Logic not working - Aging report

roshini
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
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
0
Answers
-
Your code needs to be changed.
Your Cust. ledger entries either go on due or overdue buckets. The code should look like thisCLEAR(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;
0 -
Hi Mr. Rashed,
Big Thanks for your Excellent Support.
Thanking You0 -
You are welcome.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions