[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 061fa21 3/3: Round {ee, er}-apportioned net p
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 061fa21 3/3: Round {ee, er}-apportioned net premium, preserving their total |
Date: |
Tue, 25 Aug 2020 19:18:01 -0400 (EDT) |
branch: master
commit 061fa216bf330b3314f7e1639fab6a5617db2961
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Round {ee,er}-apportioned net premium, preserving their total
---
ihs_avmly.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 6869c47..d91f358 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -284,7 +284,17 @@ void AccountValue::process_payment(double payment)
{
er_proportion = ErGrossPmts[Month] / gross_non_1035_pmts;
}
- double er_net_pmt = er_proportion * payment;
+
+ // This is a net premium that's multiplied by a gross-premium
+ // proportion, because that's the only way the proportion can be
+ // deduced from input. But it remains a net premium, so the
+ // net-premium rounding rule is appropriate.
+ double er_net_pmt = round_net_premium()(er_proportion * payment);
+ // This is deliberately not rounded. The crucial invariant that
+ // must be preserved is that ee + er = total; but rounding both
+ // addends could break that invariant, e.g.:
+ // round(2.5) + round(2.5)
+ // might not produce 5.0 as desired.
double ee_net_pmt = payment - er_net_pmt;
switch(ee_premium_allocation_method)