[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/005 f9d4d68 3/4: Remove gratuitous incompati
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/005 f9d4d68 3/4: Remove gratuitous incompatibilities with master |
Date: |
Fri, 29 Jan 2021 17:08:08 -0500 (EST) |
branch: valyuta/005
commit f9d4d6854dd0e799cc1803cc9fce83675f10e44c
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Remove gratuitous incompatibilities with master
---
ihs_avmly.cpp | 8 ++++++--
ihs_avstrtgy.cpp | 4 ----
ihs_basicval.cpp | 17 +++++++----------
verify_products.cpp | 4 +---
4 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 76de49f..fdc307a 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -724,7 +724,11 @@ currency AccountValue::minimum_specified_amount(bool
issuing_now, bool term_ride
// Make sure ActualSpecAmt is never less than minimum specamt.
void AccountValue::ChangeSpecAmtBy(currency delta)
{
- delta = round_specamt().c(delta); // CURRENCY !! already rounded?
+ // The argument is already currency, but it might not be rounded
+ // in the right way--e.g., if a withdrawal of twenty cents is
+ // taken, rounding rules might require specamt to decrease by
+ // one full dollar.
+ delta = round_specamt().c(delta);
double term_proportion = 0.0;
currency const old_total_specamt = ActualSpecAmt + TermSpecAmt;
// Adjust term here only if it's formally a rider.
@@ -816,7 +820,7 @@ void AccountValue::ChangeSpecAmtBy(currency delta)
void AccountValue::ChangeSupplAmtBy(currency delta)
{
- delta = round_specamt().c(delta); // CURRENCY !! already rounded?
+ delta = round_specamt().c(delta);
TermSpecAmt += delta;
// No minimum other than zero is defined.
diff --git a/ihs_avstrtgy.cpp b/ihs_avstrtgy.cpp
index df754f1..83a445f 100644
--- a/ihs_avstrtgy.cpp
+++ b/ihs_avstrtgy.cpp
@@ -145,8 +145,6 @@ void AccountValue::PerformSpecAmtStrategy()
strategy = mce_sa_input_scalar;
}
currency z = CalculateSpecAmtFromStrategy(j, 0, explicit_value,
strategy);
- // This should have been rounded upstream. It would be nice to
- // devise a good way to assert that it was.
DeathBfts_->set_specamt(std::max(m, z), j, 1 + j);
if
( j == InforceYear
@@ -178,8 +176,6 @@ void AccountValue::PerformSupplAmtStrategy()
currency explicit_value = DeathBfts_->supplamt()[j];
mcenum_sa_strategy strategy =
yare_input_.SupplementalAmountStrategy[j];
currency z = CalculateSpecAmtFromStrategy(j, 0, explicit_value,
strategy);
- // This should have been rounded upstream. It would be nice to
- // devise a good way to assert that it was.
DeathBfts_->set_supplamt(std::max(m, z), j, 1 + j);
}
}
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index ef8b00a..d039a28 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -166,7 +166,6 @@ BasicValues::BasicValues
//============================================================================
void BasicValues::Init()
{
- // This wants to be refactored:
lingo_ = lingo::read_via_cache
(AddDataDir(product().datum("LingoFilename")));
FundData_ = FundData::read_via_cache
@@ -1409,7 +1408,7 @@ currency BasicValues::GetModalSpecAmtMax(currency
annualized_pmt) const
case oe_modal_nonmec:
return GetModalSpecAmtMinNonMec(annualized_pmt);
case oe_modal_table:
- return round_min_specamt().c
+ return round_specamt().c
(
annualized_pmt
/ MortalityRates_->MinimumPremiumRates()[0]
@@ -1433,7 +1432,7 @@ currency BasicValues::GetModalSpecAmtTgt(currency
annualized_pmt) const
case oe_modal_nonmec:
return GetModalSpecAmtMinNonMec(annualized_pmt);
case oe_modal_table:
- return round_min_specamt().c
+ return round_specamt().c
(
(annualized_pmt - TgtPremMonthlyPolFee * 12)
/ MortalityRates_->TargetPremiumRates()[0]
@@ -1497,12 +1496,10 @@ currency BasicValues::GetModalSpecAmtGSP(currency
annualized_pmt) const
/// typical practice) and rounded to integer to recapture the intended
/// value.
///
-/// Of course, lmi would allow a table of corridor factors to have,
-/// say, seven decimal digits, so rounding might give an undesired
-/// answer even with a payment that exceeds the above example's 10^5
-/// by a factor of one plus epsilon. Until such amounts are stored as
-/// integral cents, this implementation cannot guarantee to give the
-/// desired answer in every case.
+/// This cannot be implemented as a single call to round_to() because
+/// it rounds twice: once to convert a floating-point corridor factor
+/// to an exact integer (4.9 --> 490 in the example above), and again
+/// after multiplying that integral factor by premium.
currency BasicValues::GetModalSpecAmtCorridor(currency annualized_pmt) const
{
@@ -1531,7 +1528,7 @@ currency BasicValues::GetModalSpecAmtSalary(int a_year)
const
z = std::min(z, yare_input_.SalarySpecifiedAmountCap);
}
z -= yare_input_.SalarySpecifiedAmountOffset;
- return round_min_specamt().c(std::max(0.0, z));
+ return round_specamt().c(std::max(0.0, z));
}
/// In general, strategies linking specamt and premium commute. The
diff --git a/verify_products.cpp b/verify_products.cpp
index 7417748..4751114 100644
--- a/verify_products.cpp
+++ b/verify_products.cpp
@@ -55,7 +55,7 @@ class product_verifier
std::string const product_name_;
std::string const gender_str_ ;
std::string const smoking_str_ ;
- product_data const& p_ ; // or just std::shared_ptr?
+ product_data const& p_ ;
mcenum_gender const gender_ ;
mcenum_smoking const smoking_ ;
product_database const db0_ ;
@@ -80,7 +80,6 @@ product_verifier::product_verifier
,p_
(*product_data::read_via_cache(filename_from_product_name(product_name)))
,gender_ {mce_gender (gender_str ).value()}
,smoking_ {mce_smoking(smoking_str).value()}
- // CURRENCY !! [not really currency] consider caching this
,db0_
(product_name
,gender_
@@ -91,7 +90,6 @@ product_verifier::product_verifier
,mce_s_XX
)
,min_age_ {db0_.query<int>(DB_MinIssAge)}
- // CURRENCY !! [not really currency] consider caching this
,db_
(product_name
,gender_