I've been developing a report extension for our finance department. The default 1316 report is like a bank statement, showing all activity on the account. Their requirement is for it to only show Open entries. I've tried a number of different ways of doing this, but can't seem to get it to show only invoice amounts that are outstanding.
I've tried adding a DataItemLink to the ledger entries and then filtering based on the remaining amount field; I've also tried using the PreDataItem trigger and the OnAfterGetRecord to set the range and tried setting the filter, but the report keeps showing transactions with a remaining amount of 0.
I had a look at the AL code from the Base Application, and weirdly it already seems to be doing the exact thing I want it to do, so I can't figure out why it isn't filtering out the amounts that are 0.
// CODE FROM StandardStatement.Report.al
dataitem(CustLedgEntry2; "Cust. Ledger Entry")
{
DataItemLink = "Customer No." = FIELD("No.");
DataItemLinkReference = Customer;
DataItemTableView = SORTING("Customer No.", Open, Positive, "Due Date");
column(OverDueEntries; StrSubstNo(OverdueEntriesLbl, TempCurrency2.Code))
{
}
... {lots of column definitions, truncated for brevity}
trigger OnAfterGetRecord()
var
CustLedgEntry: Record "Cust. Ledger Entry";
begin
if IncludeAgingBand then
if ("Posting Date" > EndDate) and ("Due Date" >= EndDate) then
CurrReport.Skip();
CustLedgEntry := CustLedgEntry2;
CustLedgEntry.SetRange("Date Filter", 0D, EndDate);
CustLedgEntry.CalcFields("Remaining Amount");
"Remaining Amount" := CustLedgEntry."Remaining Amount";
if CustLedgEntry."Remaining Amount" = 0 then
CurrReport.Skip();
if "Due Date" >= EndDate then
CurrReport.Skip();
Any help would be appreciated!