lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 7b51fab 07/15: Adapt to currency class


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 7b51fab 07/15: Adapt to currency class
Date: Mon, 25 Jan 2021 09:58:05 -0500 (EST)

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

    Adapt to currency class
    
    For objects of currency type:
     - write zero as "C0"
     - round with round_to<>.c()
     - convert to double with dblize() where needed
---
 death_benefits.cpp        | 10 +++++-----
 group_values.cpp          |  3 ++-
 ledger_invariant_init.cpp | 13 +++++++------
 ledger_variant_init.cpp   |  2 +-
 outlay.cpp                | 32 ++++++++++++++++----------------
 5 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/death_benefits.cpp b/death_benefits.cpp
index 89c90aa..52259d2 100644
--- a/death_benefits.cpp
+++ b/death_benefits.cpp
@@ -49,9 +49,9 @@ death_benefits::death_benefits
     supplamt_.resize(length_);
     for(int j = 0; j < length_; ++j)
         {
-        dbopt_   [j] =                yi.DeathBenefitOption[j];
-        specamt_ [j] = round_specamt_(yi.SpecifiedAmount   [j]);
-        supplamt_[j] = round_specamt_(yi.SupplementalAmount[j]);
+        dbopt_   [j] =                  yi.DeathBenefitOption[j];
+        specamt_ [j] = round_specamt_.c(yi.SpecifiedAmount   [j]);
+        supplamt_[j] = round_specamt_.c(yi.SupplementalAmount[j]);
         }
 }
 
@@ -67,7 +67,7 @@ void death_benefits::set_specamt(currency 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);
+    z = round_specamt_.c(z);
     for(int j = from_year; j < std::min(length_, to_year); ++j)
         {
         specamt_[j] = z;
@@ -86,7 +86,7 @@ void death_benefits::set_supplamt(currency 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);
+    z = round_specamt_.c(z);
     for(int j = from_year; j < std::min(length_, to_year); ++j)
         {
         supplamt_[j] = z;
diff --git a/group_values.cpp b/group_values.cpp
index 1ae231b..739b6d2 100644
--- a/group_values.cpp
+++ b/group_values.cpp
@@ -28,6 +28,7 @@
 #include "assert_lmi.hpp"
 #include "configurable_settings.hpp"
 #include "contains.hpp"
+#include "currency.hpp"
 #include "emit_ledger.hpp"
 #include "fenv_guard.hpp"
 #include "input.hpp"
@@ -418,7 +419,7 @@ census_run_result run_census_in_parallel::operator()
                     ;
             for(int month = inforce_month; month < 12; ++month)
                 {
-                double assets = 0.0;
+                currency assets = C0;
 
                 // Get total case assets prior to interest crediting because
                 // those assets may determine the M&E charge.
diff --git a/ledger_invariant_init.cpp b/ledger_invariant_init.cpp
index 2b1364f..922c488 100644
--- a/ledger_invariant_init.cpp
+++ b/ledger_invariant_init.cpp
@@ -27,6 +27,7 @@
 #include "assert_lmi.hpp"
 #include "basic_values.hpp"
 #include "contains.hpp"
+#include "currency.hpp"
 #include "database.hpp"
 #include "dbnames.hpp"
 #include "death_benefits.hpp"
@@ -107,7 +108,7 @@ void LedgerInvariant::Init(BasicValues const* b)
         }
     else if(b->database().query<bool>(DB_TermIsNotRider))
         {
-        TermSpecAmt            = b->DeathBfts_->supplamt();
+        TermSpecAmt            = dblize(b->DeathBfts_->supplamt());
         if(!each_equal(TermSpecAmt, 0.0))
             {
             HasSupplSpecAmt    = true;
@@ -117,7 +118,7 @@ void LedgerInvariant::Init(BasicValues const* b)
         {
         TermSpecAmt            .assign(Length, 0.0);
         }
-    SpecAmt                    = b->DeathBfts_->specamt();
+    SpecAmt                    = dblize(b->DeathBfts_->specamt());
 
     // Forborne vectors.
 
@@ -146,7 +147,7 @@ void LedgerInvariant::Init(BasicValues const* b)
     // Scalable scalars.
 
     // SOMEDAY !! Things indexed with '[0]' should probably use inforce year 
instead.
-    InitBaseSpecAmt            = b->DeathBfts_->specamt()[0];
+    InitBaseSpecAmt            = dblize(b->DeathBfts_->specamt()[0]);
     InitTermSpecAmt            = TermSpecAmt[0];
     ChildRiderAmount           = b->yare_input_.ChildRiderAmount;
     SpouseRiderAmount          = b->yare_input_.SpouseRiderAmount;
@@ -725,7 +726,7 @@ void LedgerInvariant::ReInit(BasicValues const* b)
         }
     else if(b->database().query<bool>(DB_TermIsNotRider))
         {
-        TermSpecAmt            = b->DeathBfts_->supplamt();
+        TermSpecAmt            = dblize(b->DeathBfts_->supplamt());
         if(!each_equal(TermSpecAmt, 0.0))
             {
             HasSupplSpecAmt    = true;
@@ -735,9 +736,9 @@ void LedgerInvariant::ReInit(BasicValues const* b)
         {
         TermSpecAmt            .assign(Length, 0.0);
         }
-    SpecAmt                    = b->DeathBfts_->specamt();
+    SpecAmt                    = dblize(b->DeathBfts_->specamt());
 
-    InitBaseSpecAmt            = b->DeathBfts_->specamt()[0];
+    InitBaseSpecAmt            = dblize(b->DeathBfts_->specamt()[0]);
     InitTermSpecAmt            = TermSpecAmt[0];
 
     IsMec                      = false;
diff --git a/ledger_variant_init.cpp b/ledger_variant_init.cpp
index 21a83fc..9114690 100644
--- a/ledger_variant_init.cpp
+++ b/ledger_variant_init.cpp
@@ -112,7 +112,7 @@ void LedgerVariant::Init
         ;
 
     InitTgtPremHiLoadRate = 
bv.Loads_->target_premium_load_maximum_premium_tax()[bv.yare_input_.InforceYear];
-    InitMlyPolFee         = bv.Loads_->monthly_policy_fee(GenBasis_)           
 [bv.yare_input_.InforceYear];
+    InitMlyPolFee         = dblize(bv.Loads_->monthly_policy_fee(GenBasis_)    
 [bv.yare_input_.InforceYear]);
 
     FullyInitialized = true;
 }
diff --git a/outlay.cpp b/outlay.cpp
index 540cc8d..cbd9018 100644
--- a/outlay.cpp
+++ b/outlay.cpp
@@ -37,54 +37,54 @@ modal_outlay::modal_outlay
     :round_gross_premium_  {round_gross_premium}
     ,round_withdrawal_     {round_withdrawal   }
     ,round_loan_           {round_loan         }
-    ,dumpin_               {round_gross_premium_(yi.Dumpin)                    
}
-    ,external_1035_amount_ 
{round_gross_premium_(yi.External1035ExchangeAmount)}
-    ,internal_1035_amount_ 
{round_gross_premium_(yi.Internal1035ExchangeAmount)}
-    ,ee_modal_premiums_    {round_gross_premium_(yi.Payment)                   
}
-    ,ee_premium_modes_     {                     yi.PaymentMode                
}
-    ,er_modal_premiums_    {round_gross_premium_(yi.CorporationPayment)        
}
-    ,er_premium_modes_     {                     yi.CorporationPaymentMode     
}
-    ,withdrawals_          {round_withdrawal_   (yi.Withdrawal)                
}
-    ,new_cash_loans_       {round_loan_         (yi.NewLoan)                   
}
+    ,dumpin_               {round_gross_premium_.c(yi.Dumpin)                  
  }
+    ,external_1035_amount_ 
{round_gross_premium_.c(yi.External1035ExchangeAmount)}
+    ,internal_1035_amount_ 
{round_gross_premium_.c(yi.Internal1035ExchangeAmount)}
+    ,ee_modal_premiums_    {round_gross_premium_.c(yi.Payment)                 
  }
+    ,ee_premium_modes_     {                       yi.PaymentMode              
  }
+    ,er_modal_premiums_    {round_gross_premium_.c(yi.CorporationPayment)      
  }
+    ,er_premium_modes_     {                       yi.CorporationPaymentMode   
  }
+    ,withdrawals_          {round_withdrawal_   .c(yi.Withdrawal)              
  }
+    ,new_cash_loans_       {round_loan_         .c(yi.NewLoan)                 
  }
 {
 }
 
 void modal_outlay::set_external_1035_amount(currency z)
 {
-    external_1035_amount_ = round_gross_premium_(z);
+    external_1035_amount_ = round_gross_premium_.c(z);
 }
 
 void modal_outlay::set_internal_1035_amount(currency z)
 {
-    internal_1035_amount_ = round_gross_premium_(z);
+    internal_1035_amount_ = round_gross_premium_.c(z);
 }
 
 void modal_outlay::set_ee_modal_premiums(currency z, int from_year, int 
to_year)
 {
-    z = round_gross_premium_(z);
+    z = round_gross_premium_.c(z);
     std::fill_n(ee_modal_premiums_.begin() + from_year, to_year - from_year, 
z);
 }
 
 void modal_outlay::set_er_modal_premiums(currency z, int from_year, int 
to_year)
 {
-    z = round_gross_premium_(z);
+    z = round_gross_premium_.c(z);
     std::fill_n(er_modal_premiums_.begin() + from_year, to_year - from_year, 
z);
 }
 
 void modal_outlay::set_er_modal_premiums(std::vector<currency> const& z)
 {
     LMI_ASSERT(z.size() == er_modal_premiums_.size());
-    er_modal_premiums_ = round_gross_premium_(z);
+    er_modal_premiums_ = round_gross_premium_.c(z);
 }
 
 void modal_outlay::set_withdrawals(currency z, int from_year, int to_year)
 {
-    z = round_withdrawal_(z);
+    z = round_withdrawal_.c(z);
     std::fill_n(withdrawals_.begin() + from_year, to_year - from_year, z);
 }
 
 void modal_outlay::set_new_cash_loans(currency z, int from_year, int to_year)
 {
-    z = round_loan_(z);
+    z = round_loan_.c(z);
     std::fill_n(new_cash_loans_.begin() + from_year, to_year - from_year, z);
 }



reply via email to

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