lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 0e44701 3/7: Rework maximum-loan calculation


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 0e44701 3/7: Rework maximum-loan calculation
Date: Wed, 27 Jan 2021 20:57:45 -0500 (EST)

branch: master
commit 0e447015cd7737b649aa786e5cea5870f5af0c82
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Rework maximum-loan calculation
    
    Reworked AccountValue::SetMaxLoan(), starting from the last version
    released into production, along the lines of valyuta/005 . The crucial
    difference is whether a maximum-loan formula in product specifications
    is to be interpreted as currency or floating-point arithmetic: changed
    from the former (recently implemented) to the latter (as in the past).
    Thus, intermediate components were recently treated as subject to
    separate rounding at each step, but now (once again) rounding is
    performed only at the last step, because that seems to be the better
    reading of the specifications.
    
    The behavior, in this respect only, should match SHA1 74077f91ce97 of
    20210126T2046Z (and of valyuta/005).
---
 ihs_avmly.cpp | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index a11a680..f4cec58 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -2672,11 +2672,13 @@ void AccountValue::TxTakeWD()
 // Calculate maximum permissible total loan (not increment).
 void AccountValue::SetMaxLoan()
 {
-    MaxLoan =
-          round_loan().c((AVGenAcct + AVSepAcct) * MaxLoanAVMult)
-        + (AVRegLn + AVPrfLn)
-        - anticipated_deduction(MaxLoanDed_)
-        - std::max(C0, SurrChg())
+    double max_loan =
+          (AVGenAcct + AVSepAcct) * MaxLoanAVMult
+        + dblize
+            ( (AVRegLn + AVPrfLn)
+            - anticipated_deduction(MaxLoanDed_)
+            - std::max(C0, SurrChg())
+            )
         ;
 
     // Illustrations generally permit loans only on anniversary.
@@ -2711,19 +2713,19 @@ void AccountValue::SetMaxLoan()
     // the end of the policy year--but does not guarantee that, e.g.
     // because the specified amount may change between anniversaries,
     // even on illustrations.
-    MaxLoan -= round_loan().c
-        (
+    max_loan -=
           RegLnBal * reg_loan_factor
         + PrfLnBal * prf_loan_factor
-        );
+        ;
 
     // TODO ?? This adjustment isn't quite right because it uses only
     // the regular-loan interest factor. Is it conservative under the
     // plausible but unasserted assumption that that factor is more
     // liberal than the preferred-loan factor?
     //
-    double adj = 1.0 - (reg_loan_factor) / (1.0 + reg_loan_factor);
-    MaxLoan = round_loan().c(MaxLoan * adj);
+    max_loan *= 1.0 - (reg_loan_factor) / (1.0 + reg_loan_factor);
+
+    MaxLoan = round_loan().c(max_loan);
 
     // I do not think we want a MaxLoan < current level of indebtedness.
     MaxLoan = std::max((AVRegLn + AVPrfLn), MaxLoan);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]