[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b4ad495a 3/5: Enforce minimum specamt only co
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b4ad495a 3/5: Enforce minimum specamt only conditionally |
Date: |
Fri, 2 Sep 2022 14:23:17 -0400 (EDT) |
branch: master
commit b4ad495a4dd7b9864bf1bce503f446535ed0b948
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Enforce minimum specamt only conditionally
This commit is just a refactoring. Soon this new option will be used.
---
account_value.hpp | 3 ++-
accountvalue.cpp | 10 ++++++----
ihs_acctval.cpp | 2 +-
ihs_avstrtgy.cpp | 9 +++++----
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/account_value.hpp b/account_value.hpp
index 5a212b88..bc49237f 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -209,7 +209,8 @@ class LMI_SO AccountValue final
currency SolveGuarPremium ();
- void PerformSpecAmtStrategy();
+ enum e_specamt_minimum_toggle {enforce_minimum, ignore_minimum};
+ void PerformSpecAmtStrategy(e_specamt_minimum_toggle);
void PerformSupplAmtStrategy();
currency CalculateSpecAmtFromStrategy
(int actual_year
diff --git a/accountvalue.cpp b/accountvalue.cpp
index f6f4aa03..dbe560b5 100644
--- a/accountvalue.cpp
+++ b/accountvalue.cpp
@@ -241,7 +241,7 @@ void AccountValue::RunOneCell(mcenum_run_basis TheBasis)
// designed to allow inforce loans.
AVUnloaned = InforceAVGenAcct;
- PerformSpecAmtStrategy();
+ PerformSpecAmtStrategy(enforce_minimum);
for(Year = InforceYear; Year < BasicValues::GetLength(); ++Year)
{
@@ -430,9 +430,11 @@ inline int AccountValue::MonthsToNextModalPmtDate() const
return months_to_next_modal_pmt[ModeIndex][Month];
}
-//============================================================================
-// Set specamt according to selected strategy, in every year.
-void AccountValue::PerformSpecAmtStrategy()
+/// Set specamt according to selected strategy, in every year.
+///
+/// The argument is ignored because this code knows no minimum.
+
+void AccountValue::PerformSpecAmtStrategy(e_specamt_minimum_toggle)
{
currency SA = C0;
switch(yare_input_.SpecifiedAmountStrategy[0])
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index bd263def..431fcbfc 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -108,7 +108,7 @@ AccountValue::AccountValue(Input const& input)
{
SetInitialValues();
LMI_ASSERT(InforceYear < methuselah);
- PerformSpecAmtStrategy();
+ PerformSpecAmtStrategy(enforce_minimum);
PerformSupplAmtStrategy();
InvariantValues().Init(this);
diff --git a/ihs_avstrtgy.cpp b/ihs_avstrtgy.cpp
index 55427285..a8ffdceb 100644
--- a/ihs_avstrtgy.cpp
+++ b/ihs_avstrtgy.cpp
@@ -107,9 +107,9 @@ currency AccountValue::CalculateSpecAmtFromStrategy
throw "Unreachable--silences a compiler diagnostic.";
}
-/// Set specamt according to selected strategy, respecting minimum.
+/// Set specamt according to a strategy, optionally enforcing minimum.
///
-/// The actual minimum, set elsewhere, is ascertainable only during
+/// The actual minimum, set dynamically, is ascertainable only during
/// monthiversary processing because, e.g., it may depend on whether
/// cash value is sufficient to keep a term rider in force.
///
@@ -118,7 +118,7 @@ currency AccountValue::CalculateSpecAmtFromStrategy
/// input is erroneous; but apply the minimum silently if specamt is
/// to be calculated from a strategy, or if a solve is in progress.
-void AccountValue::PerformSpecAmtStrategy()
+void AccountValue::PerformSpecAmtStrategy(e_specamt_minimum_toggle e)
{
// Store original input specamt for first inforce year, for
// comparison below. Using DeathBfts_->specamt() here instead of
@@ -129,7 +129,8 @@ void AccountValue::PerformSpecAmtStrategy()
for(int j = 0; j < BasicValues::Length; ++j)
{
bool t = yare_input_.TermRider && 0.0 != yare_input_.TermRiderAmount;
- currency m = minimum_specified_amount(0 == j, t);
+ bool const ignore_min {ignore_minimum == e};
+ currency m = ignore_min ? C0 : minimum_specified_amount(0 == j, t);
currency explicit_value = DeathBfts_->specamt()[j];
mcenum_sa_strategy strategy = yare_input_.SpecifiedAmountStrategy[j];
// Don't override a specamt that's being solved for.