Progressive Sum Cust. Ledger Entries Form

liquid_dreamliquid_dream Member Posts: 8
Hi everyone,
I need to have a column in Cust. Ledger Entries Form that has the progressive sum of the Field "Amount (LCY)".

Example:
Entry No. "Amount (LCY)" Prog Sum
01 100 100
02 200 300
03 -300 0
04 -500 -500



I can do this when the form opens, but i would also like to be able to refresh the values if a filter is applied to the form.
I wonder if this is possible at all...
Thanks

Comments

  • ara3nara3n Member Posts: 9,257
    Hello Please follow the following instructions

    Design the form and add a new text column set the source expression to
    GetProgresiveSum("Entry No.")

    Create a function as bellow.
    GetProgresiveSum(entryNo : Integer) : Decimal
    CustLedger.COPYFILTERS(Rec);
    CustLedger.SETFILTER("Entry No.",'0..%1',entryNo);
    TotalSum := 0;
    IF CustLedger.FIND('-') THEN REPEAT
    //Rec.COPYFILTER("Customer No.",CustDetail."Customer No.");
    
    CustDetail.SETCURRENTKEY("Cust. Ledger Entry No.","Entry Type","Posting Date");
    CustDetail.SETFILTER("Entry Type",'<>%1&<>%2&<>%3',CustDetail."Entry Type"::Application,
                         CustDetail."Entry Type"::"Appln. Rounding", CustDetail."Entry Type"::"Correction of Remaining Amount");
    CustDetail.SETRANGE("Cust. Ledger Entry No.",CustLedger."Entry No.");
    CustDetail.CALCSUMS("Amount (LCY)");
      TotalSum +=  CustDetail."Amount (LCY)";
    UNTIL CustLedger.NEXT = 0;
    EXIT(TotalSum);
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • QuilaQuila Member Posts: 4
    Or maybe a little more simple create a function like this:


    GetCurrBalance() : Decimal
    Custledg.COPY(Rec);
    IF Custledg.FIND('-') THEN REPEAT
    Custledg.CALCFIELDS(Amount);
    BalanceAmount := BalanceAmount + Custledg.Amount;
    UNTIL (Custledg."Entry No." = Rec."Entry No.") OR (Custledg.NEXT = 0);
    EXIT(BalanceAmount);

    Which will be functioning independant on sorting, filters etc.

    Kind regards,

    Quila
Sign In or Register to comment.