Customer Summary aging pr G/L Account - wrong results
dabba23
Member Posts: 77
Hi,
I have a report that needs to show Customer summary aging pr G/L Account.
First I start with a dataitem of G/L Account in order to combine my detailed cust. ledg. entries with a g/l account:
G/L Account - OnAfterGetRecord
GLEntry.SETCURRENTKEY("G/L Account No.");
GLEntry.SETRANGE("G/L Account No.","No.");
IF GLEntry.FIND('-') THEN
REPEAT
CustLedgEntry.SETCURRENTKEY("Entry No.");
CustLedgEntry.SETRANGE("Entry No.",GLEntry."Entry No.");
IF CustLedgEntry.FIND('-') THEN
REPEAT
DtldCustLedgEntry.SETCURRENTKEY("Cust. Ledger Entry No.");
DtldCustLedgEntry.SETRANGE("Cust. Ledger Entry No.",CustLedgEntry."Entry No.");
DtldCustLedgEntry.SETRANGE("Customer No.",CustLedgEntry."Customer No.");
IF DtldCustLedgEntry.FIND('-') THEN
REPEAT
TempCustLedgEntry."Entry No." := DtldCustLedgEntry."Entry No.";
TempCustLedgEntry.INSERT;
TempCustLedgEntry."Document No." := GLEntry."G/L Account No.";
TempCustLedgEntry."Posting Date" := DtldCustLedgEntry."Posting Date";
TempCustLedgEntry."Customer No." := DtldCustLedgEntry."Customer No.";
TempCustLedgEntry."Initial Entry Due Date" := DtldCustLedgEntry."Initial Entry Due Date";
TempCustLedgEntry."Amount (LCY)" := DtldCustLedgEntry."Amount (LCY)";
TempCustLedgEntry.MODIFY;
UNTIL DtldCustLedgEntry.NEXT = 0;
UNTIL CustLedgEntry.NEXT = 0;
UNTIL GLEntry.NEXT = 0;
when having filled in my temp record, I then create a new dataitem called Customer.
I want for each G/L account show a summary of aging amount pr cust.:
Customer - OnPreDataItem
CurrReport.CREATETOTALS(CustBalanceDueLCY);
Customer - OnAfterGetRecord
PrintCust := FALSE;
FOR i := 1 TO 5 DO BEGIN
TempCustLedgEntry.SETCURRENTKEY("Customer No.","Initial Entry Due Date","Posting Date","Document No.");
TempCustLedgEntry.SETRANGE("Document No.","G/L Account"."No.");
TempCustLedgEntry.SETRANGE("Customer No.","No.");
TempCustLedgEntry.SETRANGE("Posting Date",0D,StartDate);
TempCustLedgEntry.SETRANGE("Initial Entry Due Date",PeriodStartDate,PeriodStartDate[i + 1] - 1);
TempCustLedgEntry.CALCSUMS("Amount (LCY)");
CustBalanceDueLCY := DtldCustLedgEntry."Amount (LCY)";
IF CustBalanceDueLCY <> 0 THEN
PrintCust := TRUE;
END;
IF NOT PrintCust THEN
CurrReport.SKIP;
Report - OnPreReport
However, I get the result of 1000 for each customer and for each period.
The layout of the report is the same as report 109 however I start with showing G/L Account No. first.
What is wrong with my code, since it is not showing correct data? When debugging through my temp record when wanting to sum the amount, I always only see one customer from the temp record. Why is that?
I have a report that needs to show Customer summary aging pr G/L Account.
First I start with a dataitem of G/L Account in order to combine my detailed cust. ledg. entries with a g/l account:
G/L Account - OnAfterGetRecord
GLEntry.SETCURRENTKEY("G/L Account No.");
GLEntry.SETRANGE("G/L Account No.","No.");
IF GLEntry.FIND('-') THEN
REPEAT
CustLedgEntry.SETCURRENTKEY("Entry No.");
CustLedgEntry.SETRANGE("Entry No.",GLEntry."Entry No.");
IF CustLedgEntry.FIND('-') THEN
REPEAT
DtldCustLedgEntry.SETCURRENTKEY("Cust. Ledger Entry No.");
DtldCustLedgEntry.SETRANGE("Cust. Ledger Entry No.",CustLedgEntry."Entry No.");
DtldCustLedgEntry.SETRANGE("Customer No.",CustLedgEntry."Customer No.");
IF DtldCustLedgEntry.FIND('-') THEN
REPEAT
TempCustLedgEntry."Entry No." := DtldCustLedgEntry."Entry No.";
TempCustLedgEntry.INSERT;
TempCustLedgEntry."Document No." := GLEntry."G/L Account No.";
TempCustLedgEntry."Posting Date" := DtldCustLedgEntry."Posting Date";
TempCustLedgEntry."Customer No." := DtldCustLedgEntry."Customer No.";
TempCustLedgEntry."Initial Entry Due Date" := DtldCustLedgEntry."Initial Entry Due Date";
TempCustLedgEntry."Amount (LCY)" := DtldCustLedgEntry."Amount (LCY)";
TempCustLedgEntry.MODIFY;
UNTIL DtldCustLedgEntry.NEXT = 0;
UNTIL CustLedgEntry.NEXT = 0;
UNTIL GLEntry.NEXT = 0;
when having filled in my temp record, I then create a new dataitem called Customer.
I want for each G/L account show a summary of aging amount pr cust.:
Customer - OnPreDataItem
CurrReport.CREATETOTALS(CustBalanceDueLCY);
Customer - OnAfterGetRecord
PrintCust := FALSE;
FOR i := 1 TO 5 DO BEGIN
TempCustLedgEntry.SETCURRENTKEY("Customer No.","Initial Entry Due Date","Posting Date","Document No.");
TempCustLedgEntry.SETRANGE("Document No.","G/L Account"."No.");
TempCustLedgEntry.SETRANGE("Customer No.","No.");
TempCustLedgEntry.SETRANGE("Posting Date",0D,StartDate);
TempCustLedgEntry.SETRANGE("Initial Entry Due Date",PeriodStartDate,PeriodStartDate[i + 1] - 1);
TempCustLedgEntry.CALCSUMS("Amount (LCY)");
CustBalanceDueLCY := DtldCustLedgEntry."Amount (LCY)";
IF CustBalanceDueLCY <> 0 THEN
PrintCust := TRUE;
END;
IF NOT PrintCust THEN
CurrReport.SKIP;
Report - OnPreReport
However, I get the result of 1000 for each customer and for each period.
The layout of the report is the same as report 109 however I start with showing G/L Account No. first.
What is wrong with my code, since it is not showing correct data? When debugging through my temp record when wanting to sum the amount, I always only see one customer from the temp record. Why is that?
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions