Getting Amount Brought Forward.
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.
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?
0
Comments
-
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?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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 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