Can't Get Amount from Cust. Ledger Entry.

zulq
zulq Member Posts: 204
Hi Am building a report that shows Customer Arrears. I am using the Customer and the Cust. Ledger Entry tables.
Below is my Code:


CustLedgerEntry.SETRANGE("Customer No.","No.");
CustLedgerEntry.SETFILTER("Start Period",'>=%1',DateFrom);
CustLedgerEntry.SETFILTER("End Period",'<=%1',DateTo);

IF (DateFrom <> 0D) AND (DateTo > DateFrom) THEN BEGIN
Calendar.RESET;
Calendar.SETRANGE("Period Type",Calendar."Period Type"::Month);
Calendar.SETRANGE("Period Start",DateFrom,DateTo);
Months := Calendar.COUNT;
END ELSE
Months := 0;

MonthsOwed := 0;
AmountOwed := 0;
IF CustLedgerEntry.FIND('-')
THEN BEGIN
MonthsPaid := CustLedgerEntry.COUNT;
END ELSE BEGIN
MonthsPaid := 0;
END;

IF (MonthsPaid < Months)
THEN BEGIN
MonthsOwed := Months - MonthsPaid;
END;

IF CustLedgerEntry.FIND('+')
THEN BEGIN
LastAmount := CustLedgerEntry."Original Amount";
END;

IF MonthsPaid <> 0
THEN BEGIN
AmountOwed := LastAmount * MonthsPaid;
END;


All fields are coming correctly from the Cust. Ledger Entry except the Amounts. I've used several of the varying amounts in the Cust. Ledger Entry but none of them work.

Am I missing something! Please help...
Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?

Answers

  • Albertvh
    Albertvh Member Posts: 516
    Hi

    Do the following
    IF CustLedgerEntry.FIND('+') 
    THEN BEGIN 
    CustLedgerEntry.CALCFIELDS("Original Amount");
    LastAmount := CustLedgerEntry."Original Amount"; 
    END;
    
  • zulq
    zulq Member Posts: 204
    Thanks Albertvh.
    But now I want to change the Amount to positive how do I do that?

    Thanks.
    Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?
  • Albertvh
    Albertvh Member Posts: 516
    HI Zulq

    LastAmount := -CustLedgerEntry."Original Amount";

    <Edit>
    or

    LastAmount := ABS(CustLedgerEntry."Original Amount");

    <End Edit>
  • zulq
    zulq Member Posts: 204
    Thanks a lot Albertvh.
    Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?