Getting Amount Brought Forward.

zulq
zulq Member Posts: 204
Trying to build a report which calculates accumulated/compound interest for our company but having problems.
Row 1:

PeriodStart PeriodEnd CurrentContribution Type Rate Int.Credit Closing Bal.
01/01/07 28/02/07 1517.15 A 0.32 40.46 1557.61

Row 2:
PeriodStart PeriodEnd CurrentContribution Type Rate Int.Credit Closing Bal.
01/03/07 31/05/07 3030.00 B 0.16 60 3090.60



Now I want to pick the Closing Balance of Row 1 and calculate its interest for the second row as it should be carried forward.
Any ideas how I can do this please....?

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?

Comments

  • zulq
    zulq Member Posts: 204
    By the by I have being able to get the previous record I want. This is how I do it: created an "Entry No." in the table as integer and auto-increment and use the code below:

    EntryNo := "Entry No." -1;
    BenefitsKey.SETRANGE("Entry No.",EntryNo);
    BenefitsKey.SETRANGE("Employee #",Cont."Employee No.");


    IF BenefitsKey.FIND('-')
    THEN BEGIN
    OpeningBalance := BenefitsKey.ClosingBalance;
    END;

    Its working perfect and calculating properly. The only problem I have now is the automated calculation only works On Modify Trigger and not after validating the last insert field.
    Below is the whole code for reference:

    Cont.SETRANGE("Employee No.","Employee #");
    Cont.SETRANGE("From Date","Period Start","Period End");
    Cont.SETFILTER("From Date",'>=%1',"Period Start");
    Cont.SETFILTER("To Date",'<=%1',"Period End");

    //Code to Count Months
    IF ("Period Start" <> 0D) AND ("Period End" > "Period Start") THEN BEGIN
    Calendar.RESET;
    Calendar.SETRANGE("Period Type",Calendar."Period Type"::Month);
    Calendar.SETRANGE("Period Start","Period Start","Period End");
    Months := Calendar.COUNT;
    END ELSE
    Months := 0;
    // Code Ends above.

    IF Cont.FIND('-')
    THEN BEGIN
    TotalAmount := Cont.Quantity;
    IF Cont.NEXT <> 0
    THEN
    REPEAT
    TotalAmount := TotalAmount + Cont.Quantity;
    UNTIL Cont.NEXT = 0;
    END;

    IntCredit := (TotalAmount * Rate * Months)/24;
    CurrAccTotal := IntCredit + TotalAmount;


    EntryNo := "Entry No." -1;
    BenefitsKey.SETRANGE("Entry No.",EntryNo);
    BenefitsKey.SETRANGE("Employee #",Cont."Employee No.");

    IF BenefitsKey.FIND('-')
    THEN BEGIN
    OpeningBalance := BenefitsKey.ClosingBalance;
    END;

    OpIntCredit := OpeningBalance * Rate;
    ClosingBalance := OpIntCredit + OpeningBalance + CurrAccTotal;


    Any ideas welcome Please!
    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?