[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);
- [lmi-commits] [lmi] master updated (fa7b681 -> e0ea157), Greg Chicares, 2021/01/27
- [lmi-commits] [lmi] master 0e44701 3/7: Rework maximum-loan calculation,
Greg Chicares <=
- [lmi-commits] [lmi] master 53165eb 4/7: Reorder independent statements for clarity, Greg Chicares, 2021/01/27
- [lmi-commits] [lmi] master 2fcea50 1/7: Resolve gratuitous differences from valyuta/005, Greg Chicares, 2021/01/27
- [lmi-commits] [lmi] master e0ea157 7/7: Switch to currency class, Greg Chicares, 2021/01/27
- [lmi-commits] [lmi] master 6c85726 2/7: Reformat, Greg Chicares, 2021/01/27
- [lmi-commits] [lmi] master f9b937f 5/7: Round increments and decrements better, Greg Chicares, 2021/01/27
- [lmi-commits] [lmi] master 8c0f4d8 6/7: Record speed measurements, Greg Chicares, 2021/01/27