From 9afc856c20a0ad835562a2f8b2abf11a35c390af Mon Sep 17 00:00:00 2001 From: thetedmunds Date: Mon, 15 Apr 2019 13:16:32 -0700 Subject: [PATCH] Changed gnc:computeInterestIncrement to directly calculate the amount of interest accrued in the specified compounding period. Bug 797195. --- libgnucash/app-utils/fin.scm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libgnucash/app-utils/fin.scm b/libgnucash/app-utils/fin.scm index be56e543fd..a8edf0506c 100644 --- a/libgnucash/app-utils/fin.scm +++ b/libgnucash/app-utils/fin.scm @@ -63,12 +63,9 @@ ;; formula from http://www.riskglossary.com/articles/compounding.htm (* a (expt (+ 1 (/ r n)) (* n t)))) -(define (gnc:computeInterestIncrement amount interest periods i) - (let ((thisVal (gnc:futureValue amount interest periods i)) - (prevVal (gnc:futureValue amount interest periods (- i 1)))) - (- thisVal prevVal) - ) -) +(define (gnc:computeInterestIncrement pv ann-rate compounds period) + (let ((rate (/ ann-rate compounds))) + (* rate (* pv (expt (+ 1 rate) (- period 1)))))) ;;;;; ;; below: not-exposed/"private" functions, used by the "public" functions