Logic not working - Aging report

roshiniroshini Member Posts: 122
Hi Nav Experts!

I have modified standard report 109:Customer - Summary Aging Simp., as per customer requirement.

My Logic is not working properly. details as follows:

here customer having additional fields 1. Cust. Payment date 2. Sus.Duedate

Example data:

Posting Date| Cust. Payment Date| Sus.DueDate | Amount
2008/7/15 | 2008/07/20 | 2008/08/20 | 840
2008/8/21 | 2008/09/20 | 2008/10/20 | 12,600
2008/10/16 | 2008/10/20 | 2008/11/20 | 12,600
2008/10/16 | 2008/10/20 | 2008/11/20 | 12,600


Startdate > Sus.DueDate will be Overdue
Example: Startdate --> 2008/12/24, then as per above data all invoices will display in overdue columns, if Startdate--> 2008/10/23 then as per above data, last two invoices should show in due columns and first 3 invoices should show in overdue column as sus.duedate is greaterthen Startdate.

Startdate < Sus.DueDate will be due and have to check cust. payment date of particular Invoice not posting date

Reprot format is :


....................................| Trade AR Due ......................... | Trade AR OverDue
SusDue Date | Document No. | less 30D | 31-60D | 61-90D | More | less 30D | 31-60D | 61-90D | More


My code as follows:

PrintCust := FALSE;

DtldCustLedgEntry.RESET;
DtldCustLedgEntry.SETRANGE(DtldCustLedgEntry."Customer No.",Customer."No.");

IF DtldCustLedgEntry.FIND('-') THEN

IF StartDate < DtldCustLedgEntry."Sus. DueDate" THEN BEGIN
FOR i := 1 TO 15 DO BEGIN
DtldCustLedgEntry.SETCURRENTKEY("Customer No.","Sus. DueDate","Cust. Payment Date");
DtldCustLedgEntry.SETRANGE("Customer No.","No.");
DtldCustLedgEntry.SETRANGE("Cust. Payment Date",0D,StartDate);
DtldCustLedgEntry.SETRANGE("Cust. Payment Date",PeriodStartDate,PeriodStartDate[i + 1] - 1);
DtldCustLedgEntry.CALCSUMS("Amount (LCY)");

CustLedgerEntryRec.RESET;
IF CustLedgerEntryRec.FIND('-') THEN BEGIN
CustBalanceDueLCY := DtldCustLedgEntry."Amount (LCY)";
END ELSE BEGIN
CustBalanceDueLCY := 0;
END;
IF CustBalanceDueLCY <> 0 THEN
PrintCust := TRUE;
END;
IF NOT PrintCust THEN
CurrReport.SKIP;

END ELSE BEGIN

// 2nd

PrintCust2 := FALSE;

FOR k := 1 TO 15 DO BEGIN
DtldCustLedgEntry2.SETCURRENTKEY("Customer No.","Sus. DueDate","Cust. Payment Date");
DtldCustLedgEntry2.SETRANGE("Customer No.","No.");
DtldCustLedgEntry2.SETRANGE("Sus. DueDate",0D,StartDate);
DtldCustLedgEntry2.SETRANGE("Sus. DueDate",PeriodStartDate2[k],PeriodStartDate2[k + 1] - 1);
DtldCustLedgEntry2.CALCSUMS("Amount (LCY)");
CustLedgerEntryRec2.RESET;
IF CustLedgerEntryRec2.FIND('-') THEN BEGIN
CustBalanceDueLCY2[k] := DtldCustLedgEntry2."Amount (LCY)";
END ELSE BEGIN
CustBalanceDueLCY2[k] := 0;
END;
IF CustBalanceDueLCY2[k] <> 0 THEN
PrintCust2 := TRUE;
END;
IF NOT PrintCust2 THEN
CurrReport.SKIP;
END;

Can any one suggest how to work logic properly.

Thanking You

Answers

  • ara3nara3n Member Posts: 9,256
    Your code needs to be changed.
    Your Cust. ledger entries either go on due or overdue buckets. The code should look like this
    CLEAR(CustBalanceDueLCY)
    FOR i := 1 TO 5 DO BEGIN
      DtldCustLedgEntry.SETCURRENTKEY("Customer No.","Sus. DueDate","Cust. Payment Date"); 
      DtldCustLedgEntry.SETRANGE("Customer No.","No.");
      DtldCustLedgEntry.SETRANGE("Cust. Payment Date",0D,StartDate);
      DtldCustLedgEntry.SETRANGE("Cust. Payment Date",PeriodStartDate[i],PeriodStartDate[i + 1] - 1);
      IF CustLedgerEntryRec.FIND('-') THEN REPEAT
        IF (CustLedgerEntryRec."Sus. DueDate" >= PeriodStartDate[i])) AND (CustLedgerEntryRec."Sus. DueDate" <= PeriodStartDate[i + 1] - 1) THEN
          CustBalanceDueLCY[i] +=0
       ELSE
         CustBalanceDueLCY[i] += DtldCustLedgEntry."Amount (LCY)";
    
      UNTIL CustLedgerEntryRec.NEXT = 0;
    END;
    
    FOR i := 1 TO 5 DO BEGIN
      DtldCustLedgEntry.SETCURRENTKEY("Customer No.","Sus. DueDate","Cust. Payment Date"); 
      DtldCustLedgEntry.SETRANGE("Customer No.","No.");
      DtldCustLedgEntry.SETRANGE(""Sus. DueDate",0D,StartDate);
      DtldCustLedgEntry.SETRANGE(""Sus. DueDate",PeriodStartDate[i],PeriodStartDate[i + 1] - 1);
      IF CustLedgerEntryRec.FIND('-') THEN REPEAT
         CustBalanceDueLCY[i+5] += DtldCustLedgEntry."Amount (LCY)";
      UNTIL CustLedgerEntryRec.NEXT = 0;
    END;
    
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • roshiniroshini Member Posts: 122
    Hi Mr. Rashed,

    Big Thanks for your Excellent Support.


    Thanking You
  • ara3nara3n Member Posts: 9,256
    You are welcome.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.