lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 039093e: Round values in class death_benefits


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 039093e: Round values in class death_benefits
Date: Mon, 24 Aug 2020 16:43:24 -0400 (EDT)

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

    Round values in class death_benefits
    
    Incidentally made this class's ctor 'explicit', merely to follow the
    practice already used in the parallel class modal_outlay. There's no
    special reason for either of these classes' multiple-argument ctors
    to be 'explicit' or not.
---
 basicvalues.cpp    |  2 +-
 death_benefits.cpp | 17 ++++++++++++-----
 death_benefits.hpp | 10 +++++++++-
 ihs_basicval.cpp   |  4 ++--
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/basicvalues.cpp b/basicvalues.cpp
index 6273d6f..9eddf08 100644
--- a/basicvalues.cpp
+++ b/basicvalues.cpp
@@ -113,7 +113,7 @@ void BasicValues::Init()
     // Multilife contracts will need a vector of mortality-rate objects.
     MortalityRates_.reset(new MortalityRates (*this));
     InterestRates_ .reset(new InterestRates  (*this));
-    DeathBfts_     .reset(new death_benefits (GetLength(), yare_input_));
+    DeathBfts_     .reset(new death_benefits (GetLength(), yare_input_, 
round_specamt_));
     Outlay_        .reset(new modal_outlay   (yare_input_, 
round_gross_premium_, round_withdrawal_, round_loan_));
     PremiumTax_    .reset(new premium_tax    (PremiumTaxState_, database()));
     Loads_         .reset(new Loads(database(), IsSubjectToIllustrationReg()));
diff --git a/death_benefits.cpp b/death_benefits.cpp
index 55d9bdb..08bfa31 100644
--- a/death_benefits.cpp
+++ b/death_benefits.cpp
@@ -29,8 +29,13 @@
 #include <algorithm>                    // min()
 
 //============================================================================
-death_benefits::death_benefits(int length, yare_input const& yi)
-    :length_ {length}
+death_benefits::death_benefits
+    (int                     length
+    ,yare_input       const& yi
+    ,round_to<double> const& round_specamt
+    )
+    :length_        {length}
+    ,round_specamt_ {round_specamt}
 {
     // In the antediluvian branch, the vector in the input class
     // is padded to a greater length.
@@ -44,9 +49,9 @@ death_benefits::death_benefits(int length, yare_input const& 
yi)
     supplamt_.resize(length_);
     for(int j = 0; j < length_; ++j)
         {
-        dbopt_   [j] = yi.DeathBenefitOption[j];
-        specamt_ [j] = yi.SpecifiedAmount   [j];
-        supplamt_[j] = yi.SupplementalAmount[j];
+        dbopt_   [j] =                yi.DeathBenefitOption[j];
+        specamt_ [j] = round_specamt_(yi.SpecifiedAmount   [j]);
+        supplamt_[j] = round_specamt_(yi.SupplementalAmount[j]);
         }
 }
 
@@ -62,6 +67,7 @@ void death_benefits::set_specamt(double z, int from_year, int 
to_year)
     LMI_ASSERT(                  to_year < length_);
     std::fill_n(specamt_.begin() + from_year, to_year - from_year, z);
 #endif // 0
+    z = round_specamt_(z);
     for(int j = from_year; j < std::min(length_, to_year); ++j)
         {
         specamt_[j] = z;
@@ -80,6 +86,7 @@ void death_benefits::set_supplamt(double z, int from_year, 
int to_year)
     LMI_ASSERT(                  to_year < length_);
     std::fill_n(supplamt_.begin() + from_year, to_year - from_year, z);
 #endif // 0
+    z = round_specamt_(z);
     for(int j = from_year; j < std::min(length_, to_year); ++j)
         {
         supplamt_[j] = z;
diff --git a/death_benefits.hpp b/death_benefits.hpp
index 06a3fda..46fbeb8 100644
--- a/death_benefits.hpp
+++ b/death_benefits.hpp
@@ -25,6 +25,7 @@
 #include "config.hpp"
 
 #include "mc_enum_type_enums.hpp"
+#include "round_to.hpp"
 
 #include <vector>
 
@@ -33,7 +34,11 @@ class yare_input;
 class death_benefits final
 {
   public:
-    death_benefits(int, yare_input const&);
+    explicit death_benefits
+        (int                     length
+        ,yare_input       const&
+        ,round_to<double> const& round_specamt
+        );
     ~death_benefits() = default;
 
     void set_specamt (double z, int from_year, int to_year);
@@ -48,6 +53,9 @@ class death_benefits final
     death_benefits& operator=(death_benefits const&) = delete;
 
     int length_;
+
+    round_to<double> round_specamt_;
+
     std::vector<mcenum_dbopt> dbopt_   ;
     std::vector<double>       specamt_ ;
     std::vector<double>       supplamt_;
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index c6ff672..d71385c 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -227,7 +227,7 @@ void BasicValues::Init()
     // Interest rates require tiered data and 7702 spread.
     MortalityRates_.reset(new MortalityRates (*this));
     InterestRates_ .reset(new InterestRates  (*this));
-    DeathBfts_     .reset(new death_benefits (GetLength(), yare_input_));
+    DeathBfts_     .reset(new death_benefits (GetLength(), yare_input_, 
round_specamt_));
     // Outlay requires only input and rounding; it might someday use
     // interest rates.
     Outlay_        .reset(new modal_outlay   (yare_input_, 
round_gross_premium_, round_withdrawal_, round_loan_));
@@ -315,7 +315,7 @@ void BasicValues::GPTServerInit()
     // Requires database.
     MortalityRates_.reset(new MortalityRates (*this)); // Used by certain 
target-premium calculations.
 //  InterestRates_ .reset(new InterestRates  (*this));
-//  DeathBfts_     .reset(new death_benefits (GetLength(), yare_input_));
+//  DeathBfts_     .reset(new death_benefits (GetLength(), yare_input_, 
round_specamt_));
     // Outlay requires only input and rounding; it might someday use
     // interest rates.
 //  Outlay_        .reset(new modal_outlay   (yare_input_, 
round_gross_premium_, round_withdrawal_, round_loan_));



reply via email to

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