Hi Community,
I'm working on a customised "Salesperson - Commission" report where it is extended with the Sales lines to get a more detailed view of the commission and sales. There is also a customisation where the commission is based on the item, not on the salesperson.
The challenge I am facing is when there is a Sales Credit Memo for a Sales Invoice. The report should only show Sales Invoice Lines where there is no Sales Credit Memo (lines).
The only connection I have found between the two (Sales Invoice and Sales Credit Memo) are the fields "Applies-to Doc. No." and "Applies-to Doc. Type" in the Credit Memo. It would also be possible to use the "Cancelled" field on the Sales Invoice Header but this is probably not reliable in all scenarios.
The dataset in the report currently looks as this (high level):
dataset
{
dataitem("Salesperson/Purchaser"; "Salesperson/Purchaser")
{
RequestFilterHeading = 'Salesperson/Purchaser';
DataItemTableView = SORTING(Code);
PrintOnlyIfDetail = true;
RequestFilterFields = "Code";
dataitem("Cust. Ledger Entry"; "Cust. Ledger Entry")
{
DataItemLink = "Salesperson Code" = FIELD(Code);
DataItemTableView = SORTING("Salesperson Code", "Posting Date") WHERE("Document Type" = FILTER(Invoice | "Credit Memo"));
RequestFilterHeading = 'Time Period';
RequestFilterFields = "Posting Date";
dataitem("Sales Invoice Header"; "Sales Invoice Header")
{
DataItemLink = "No." = FIELD("Document No.");
dataitem("Sales Invoice Line"; "Sales Invoice Line")
{
DataItemLink = "Document No." = FIELD("No.");
DataItemTableView = SORTING("Document No."));
}
}
}
}
How is it possible to extend the dataset with filters or queries to achieve the goal of only getting invoices without corresponding sales invoices?
Thank you in advance for your input.