Report 120 Aged Accounts Receivable
src/Layers/W1/BaseApp/Sales/Reports/AgedAccountsReceivable.Report.al1,032 lines, Copyright (c) Microsoft Corporation. MIT
#if not CLEAN28// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Sales.Reports;/// <summary>/// Generates an aged accounts receivable report showing customer balances grouped by aging periods. This report is obsolete./// </summary>using Microsoft.Finance.Currency;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Sales.Customer;using Microsoft.Sales.Receivables;using Microsoft.Utilities;using System.Utilities;report 120 "Aged Accounts Receivable"{ ApplicationArea = Basic, Suite; Caption = 'Aged Accounts Receivable (Obsolete)'; PreviewMode = PrintLayout; UsageCategory = ReportsAndAnalysis; DataAccessIntent = ReadOnly; ObsoleteState = Pending; ObsoleteReason = 'This report has been replaced by the report Aged Accounts Receivable (Excel). This report will be removed in a future release.'; ObsoleteTag = '28.0'; DefaultRenderingLayout = RDLCLayout; dataset { dataitem(Header; "Integer") { DataItemTableView = sorting(Number) where(Number = const(1)); column(CompanyName; CompanyDisplayName) { } column(FormatEndingDate; StrSubstNo(Text006, Format(EndingDate, 0, 4))) { } column(PostingDate; StrSubstNo(Text007, SelectStr(AgingBy + 1, Text009))) { } column(PrintAmountInLCY; PrintAmountInLCY) { } column(TableCaptnCustFilter; Customer.TableCaption + ': ' + CustFilter) { } column(CustFilter; CustFilter) { } column(AgingByDueDate; AgingBy = AgingBy::"Due Date") { } column(AgedbyDocumnetDate; StrSubstNo(Text004, SelectStr(AgingBy + 1, Text009))) { } column(HeaderText5; HeaderText[5]) { } column(HeaderText4; HeaderText[4]) { } column(HeaderText3; HeaderText[3]) { } column(HeaderText2; HeaderText[2]) { } column(HeaderText1; HeaderText[1]) { } column(PrintDetails; PrintDetails) { } column(AgedAccReceivableCptn; AgedAccReceivableCptnLbl) { } column(CurrReportPageNoCptn; CurrReportPageNoCptnLbl) { } column(AllAmtinLCYCptn; AllAmtinLCYCptnLbl) { } column(AgedOverdueAmtCptn; AgedOverdueAmtCptnLbl) { } column(CLEEndDateAmtLCYCptn; CLEEndDateAmtLCYCptnLbl) { } column(CLEEndDateDueDateCptn; CLEEndDateDueDateCptnLbl) { } column(CLEEndDateDocNoCptn; CLEEndDateDocNoCptnLbl) { } column(CLEEndDatePstngDateCptn; CLEEndDatePstngDateCptnLbl) { } column(CLEEndDateDocTypeCptn; CLEEndDateDocTypeCptnLbl) { } column(OriginalAmtCptn; OriginalAmtCptnLbl) { } column(TotalLCYCptn; TotalLCYCptnLbl) { } column(NewPagePercustomer; NewPagePercustomer) { } column(GrandTotalCLE5RemAmt; GrandTotalCustLedgEntry[5]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE4RemAmt; GrandTotalCustLedgEntry[4]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE3RemAmt; GrandTotalCustLedgEntry[3]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE2RemAmt; GrandTotalCustLedgEntry[2]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE1RemAmt; GrandTotalCustLedgEntry[1]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLEAmtLCY; GrandTotalCustLedgEntry[1]."Amount (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE1CustRemAmtLCY; Pct(GrandTotalCustLedgEntry[1]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE2CustRemAmtLCY; Pct(GrandTotalCustLedgEntry[2]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE3CustRemAmtLCY; Pct(GrandTotalCustLedgEntry[3]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE4CustRemAmtLCY; Pct(GrandTotalCustLedgEntry[4]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE5CustRemAmtLCY; Pct(GrandTotalCustLedgEntry[5]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE1AmtLCY; GrandTotalCustLedgEntry[1]."Amount (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE5PctRemAmtLCY; Pct(GrandTotalCustLedgEntry[5]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE3PctRemAmtLCY; Pct(GrandTotalCustLedgEntry[3]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE2PctRemAmtLCY; Pct(GrandTotalCustLedgEntry[2]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE1PctRemAmtLCY; Pct(GrandTotalCustLedgEntry[1]."Remaining Amt. (LCY)", GrandTotalCustLedgEntry[1]."Amount (LCY)")) { } column(GrandTotalCLE5RemAmtLCY; GrandTotalCustLedgEntry[5]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE4RemAmtLCY; GrandTotalCustLedgEntry[4]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE3RemAmtLCY; GrandTotalCustLedgEntry[3]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE2RemAmtLCY; GrandTotalCustLedgEntry[2]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(GrandTotalCLE1RemAmtLCY; GrandTotalCustLedgEntry[1]."Remaining Amt. (LCY)") { AutoFormatType = 1; } dataitem(Customer; Customer) { RequestFilterFields = "No."; column(PageGroupNo; PageGroupNo) { } column(CustomerPhoneNoCaption; FieldCaption("Phone No.")) { } column(CustomerContactCaption; FieldCaption(Contact)) { } dataitem("Cust. Ledger Entry"; "Cust. Ledger Entry") { DataItemLink = "Customer No." = field("No."); DataItemTableView = sorting("Customer No.", "Posting Date", "Currency Code"); trigger OnAfterGetRecord() var CustLedgEntry: Record "Cust. Ledger Entry"; begin CustLedgEntry.SetCurrentKey("Closed by Entry No."); if "Closed by Entry No." <> 0 then CustLedgEntry.SetFilter("Closed by Entry No.", '%1|%2', "Entry No.", "Closed by Entry No.") else CustLedgEntry.SetRange("Closed by Entry No.", "Entry No."); CustLedgEntry.SetRange("Posting Date", 0D, EndingDate); CopyDimFiltersFromCustomer(CustLedgEntry); if CustLedgEntry.FindSet(false) then repeat InsertTemp(CustLedgEntry); until CustLedgEntry.Next() = 0; CustLedgEntry.Reset(); CustLedgEntry.SetRange("Entry No.", "Closed by Entry No."); CustLedgEntry.SetRange("Posting Date", 0D, EndingDate); CopyDimFiltersFromCustomer(CustLedgEntry); if CustLedgEntry.FindSet(false) then repeat InsertTemp(CustLedgEntry); until CustLedgEntry.Next() = 0; CurrReport.Skip(); end; trigger OnPreDataItem() begin SetRange("Posting Date", EndingDate + 1, DMY2Date(31, 12, 9999)); CopyDimFiltersFromCustomer("Cust. Ledger Entry"); Customer.CopyFilter("Currency Filter", "Currency Code"); end; } dataitem(OpenCustLedgEntry; "Cust. Ledger Entry") { DataItemLink = "Customer No." = field("No."); DataItemTableView = sorting("Customer No.", Open, Positive, "Due Date", "Currency Code"); trigger OnAfterGetRecord() begin InsertTemp(OpenCustLedgEntry); CurrReport.Skip(); end; trigger OnPreDataItem() begin if AgingBy = AgingBy::"Posting Date" then begin SetRange("Posting Date", 0D, EndingDate); SetRange("Date Filter", 0D, EndingDate); SetAutoCalcFields("Remaining Amt. (LCY)"); SetFilter("Remaining Amt. (LCY)", '<>0'); end; CopyDimFiltersFromCustomer(OpenCustLedgEntry); Customer.CopyFilter("Currency Filter", "Currency Code"); end; } dataitem(CurrencyLoop; "Integer") { DataItemTableView = sorting(Number) where(Number = filter(1 ..)); PrintOnlyIfDetail = true; dataitem(TempCustLedgEntryLoop; "Integer") { DataItemTableView = sorting(Number) where(Number = filter(1 ..)); column(Name1_Cust; Customer.Name) { IncludeCaption = true; } column(No_Cust; Customer."No.") { IncludeCaption = true; } column(CustomerPhoneNo; Customer."Phone No.") { } column(CustomerContactName; Customer.Contact) { } column(CLEEndDateRemAmtLCY; CustLedgEntryEndingDate."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(AgedCLE1RemAmtLCY; AgedCustLedgEntry[1]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(AgedCLE2RemAmtLCY; AgedCustLedgEntry[2]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(AgedCLE3RemAmtLCY; AgedCustLedgEntry[3]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(AgedCLE4RemAmtLCY; AgedCustLedgEntry[4]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(AgedCLE5RemAmtLCY; AgedCustLedgEntry[5]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(CLEEndDateAmtLCY; CustLedgEntryEndingDate."Amount (LCY)") { AutoFormatType = 1; } column(CLEEndDueDate; Format(CustLedgEntryEndingDate."Due Date")) { } column(CLEEndDateDocNo; CustLedgEntryEndingDate."Document No.") { } column(CLEDocType; Format(CustLedgEntryEndingDate."Document Type")) { } column(CLEPostingDate; Format(CustLedgEntryEndingDate."Posting Date")) { } column(AgedCLE5TempRemAmt; AgedCustLedgEntry[5]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE4TempRemAmt; AgedCustLedgEntry[4]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE3TempRemAmt; AgedCustLedgEntry[3]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE2TempRemAmt; AgedCustLedgEntry[2]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE1TempRemAmt; AgedCustLedgEntry[1]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(RemAmt_CLEEndDate; CustLedgEntryEndingDate."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(CLEEndDate_ExtDocNo; CustLedgEntryEndingDate."External Document No.") { } column(CLEEndDate; CustLedgEntryEndingDate.Amount) { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(Name_Cust; StrSubstNo(Text005, Customer.Name)) { } column(TotalCLE1AmtLCY; TotalCustLedgEntry[1]."Amount (LCY)") { AutoFormatType = 1; } column(TotalCLE1RemAmtLCY; TotalCustLedgEntry[1]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(TotalCLE2RemAmtLCY; TotalCustLedgEntry[2]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(TotalCLE3RemAmtLCY; TotalCustLedgEntry[3]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(TotalCLE4RemAmtLCY; TotalCustLedgEntry[4]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(TotalCLE5RemAmtLCY; TotalCustLedgEntry[5]."Remaining Amt. (LCY)") { AutoFormatType = 1; } column(CurrrencyCode; CurrencyCode) { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCLE5RemAmt; TotalCustLedgEntry[5]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCLE4RemAmt; TotalCustLedgEntry[4]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCLE3RemAmt; TotalCustLedgEntry[3]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCLE2RemAmt; TotalCustLedgEntry[2]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCLE1RemAmt; TotalCustLedgEntry[1]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCLE1Amt; TotalCustLedgEntry[1].Amount) { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(TotalCheck; CustFilterCheck) { } trigger OnAfterGetRecord() var PeriodIndex: Integer; begin if Number = 1 then begin if not TempCustLedgEntry.FindSet(false) then CurrReport.Break(); end else if TempCustLedgEntry.Next() = 0 then CurrReport.Break(); CustLedgEntryEndingDate := TempCustLedgEntry; DetailedCustomerLedgerEntry.SetLoadFields("Entry Type", "Posting Date", Amount, "Amount (LCY)"); DetailedCustomerLedgerEntry.SetRange("Cust. Ledger Entry No.", CustLedgEntryEndingDate."Entry No."); OnTempCustLedgEntryGetRecordOnAfterSetDetailedEntryFilters(DetailedCustomerLedgerEntry); if DetailedCustomerLedgerEntry.FindSet(false) then repeat if (DetailedCustomerLedgerEntry."Entry Type" = DetailedCustomerLedgerEntry."Entry Type"::"Initial Entry") and (CustLedgEntryEndingDate."Posting Date" > EndingDate) and (AgingBy <> AgingBy::"Posting Date") then if CustLedgEntryEndingDate."Document Date" <= EndingDate then DetailedCustomerLedgerEntry."Posting Date" := CustLedgEntryEndingDate."Document Date" else if (CustLedgEntryEndingDate."Due Date" <= EndingDate) and (AgingBy = AgingBy::"Due Date") then DetailedCustomerLedgerEntry."Posting Date" := CustLedgEntryEndingDate."Due Date"; if (DetailedCustomerLedgerEntry."Posting Date" <= EndingDate) or (TempCustLedgEntry.Open and (AgingBy = AgingBy::"Due Date") and (CustLedgEntryEndingDate."Due Date" > EndingDate) and (CustLedgEntryEndingDate."Posting Date" <= EndingDate)) then begin OnCustomerOnAfterGetRecordOnBeforeSetCustLedgEntryEndingDateAmount(CustLedgEntryEndingDate, DetailedCustomerLedgerEntry); if DetailedCustomerLedgerEntry."Entry Type" in [DetailedCustomerLedgerEntry."Entry Type"::"Initial Entry", DetailedCustomerLedgerEntry."Entry Type"::"Unrealized Loss", DetailedCustomerLedgerEntry."Entry Type"::"Unrealized Gain", DetailedCustomerLedgerEntry."Entry Type"::"Realized Loss", DetailedCustomerLedgerEntry."Entry Type"::"Realized Gain", DetailedCustomerLedgerEntry."Entry Type"::"Payment Discount", DetailedCustomerLedgerEntry."Entry Type"::"Payment Discount (VAT Excl.)", DetailedCustomerLedgerEntry."Entry Type"::"Payment Discount (VAT Adjustment)", DetailedCustomerLedgerEntry."Entry Type"::"Payment Tolerance", DetailedCustomerLedgerEntry."Entry Type"::"Payment Discount Tolerance", DetailedCustomerLedgerEntry."Entry Type"::"Payment Tolerance (VAT Excl.)", DetailedCustomerLedgerEntry."Entry Type"::"Payment Tolerance (VAT Adjustment)", DetailedCustomerLedgerEntry."Entry Type"::"Payment Discount Tolerance (VAT Excl.)", DetailedCustomerLedgerEntry."Entry Type"::"Payment Discount Tolerance (VAT Adjustment)"] then begin CustLedgEntryEndingDate.Amount := CustLedgEntryEndingDate.Amount + DetailedCustomerLedgerEntry.Amount; CustLedgEntryEndingDate."Amount (LCY)" := CustLedgEntryEndingDate."Amount (LCY)" + DetailedCustomerLedgerEntry."Amount (LCY)"; end; if DetailedCustomerLedgerEntry."Posting Date" <= EndingDate then begin CustLedgEntryEndingDate."Remaining Amount" := CustLedgEntryEndingDate."Remaining Amount" + DetailedCustomerLedgerEntry.Amount; CustLedgEntryEndingDate."Remaining Amt. (LCY)" := CustLedgEntryEndingDate."Remaining Amt. (LCY)" + DetailedCustomerLedgerEntry."Amount (LCY)"; end; end; until DetailedCustomerLedgerEntry.Next() = 0; if CustLedgEntryEndingDate."Remaining Amount" = 0 then CurrReport.Skip(); case AgingBy of AgingBy::"Due Date": PeriodIndex := GetPeriodIndex(CustLedgEntryEndingDate."Due Date"); AgingBy::"Posting Date": PeriodIndex := GetPeriodIndex(CustLedgEntryEndingDate."Posting Date"); AgingBy::"Document Date": begin if CustLedgEntryEndingDate."Document Date" > EndingDate then begin CustLedgEntryEndingDate."Remaining Amount" := 0; CustLedgEntryEndingDate."Remaining Amt. (LCY)" := 0; CustLedgEntryEndingDate."Document Date" := CustLedgEntryEndingDate."Posting Date"; end; PeriodIndex := GetPeriodIndex(CustLedgEntryEndingDate."Document Date"); end; end; Clear(AgedCustLedgEntry); AgedCustLedgEntry[PeriodIndex]."Remaining Amount" := CustLedgEntryEndingDate."Remaining Amount"; AgedCustLedgEntry[PeriodIndex]."Remaining Amt. (LCY)" := CustLedgEntryEndingDate."Remaining Amt. (LCY)"; TotalCustLedgEntry[PeriodIndex]."Remaining Amount" += CustLedgEntryEndingDate."Remaining Amount"; TotalCustLedgEntry[PeriodIndex]."Remaining Amt. (LCY)" += CustLedgEntryEndingDate."Remaining Amt. (LCY)"; GrandTotalCustLedgEntry[PeriodIndex]."Remaining Amt. (LCY)" += CustLedgEntryEndingDate."Remaining Amt. (LCY)"; TotalCustLedgEntry[1].Amount += CustLedgEntryEndingDate."Remaining Amount"; TotalCustLedgEntry[1]."Amount (LCY)" += CustLedgEntryEndingDate."Remaining Amt. (LCY)"; GrandTotalCustLedgEntry[1]."Amount (LCY)" += CustLedgEntryEndingDate."Remaining Amt. (LCY)"; NumberOfLines += 1; end; trigger OnPostDataItem() begin if not PrintAmountInLCY then UpdateCurrencyTotals(); end; trigger OnPreDataItem() begin if not PrintAmountInLCY then if (TempCurrency.Code = '') or (TempCurrency.Code = GLSetup."LCY Code") then TempCustLedgEntry.SetFilter("Currency Code", '%1|%2', GLSetup."LCY Code", '') else TempCustLedgEntry.SetRange("Currency Code", TempCurrency.Code); PageGroupNo := NextPageGroupNo; if NewPagePercustomer and (NumberOfCurrencies > 0) then NextPageGroupNo := PageGroupNo + 1; end; } trigger OnAfterGetRecord() begin Clear(TotalCustLedgEntry); if Number = 1 then begin if not TempCurrency.FindSet(false) then begin CurrReport.Break(); NumberOfLines -= 1; end; end else if TempCurrency.Next() = 0 then begin CurrReport.Break(); NumberOfLines -= 1; end; if TempCurrency.Code <> '' then CurrencyCode := TempCurrency.Code else CurrencyCode := GLSetup."LCY Code"; NumberOfCurrencies := NumberOfCurrencies + 1; end; trigger OnPreDataItem() begin NumberOfCurrencies := 0; end; } trigger OnAfterGetRecord() begin if SkipZeroBalanceCustomers then begin Customer.SetRange("Date Filter", 0D, EndingDate); Customer.CalcFields("Net Change"); if Customer."Net Change" = 0 then CurrReport.Skip(); end; if NewPagePercustomer then PageGroupNo += 1; TempCurrency.Reset(); TempCurrency.DeleteAll(); TempCustLedgEntry.Reset(); TempCustLedgEntry.DeleteAll(); NumberOfLines += 1; end; } dataitem(CurrencyTotals; "Integer") { DataItemTableView = sorting(Number) where(Number = filter(1 ..)); column(CurrNo; Number = 1) { } column(TempCurrCode; TempCurrency2.Code) { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE6RemAmt; AgedCustLedgEntry[6]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE1RemAmt; AgedCustLedgEntry[1]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE2RemAmt; AgedCustLedgEntry[2]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE3RemAmt; AgedCustLedgEntry[3]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE4RemAmt; AgedCustLedgEntry[4]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(AgedCLE5RemAmt; AgedCustLedgEntry[5]."Remaining Amount") { AutoFormatExpression = CurrencyCode; AutoFormatType = 1; } column(CurrSpecificationCptn; CurrSpecificationCptnLbl) { } trigger OnAfterGetRecord() begin if Number = 1 then begin if not TempCurrency2.FindSet(false) then CurrReport.Break(); end else if TempCurrency2.Next() = 0 then CurrReport.Break(); Clear(AgedCustLedgEntry); TempCurrencyAmount.SetRange("Currency Code", TempCurrency2.Code); if TempCurrencyAmount.FindSet(false) then repeat if TempCurrencyAmount.Date <> DMY2Date(31, 12, 9999) then AgedCustLedgEntry[GetPeriodIndex(TempCurrencyAmount.Date)]."Remaining Amount" := TempCurrencyAmount.Amount else AgedCustLedgEntry[6]."Remaining Amount" := TempCurrencyAmount.Amount; until TempCurrencyAmount.Next() = 0; end; } } } requestpage { SaveValues = true; AboutTitle = 'About Aged Accounts Receivable (Obsolete)'; AboutText = 'Analyze customer balances at the end of each period by calculating outstanding invoice, credit memo, and payment totals in three periods of equal length. Measure the reliability of collectable debts for your customers.** This report is obsolete and will be removed in a future release.** Please refer to the report documentation for alternative ways to retrieve this information.'; layout { area(content) { group(Options) { Caption = 'Options'; field(AgedAsOf; EndingDate) { ApplicationArea = Basic, Suite; Caption = 'Aged As Of'; ToolTip = 'Specifies the date that you want the aging calculated for.'; } field(Agingby; AgingBy) { ApplicationArea = Basic, Suite; Caption = 'Aging by'; OptionCaption = 'Due Date,Posting Date,Document Date'; ToolTip = 'Specifies if the aging will be calculated from the due date, the posting date, or the document date.'; } field(PeriodLength; PeriodLength) { ApplicationArea = Basic, Suite; Caption = 'Period Length'; ToolTip = 'Specifies the period for which data is shown in the report. For example, enter "1M" for one month, "30D" for thirty days, "3Q" for three quarters, or "5Y" for five years.'; } field(AmountsinLCY; PrintAmountInLCY) { ApplicationArea = Basic, Suite; Caption = 'Print Amounts in LCY'; ToolTip = 'Specifies if you want the report to specify the aging per customer ledger entry.'; } field(PrintDetails; PrintDetails) { ApplicationArea = Basic, Suite; Caption = 'Print Details'; ToolTip = 'Specifies if you want the report to show the detailed entries that add up the total balance for each customer.'; } field(HeadingType; HeadingType) { ApplicationArea = Basic, Suite; Caption = 'Heading Type'; OptionCaption = 'Date Interval,Number of Days'; ToolTip = 'Specifies if the column heading for the three periods will indicate a date interval or the number of days overdue.'; } field(perCustomer; NewPagePercustomer) { ApplicationArea = Basic, Suite; Caption = 'New Page per Customer'; ToolTip = 'Specifies if each customer''s information is printed on a new page if you have chosen two or more customers to be included in the report.'; } field("Skip Zero Balance Customers"; SkipZeroBalanceCustomers) { ApplicationArea = Basic, Suite; Caption = 'Skip Customers with Zero Balance'; ToolTip = 'Specifies if you want to skip customers with a zero balance in the report.'; } } } } actions { } trigger OnOpenPage() begin if EndingDate = 0D then EndingDate := WorkDate(); if Format(PeriodLength) = '' then Evaluate(PeriodLength, '<1M>'); end; } rendering { layout(RDLCLayout) { Type = RDLC; LayoutFile = './Sales/Reports/AgedAccountsReceivable.rdlc'; Summary = 'Report layout made in the legacy RDLC format. Use an RDLC editor to modify the layout.'; } } labels { BalanceCaption = 'Balance'; } trigger OnPreReport() var FormatDocument: Codeunit "Format Document"; begin StartDateTime := CurrentDateTime(); CustFilter := FormatDocument.GetRecordFiltersWithCaptions(Customer); GLSetup.Get(); CalcDates(); CreateHeadings(); PageGroupNo := 1; NextPageGroupNo := 1; CustFilterCheck := (CustFilter <> 'No.'); CompanyDisplayName := COMPANYPROPERTY.DisplayName(); end; trigger OnPostReport() begin FinishDateTime := CurrentDateTime(); LogReportTelemetry(StartDateTime, FinishDateTime, NumberOfLines); end; var GLSetup: Record "General Ledger Setup"; CustLedgEntryEndingDate: Record "Cust. Ledger Entry"; TotalCustLedgEntry: array[5] of Record "Cust. Ledger Entry"; GrandTotalCustLedgEntry: array[5] of Record "Cust. Ledger Entry"; AgedCustLedgEntry: array[6] of Record "Cust. Ledger Entry"; TempCurrency: Record Currency temporary; TempCurrency2: Record Currency temporary; TempCurrencyAmount: Record "Currency Amount" temporary; DetailedCustomerLedgerEntry: Record "Detailed Cust. Ledg. Entry"; PeriodLength: DateFormula; PrintAmountInLCY: Boolean; SkipZeroBalanceCustomers: Boolean; EndingDate: Date; AgingBy: Option "Due Date","Posting Date","Document Date"; HeadingType: Option "Date Interval","Number of Days"; NewPagePercustomer: Boolean; PeriodStartDate: array[5] of Date; PeriodEndDate: array[5] of Date; HeaderText: array[5] of Text[30];#pragma warning disable AA0074 Text000: Label 'Not Due';#pragma warning restore AA0074 AfterTok: Label 'After'; BeforeTok: Label 'Before'; CurrencyCode: Code[10];#pragma warning disable AA0074 Text002: Label 'days';#pragma warning disable AA0470 Text004: Label 'Aged by %1'; Text005: Label 'Total for %1'; Text006: Label 'Aged as of %1'; Text007: Label 'Aged by %1';#pragma warning restore AA0470#pragma warning restore AA0074 NumberOfCurrencies: Integer;#pragma warning disable AA0074 Text009: Label 'Due Date,Posting Date,Document Date';#pragma warning disable AA0470 Text010: Label 'The Date Formula %1 cannot be used. Try to restate it. E.g. 1M+CM instead of CM+1M.';#pragma warning restore AA0470#pragma warning restore AA0074 PageGroupNo: Integer; NextPageGroupNo: Integer; CustFilterCheck: Boolean; Text032Txt: Label '-%1', Comment = 'Negating the period length: %1 is the period length'; AgedAccReceivableCptnLbl: Label 'Aged Accounts Receivable'; CurrReportPageNoCptnLbl: Label 'Page'; AllAmtinLCYCptnLbl: Label 'All Amounts in LCY'; AgedOverdueAmtCptnLbl: Label 'Aged Overdue Amounts'; CLEEndDateAmtLCYCptnLbl: Label 'Original Amount '; CLEEndDateDueDateCptnLbl: Label 'Due Date'; CLEEndDateDocNoCptnLbl: Label 'Document No.'; CLEEndDatePstngDateCptnLbl: Label 'Posting Date'; CLEEndDateDocTypeCptnLbl: Label 'Document Type'; OriginalAmtCptnLbl: Label 'Currency Code'; TotalLCYCptnLbl: Label 'Total (LCY)'; CurrSpecificationCptnLbl: Label 'Currency Specification'; EnterDateFormulaErr: Label 'Enter a date formula in the Period Length field.'; CompanyDisplayName: Text; TelemetryCategoryTxt: Label 'Report', Locked = true; AgedARReportGeneratedTxt: Label 'Aged AR Report generated.', Locked = true; protected var TempCustLedgEntry: Record "Cust. Ledger Entry" temporary; NumberOfLines: Integer; StartDateTime: DateTime; FinishDateTime: DateTime; CustFilter: Text; PrintDetails: Boolean; local procedure CalcDates() var PeriodLength2: DateFormula; i: Integer; begin if not Evaluate(PeriodLength2, StrSubstNo(Text032Txt, PeriodLength)) then Error(EnterDateFormulaErr); if AgingBy = AgingBy::"Due Date" then begin PeriodEndDate[1] := DMY2Date(31, 12, 9999); PeriodStartDate[1] := EndingDate + 1; end else begin PeriodEndDate[1] := EndingDate; PeriodStartDate[1] := CalcDate(PeriodLength2, EndingDate + 1); end; for i := 2 to ArrayLen(PeriodEndDate) do begin PeriodEndDate[i] := PeriodStartDate[i - 1] - 1; PeriodStartDate[i] := CalcDate(PeriodLength2, PeriodEndDate[i] + 1); end; PeriodStartDate[i] := 0D; for i := 1 to ArrayLen(PeriodEndDate) do if PeriodEndDate[i] < PeriodStartDate[i] then Error(Text010, PeriodLength); end; local procedure CreateHeadings() var i: Integer; begin if AgingBy = AgingBy::"Due Date" then begin HeaderText[1] := Text000; i := 2; end else i := 1; while i < ArrayLen(PeriodEndDate) do begin if HeadingType = HeadingType::"Date Interval" then HeaderText[i] := StrSubstNo('%1\..%2', PeriodStartDate[i], PeriodEndDate[i]) else HeaderText[i] := StrSubstNo('%1 - %2 %3', EndingDate - PeriodEndDate[i] + 1, EndingDate - PeriodStartDate[i] + 1, Text002); i := i + 1; end; if HeadingType = HeadingType::"Date Interval" then HeaderText[i] := StrSubstNo('%1 %2', BeforeTok, PeriodStartDate[i - 1]) else HeaderText[i] := StrSubstNo('%1 %2 %3', AfterTok, EndingDate - PeriodStartDate[i - 1] + 1, Text002); end; local procedure InsertTemp(var CustLedgEntry: Record "Cust. Ledger Entry") var Currency: Record Currency; begin if TempCustLedgEntry.Get(CustLedgEntry."Entry No.") then exit; TempCustLedgEntry := CustLedgEntry; TempCustLedgEntry.Insert(); if PrintAmountInLCY then begin Clear(TempCurrency); TempCurrency."Amount Rounding Precision" := GLSetup."Amount Rounding Precision"; if TempCurrency.Insert() then; exit; end; if TempCurrency.Get(TempCustLedgEntry."Currency Code") then exit; if TempCurrency.Get('') and (TempCustLedgEntry."Currency Code" = GLSetup."LCY Code") then exit; if TempCurrency.Get(GLSetup."LCY Code") and (TempCustLedgEntry."Currency Code" = '') then exit; if TempCustLedgEntry."Currency Code" <> '' then Currency.Get(TempCustLedgEntry."Currency Code") else begin Clear(Currency); Currency."Amount Rounding Precision" := GLSetup."Amount Rounding Precision"; end; TempCurrency := Currency; TempCurrency.Insert(); end; local procedure GetPeriodIndex(Date: Date): Integer var i: Integer; begin for i := 1 to ArrayLen(PeriodEndDate) do if Date in [PeriodStartDate[i] .. PeriodEndDate[i]] then exit(i); end; local procedure Pct(a: Decimal; b: Decimal): Text[30] begin if b <> 0 then exit(Format(Round(100 * a / b, 0.1), 0, '<Sign><Integer><Decimals,2>') + '%'); end; local procedure UpdateCurrencyTotals() var i: Integer; begin TempCurrency2.Code := CurrencyCode; if TempCurrency2.Insert() then; for i := 1 to ArrayLen(TotalCustLedgEntry) do begin TempCurrencyAmount."Currency Code" := CurrencyCode; TempCurrencyAmount.Date := PeriodStartDate[i]; if TempCurrencyAmount.Find() then begin TempCurrencyAmount.Amount := TempCurrencyAmount.Amount + TotalCustLedgEntry[i]."Remaining Amount"; TempCurrencyAmount.Modify(); end else begin TempCurrencyAmount."Currency Code" := CurrencyCode; TempCurrencyAmount.Date := PeriodStartDate[i]; TempCurrencyAmount.Amount := TotalCustLedgEntry[i]."Remaining Amount"; TempCurrencyAmount.Insert(); end; end; TempCurrencyAmount."Currency Code" := CurrencyCode; TempCurrencyAmount.Date := DMY2Date(31, 12, 9999); if TempCurrencyAmount.Find() then begin TempCurrencyAmount.Amount := TempCurrencyAmount.Amount + TotalCustLedgEntry[1].Amount; TempCurrencyAmount.Modify(); end else begin TempCurrencyAmount."Currency Code" := CurrencyCode; TempCurrencyAmount.Date := DMY2Date(31, 12, 9999); TempCurrencyAmount.Amount := TotalCustLedgEntry[1].Amount; TempCurrencyAmount.Insert(); end; end; /// <summary> /// Initializes the report request options for the Aged Accounts Receivable report. /// </summary> /// <param name="NewEndingDate">The ending date for aging calculation.</param> /// <param name="NewAgingBy">The aging method (due date, posting date, or document date).</param> /// <param name="NewPeriodLength">The period length formula for aging buckets.</param> /// <param name="NewPrintAmountInLCY">True to print amounts in local currency.</param> /// <param name="NewPrintDetails">True to print detailed entries.</param> /// <param name="NewHeadingType">The heading type for the report.</param> /// <param name="NewPagePercust">True to start a new page per customer.</param> procedure InitializeRequest(NewEndingDate: Date; NewAgingBy: Option; NewPeriodLength: DateFormula; NewPrintAmountInLCY: Boolean; NewPrintDetails: Boolean; NewHeadingType: Option; NewPagePercust: Boolean) begin EndingDate := NewEndingDate; AgingBy := NewAgingBy; PeriodLength := NewPeriodLength; PrintAmountInLCY := NewPrintAmountInLCY; PrintDetails := NewPrintDetails; HeadingType := NewHeadingType; NewPagePercustomer := NewPagePercust; end; local procedure CopyDimFiltersFromCustomer(var CustLedgerEntry: Record "Cust. Ledger Entry") begin if Customer.GetFilter("Global Dimension 1 Filter") <> '' then CustLedgerEntry.SetFilter("Global Dimension 1 Code", Customer.GetFilter("Global Dimension 1 Filter")); if Customer.GetFilter("Global Dimension 2 Filter") <> '' then CustLedgerEntry.SetFilter("Global Dimension 2 Code", Customer.GetFilter("Global Dimension 2 Filter")); end; local procedure LogReportTelemetry(StartDateTime: DateTime; FinishDateTime: DateTime; NumberOfLines: Integer) var Dimensions: Dictionary of [Text, Text]; ReportDuration: BigInteger; begin ReportDuration := FinishDateTime - StartDateTime; Dimensions.Add('Category', TelemetryCategoryTxt); Dimensions.Add('ReportStartTime', Format(StartDateTime, 0, 9)); Dimensions.Add('ReportFinishTime', Format(FinishDateTime, 0, 9)); Dimensions.Add('ReportDuration', Format(ReportDuration)); Dimensions.Add('NumberOfLines', Format(NumberOfLines)); Session.LogMessage('0000FJM', AgedARReportGeneratedTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, Dimensions); end; [IntegrationEvent(false, false)] local procedure OnTempCustLedgEntryGetRecordOnAfterSetDetailedEntryFilters(var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry") begin end; [IntegrationEvent(false, false)] local procedure OnCustomerOnAfterGetRecordOnBeforeSetCustLedgEntryEndingDateAmount(var CustLedgEntryEndingDate: Record "Cust. Ledger Entry"; var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry") begin end;}#endif