Open Sales Invoices by Job Report

ivanlotterivanlotter Member Posts: 31
I have inherited a report that I can't fix.

The report looks at 3 tables Job, Sales Invoice Lines (Indented 1) and Cust Ledg Entry (Indented 2).

It should return all open (unpaid/Remaing Amount >0)Invoices by Job.

Maybe someone can see a mistake in the code.

I have inserted the code below.

Sales Invoice Line
Documentation()

Sales Invoice Line - OnPreDataItem()
IF NOT SETCURRENTKEY("Job No.","Document No.") THEN BEGIN
  SETCURRENTKEY("Document No.");
  IF NOT AlreadyDisplayedMessage THEN BEGIN
    MESSAGE('This report will run much faster next time if you add a key to '+
            'the %1 table (113) which starts with %2,%3',
            TABLENAME,FIELDNAME("Job No."),FIELDNAME("Document No."));
    AlreadyDisplayedMessage := TRUE;
  END;
END;
CurrReport.CREATETOTALS("Cust. Ledger Entry"."Amount (LCY)","Cust. Ledger Entry"."Remaining Amt. (LCY)");

Sales Invoice Line - OnAfterGetRecord()
SETRANGE("Document No.","Document No.");
FIND('+');
SETRANGE("Document No.");
SalesInvoiceHeader.GET("Document No.");





Customer Ledger Entry
Documentation()

Cust. Ledger Entry - OnPreDataItem()
SETRANGE("Customer No.",SalesInvoiceHeader."Bill-to Customer No.");
CurrReport.CREATETOTALS("Amount (LCY)","Remaining Amt. (LCY)");

Cust. Ledger Entry - OnAfterGetRecord()
IF PrintAmountsInLocal THEN BEGIN
  OriginalAmtToPrint := Amount;
  BalanceToPrint := "Remaining Amount";
  PaymentsOrAdjustment := Amount - "Remaining Amount";
END ELSE BEGIN
  OriginalAmtToPrint := "Amount (LCY)";
  BalanceToPrint := "Remaining Amt. (LCY)";
  PaymentsOrAdjustment := "Amount (LCY)" - "Remaining Amt. (LCY)";
END;

Cust. Ledger Entry - OnPostDataItem()
Ivan Lötter

Answers

  • AlbertvhAlbertvh Member Posts: 516
    Hi ivanlotter

    I think you have to use CALCFIELDS for Cust. Ledger Entry


    Albert
  • ivanlotterivanlotter Member Posts: 31
    Thanks Albertvh for the advice but but I think it has got to do with the properties of the various amount fields in the Customer Ledger Entry table because if I use the Sales (LCY) and Profit (LCY) field it gives me a value but for all the other "Amount" fields it gives me a zero value.

    Is it a property problem?
    Ivan Lötter
  • AlbertvhAlbertvh Member Posts: 516
    Most of the Amount field in the Cust. Ledger Entry are flowfields so you will have to use the CALCFIELDS :wink:
  • ivanlotterivanlotter Member Posts: 31
    Thanks Albertvh it was the CALCFIELD function.
    Ivan Lötter
  • AlbertvhAlbertvh Member Posts: 516
    Glad to have been able to help
Sign In or Register to comment.