[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/002 ef7fe2f 01/65: Change type of currency v
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/002 ef7fe2f 01/65: Change type of currency variables to 'currency' in headers |
Date: |
Wed, 16 Sep 2020 16:55:10 -0400 (EDT) |
branch: valyuta/002
commit ef7fe2fc320b307e58d77be6723b41715bce891d
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Change type of currency variables to 'currency' in headers
Changed datatype to 'currency' for all values that naturally must hold
amounts in integral cents. Some choices may seem arbitrary: e.g. rider
charges are currency because they're rounded separately, but components
of premium load are not because there exist products that calculate the
total load as
round(base * Σrates)
, rounding on the final step only.
'currency' is still typedef'd as double, so this has no effect, yet.
---
account_value.hpp | 469 +++++++++++++++++++++++++++--------------------------
basic_values.hpp | 121 +++++++-------
death_benefits.hpp | 17 +-
gpt_specamt.hpp | 13 +-
outlay.hpp | 57 +++----
5 files changed, 341 insertions(+), 336 deletions(-)
diff --git a/account_value.hpp b/account_value.hpp
index 7bb7b52..a88502b 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -25,6 +25,7 @@
#include "config.hpp"
#include "basic_values.hpp"
+#include "currency.hpp"
#include "oecumenic_enumerations.hpp"
#include "so_attributes.hpp"
@@ -50,7 +51,7 @@ class LMI_SO AccountValue final
{
friend class SolveHelper;
friend class run_census_in_parallel;
- friend double SolveTest();
+ friend currency SolveTest(); // Antediluvian.
public:
enum {months_per_year = 12};
@@ -59,34 +60,34 @@ class LMI_SO AccountValue final
AccountValue(AccountValue&&) = default;
~AccountValue() override = default;
- double RunAV ();
+ currency RunAV();
void SetDebugFilename (std::string const&);
void SolveSetPmts // Antediluvian.
- (double a_Pmt
- ,int ThatSolveBegYear
- ,int ThatSolveEndYear
+ (currency a_Pmt
+ ,int ThatSolveBegYear
+ ,int ThatSolveEndYear
);
void SolveSetSpecAmt // Antediluvian.
- (double a_Bft
- ,int ThatSolveBegYear
- ,int ThatSolveEndYear
+ (currency a_Bft
+ ,int ThatSolveBegYear
+ ,int ThatSolveEndYear
);
void SolveSetLoans // Antediluvian.
- (double a_Loan
- ,int ThatSolveBegYear
- ,int ThatSolveEndYear
+ (currency a_Loan
+ ,int ThatSolveBegYear
+ ,int ThatSolveEndYear
);
void SolveSetWDs // Antediluvian.
- (double a_WD
- ,int ThatSolveBegYear
- ,int ThatSolveEndYear
+ (currency a_WD
+ ,int ThatSolveBegYear
+ ,int ThatSolveEndYear
);
void SolveSetLoanThenWD // Antediluvian.
- (double a_Amt
- ,int ThatSolveBegYear
- ,int ThatSolveEndYear
+ (currency a_Amt
+ ,int ThatSolveBegYear
+ ,int ThatSolveEndYear
);
std::shared_ptr<Ledger const> ledger_from_av() const;
@@ -104,21 +105,21 @@ class LMI_SO AccountValue final
double InforceLivesEoy () const;
double GetSepAcctAssetsInforce () const;
- void process_payment (double);
- void IncrementAVProportionally(double);
- void IncrementAVPreferentially(double, oenum_increment_account_preference);
- void process_deduction (double);
- void process_distribution (double);
- void DecrementAVProportionally(double);
- void DecrementAVProgressively (double, oenum_increment_account_preference);
+ void process_payment (currency);
+ void IncrementAVProportionally(currency);
+ void IncrementAVPreferentially(currency,
oenum_increment_account_preference);
+ void process_deduction (currency);
+ void process_distribution (currency);
+ void DecrementAVProportionally(currency);
+ void DecrementAVProgressively (currency,
oenum_increment_account_preference);
- double TotalAccountValue() const;
- double CashValueFor7702() const;
+ currency TotalAccountValue() const;
+ currency CashValueFor7702() const;
- double base_specamt(int year) const;
- double term_specamt(int year) const;
- double specamt_for_7702(int year) const;
- double specamt_for_7702A(int year) const;
+ currency base_specamt(int year) const;
+ currency term_specamt(int year) const;
+ currency specamt_for_7702(int year) const;
+ currency specamt_for_7702A(int year) const;
// We're not yet entirely sure how to handle ledger values. Right now,
// we have pointers to a Ledger and also to its variant and invariant
@@ -130,9 +131,9 @@ class LMI_SO AccountValue final
LedgerInvariant& InvariantValues();
LedgerVariant & VariantValues ();
- double RunOneCell (mcenum_run_basis);
- double RunOneBasis (mcenum_run_basis);
- double RunAllApplicableBases ();
+ currency RunOneCell (mcenum_run_basis);
+ currency RunOneBasis (mcenum_run_basis);
+ currency RunAllApplicableBases ();
void InitializeLife (mcenum_run_basis);
void FinalizeLife (mcenum_run_basis);
void FinalizeLifeAllBases ();
@@ -152,11 +153,11 @@ class LMI_SO AccountValue final
,int a_InforceMonth = 0
);
- void SolveSetSpecAmt (double a_CandidateValue);
- void SolveSetEePrem (double a_CandidateValue);
- void SolveSetErPrem (double a_CandidateValue);
- void SolveSetLoan (double a_CandidateValue);
- void SolveSetWD (double a_CandidateValue);
+ void SolveSetSpecAmt (currency a_CandidateValue);
+ void SolveSetEePrem (currency a_CandidateValue);
+ void SolveSetErPrem (currency a_CandidateValue);
+ void SolveSetLoan (currency a_CandidateValue);
+ void SolveSetWD (currency a_CandidateValue);
void DebugPrint ();
@@ -177,57 +178,57 @@ class LMI_SO AccountValue final
// to the point where interest is credited.
// Process monthly transactions up to but excluding interest credit
- double IncrementBOM
+ currency IncrementBOM
(int year
,int month
,double a_case_k_factor
);
// Credit interest and process all subsequent monthly transactions
void IncrementEOM
- (int year
- ,int month
- ,double assets_post_bom
- ,double cum_pmts_post_bom
+ (int year
+ ,int month
+ ,currency assets_post_bom
+ ,currency cum_pmts_post_bom
);
void IncrementEOY(int year);
bool PrecedesInforceDuration(int year, int month);
- double Solve(); // Antediluvian.
- double Solve
+ currency Solve(); // Antediluvian.
+ currency Solve
(mcenum_solve_type a_SolveType
,int a_SolveBeginYear
,int a_SolveEndYear
,mcenum_solve_target a_SolveTarget
- ,double a_SolveTargetCsv
+ ,currency a_SolveTargetCsv
,int a_SolveTargetYear
,mcenum_gen_basis a_SolveGenBasis
,mcenum_sep_basis a_SolveSepBasis
);
- double SolveTest (double a_CandidateValue);
+ currency SolveTest (currency a_CandidateValue);
- double SolveGuarPremium ();
+ currency SolveGuarPremium ();
void PerformSpecAmtStrategy();
void PerformSupplAmtStrategy();
- double CalculateSpecAmtFromStrategy
+ currency CalculateSpecAmtFromStrategy
(int actual_year
,int reference_year
- ,double explicit_value
+ ,currency explicit_value
,mcenum_sa_strategy strategy
) const;
- void PerformPmtStrategy(double* a_Pmt); // Antediluvian.
- double PerformEePmtStrategy () const;
- double PerformErPmtStrategy () const;
- double DoPerformPmtStrategy
+ void PerformPmtStrategy(currency* a_Pmt); // Antediluvian.
+ currency PerformEePmtStrategy () const;
+ currency PerformErPmtStrategy () const;
+ currency DoPerformPmtStrategy
(mcenum_solve_type a_SolveForWhichPrem
,mcenum_mode a_CurrentMode
,mcenum_mode a_InitialMode
,double a_TblMult
- ,std::vector<double> const& a_PmtVector
+ ,std::vector<currency> const& a_PmtVector
,std::vector<mcenum_pmt_strategy> const& a_StrategyVector
) const;
@@ -240,13 +241,13 @@ class LMI_SO AccountValue final
void TxAscertainDesiredPayment ();
void TxLimitPayment (double a_maxpmt);
void TxRecognizePaymentFor7702A
- (double a_pmt
- ,bool a_this_payment_is_unnecessary
+ (currency a_pmt
+ ,bool a_this_payment_is_unnecessary
);
- void TxAcceptPayment (double payment);
- double GetPremLoad
- (double a_pmt
- ,double a_portion_exempt_from_premium_tax
+ void TxAcceptPayment (currency payment);
+ currency GetPremLoad
+ (currency a_pmt
+ ,currency a_portion_exempt_from_premium_tax
);
void TxLoanRepay ();
@@ -272,32 +273,32 @@ class LMI_SO AccountValue final
// Reflects optional daily interest accounting.
double ActualMonthlyRate (double monthly_rate) const;
- double InterestCredited
- (double principal
- ,double monthly_rate
+ currency InterestCredited
+ (currency principal
+ ,double monthly_rate
) const;
bool IsModalPmtDate (mcenum_mode) const;
bool IsModalPmtDate (); // Antediluvian.
int MonthsToNextModalPmtDate() const;
- double anticipated_deduction (mcenum_anticipated_deduction);
+ currency anticipated_deduction (mcenum_anticipated_deduction);
- double minimum_specified_amount(bool issuing_now, bool term_rider) const;
- void ChangeSpecAmtBy (double delta);
- void ChangeSupplAmtBy (double delta);
+ currency minimum_specified_amount(bool issuing_now, bool term_rider) const;
+ void ChangeSpecAmtBy (currency delta);
+ void ChangeSupplAmtBy (currency delta);
- double SurrChg () const;
- double CSVBoost () const;
+ currency SurrChg () const;
+ currency CSVBoost () const;
- void set_list_bill_year_and_month();
- void set_list_bill_premium();
- void set_modal_min_premium();
+ void set_list_bill_year_and_month();
+ void set_list_bill_premium();
+ void set_modal_min_premium();
- void SetMaxLoan ();
- void SetMaxWD ();
- double GetRefundableSalesLoad () const;
+ void SetMaxLoan ();
+ void SetMaxWD ();
+ currency GetRefundableSalesLoad() const;
- void ApplyDynamicMandE (double assets);
+ void ApplyDynamicMandE (currency assets);
void SetMonthlyDetail(int enumerator, std::string const& s);
void SetMonthlyDetail(int enumerator, double d);
@@ -313,12 +314,12 @@ class LMI_SO AccountValue final
std::ofstream DebugStream;
std::vector<std::string> DebugRecord;
- double PriorAVGenAcct;
- double PriorAVSepAcct;
- double PriorAVRegLn;
- double PriorAVPrfLn;
- double PriorRegLnBal;
- double PriorPrfLnBal;
+ currency PriorAVGenAcct;
+ currency PriorAVSepAcct;
+ currency PriorAVRegLn;
+ currency PriorAVPrfLn;
+ currency PriorRegLnBal;
+ currency PriorPrfLnBal;
// Mode flags.
bool Debugging;
@@ -339,13 +340,13 @@ class LMI_SO AccountValue final
oenum_allocation_method er_premium_allocation_method;
oenum_increment_account_preference er_premium_preferred_account;
- double GuarPremium;
+ currency GuarPremium;
// These data members make Solve() arguments available to SolveTest().
int SolveBeginYear_;
int SolveEndYear_;
mcenum_solve_target SolveTarget_;
- double SolveTargetCsv_;
+ currency SolveTargetCsv_;
int SolveTargetDuration_;
mcenum_gen_basis SolveGenBasis_;
mcenum_sep_basis SolveSepBasis_;
@@ -357,76 +358,76 @@ class LMI_SO AccountValue final
int LapseMonth; // Antediluvian.
int LapseYear; // Antediluvian.
- double External1035Amount;
- double Internal1035Amount;
- double Dumpin;
+ currency External1035Amount;
+ currency Internal1035Amount;
+ currency Dumpin;
- double MlyNoLapsePrem;
- double CumNoLapsePrem;
- bool NoLapseActive;
+ currency MlyNoLapsePrem;
+ currency CumNoLapsePrem;
+ bool NoLapseActive;
// Solves need to know when a no-lapse guarantee is active.
// Prefer int here because vector<bool> is not a container.
std::vector<int> YearlyNoLapseActive;
// Ullage is any positive excess of amount requested over amount available.
- std::vector<double> loan_ullage_;
- std::vector<double> withdrawal_ullage_;
+ std::vector<currency> loan_ullage_;
+ std::vector<currency> withdrawal_ullage_;
- double CumPmts;
- double TaxBasis;
+ currency CumPmts;
+ currency TaxBasis;
// This supports solves for tax basis. Eventually it should be
// moved into the invariant-ledger class.
- std::vector<double> YearlyTaxBasis;
+ std::vector<currency> YearlyTaxBasis;
// Ee- and Er-GrossPmts aren't used directly in the AV calculations.
// They must be kept separate for ledger output, and also for
// tax basis calculations (when we fix that).
- std::vector<double> GrossPmts;
- std::vector<double> EeGrossPmts;
- std::vector<double> ErGrossPmts;
- std::vector<double> NetPmts;
+ std::vector<currency> GrossPmts;
+ std::vector<currency> EeGrossPmts;
+ std::vector<currency> ErGrossPmts;
+ std::vector<currency> NetPmts;
// Reproposal input.
- int InforceYear;
- int InforceMonth;
- double InforceAVGenAcct;
- double InforceAVSepAcct;
- double InforceAVRegLn;
- double InforceAVPrfLn;
- double InforceRegLnBal;
- double InforcePrfLnBal;
- double InforceCumNoLapsePrem;
- double InforceBasis;
- double InforceCumPmts;
- double InforceTaxBasis;
- double InforceLoanBalance;
+ int InforceYear;
+ int InforceMonth;
+ currency InforceAVGenAcct;
+ currency InforceAVSepAcct;
+ currency InforceAVRegLn;
+ currency InforceAVPrfLn;
+ currency InforceRegLnBal;
+ currency InforcePrfLnBal;
+ currency InforceCumNoLapsePrem;
+ currency InforceBasis;
+ currency InforceCumPmts;
+ currency InforceTaxBasis;
+ currency InforceLoanBalance;
// Intermediate values.
- int Year;
- int Month;
- int MonthsSinceIssue;
- bool daily_interest_accounting;
- int days_in_policy_month;
- int days_in_policy_year;
- double AVGenAcct;
- double AVSepAcct;
- double SepAcctValueAfterDeduction;
- double GenAcctPaymentAllocation;
- double SepAcctPaymentAllocation;
- double NAAR;
- double CoiCharge;
- double RiderCharges;
- double NetCoiCharge;
- double SpecAmtLoadBase;
- double DacTaxRsv;
-
- double AVUnloaned; // Antediluvian.
-
- double NetMaxNecessaryPremium;
- double GrossMaxNecessaryPremium;
- double NecessaryPremium;
- double UnnecessaryPremium;
+ int Year;
+ int Month;
+ int MonthsSinceIssue;
+ bool daily_interest_accounting;
+ int days_in_policy_month;
+ int days_in_policy_year;
+ currency AVGenAcct;
+ currency AVSepAcct;
+ currency SepAcctValueAfterDeduction;
+ double GenAcctPaymentAllocation;
+ double SepAcctPaymentAllocation;
+ double NAAR;
+ currency CoiCharge;
+ currency RiderCharges;
+ currency NetCoiCharge;
+ currency SpecAmtLoadBase;
+ double DacTaxRsv;
+
+ currency AVUnloaned; // Antediluvian.
+
+ currency NetMaxNecessaryPremium;
+ currency GrossMaxNecessaryPremium;
+ currency NecessaryPremium;
+ currency UnnecessaryPremium;
// 7702A CVAT deemed cash value.
double Dcv;
@@ -438,48 +439,48 @@ class LMI_SO AccountValue final
// For other riders like AD&D, charge for DCV = charge otherwise.
// Honeymoon provision.
- bool HoneymoonActive;
- double HoneymoonValue;
+ bool HoneymoonActive;
+ currency HoneymoonValue;
// 7702 GPT
- double GptForceout;
- double YearsTotalGptForceout;
+ currency GptForceout;
+ currency YearsTotalGptForceout;
// Intermediate values within annual or monthly loop only.
- double pmt; // Antediluvian.
+ currency pmt; // Antediluvian.
mcenum_mode pmt_mode; // Antediluvian.
int ModeIndex; // Antediluvian.
- double GenAcctIntCred;
- double SepAcctIntCred;
- double RegLnIntCred;
- double PrfLnIntCred;
- double AVRegLn;
- double AVPrfLn;
- double RegLnBal;
- double PrfLnBal;
- double MaxLoan;
- double UnusedTargetPrem;
- double AnnualTargetPrem;
- double MaxWD;
- double GrossWD;
- double NetWD;
- double CumWD;
-
- double wd; // Antediluvian.
- double mlyguarv; // Antediluvian.
+ currency GenAcctIntCred;
+ currency SepAcctIntCred;
+ currency RegLnIntCred;
+ currency PrfLnIntCred;
+ currency AVRegLn;
+ currency AVPrfLn;
+ currency RegLnBal;
+ currency PrfLnBal;
+ currency MaxLoan;
+ currency UnusedTargetPrem;
+ currency AnnualTargetPrem;
+ currency MaxWD;
+ currency GrossWD;
+ currency NetWD;
+ currency CumWD;
+
+ currency wd; // Antediluvian.
+ double mlyguarv; // Antediluvian.
// For GPT: SA, DB, and DBOpt before the day's transactions are applied.
- double OldSA;
- double OldDB;
+ currency OldSA;
+ currency OldDB;
mcenum_dbopt OldDBOpt;
// Permanent invariants are in class BasicValues; these are
// annual invariants.
double YearsCorridorFactor;
mcenum_dbopt YearsDBOpt;
- double YearsAnnualPolicyFee;
- double YearsMonthlyPolicyFee;
+ currency YearsAnnualPolicyFee;
+ currency YearsMonthlyPolicyFee;
double YearsGenAcctIntRate;
double YearsSepAcctIntRate;
@@ -515,71 +516,71 @@ class LMI_SO AccountValue final
double YearsSalesLoadRefundRate;
double YearsDacTaxLoadRate;
- double MonthsPolicyFees;
- double SpecAmtLoad;
- double premium_load_;
- double sales_load_;
- double premium_tax_load_;
- double dac_tax_load_;
+ currency MonthsPolicyFees;
+ currency SpecAmtLoad;
+ double premium_load_;
+ double sales_load_;
+ double premium_tax_load_;
+ double dac_tax_load_;
// Stratified loads are determined by assets and cumulative
// payments immediately after the monthly deduction. Both are
// stored at the proper moment, where they're constrained to be
// nonnegative. Stratified loads happen to be used only for the
// separate account.
- double AssetsPostBom;
- double CumPmtsPostBom;
- double SepAcctLoad;
-
- double case_k_factor;
- double ActualCoiRate;
-
- bool SplitMinPrem;
- bool UnsplitSplitMinPrem;
-
- int list_bill_year_ {methuselah};
- int list_bill_month_ {13};
-
- bool TermCanLapse;
- bool TermRiderActive;
- double ActualSpecAmt;
- double TermSpecAmt;
- double TermDB;
- double DB7702A;
- double DBIgnoringCorr;
- double DBReflectingCorr;
-
- double deathbft; // Antediluvian.
- bool haswp; // Antediluvian.
- bool hasadb; // Antediluvian.
-
- double ActualLoan;
- double RequestedLoan;
- double RequestedWD;
-
- double AdbCharge;
- double SpouseRiderCharge;
- double ChildRiderCharge;
- double WpCharge;
- double TermCharge;
-
- double MlyDed;
- double mlydedtonextmodalpmtdate; // Antediluvian.
-
- double YearsTotalCoiCharge;
- double YearsTotalRiderCharges;
- double YearsAVRelOnDeath;
- double YearsLoanRepaidOnDeath;
- double YearsGrossClaims;
- double YearsDeathProceeds;
- double YearsNetClaims;
- double YearsTotalNetIntCredited;
- double YearsTotalGrossIntCredited;
- double YearsTotalLoanIntAccrued;
- double YearsTotalPolicyFee;
- double YearsTotalDacTaxLoad;
- double YearsTotalSpecAmtLoad;
- double YearsTotalSepAcctLoad;
+ currency AssetsPostBom;
+ currency CumPmtsPostBom;
+ currency SepAcctLoad;
+
+ double case_k_factor;
+ double ActualCoiRate;
+
+ bool SplitMinPrem;
+ bool UnsplitSplitMinPrem;
+
+ int list_bill_year_ {methuselah};
+ int list_bill_month_ {13};
+
+ bool TermCanLapse;
+ bool TermRiderActive;
+ currency ActualSpecAmt;
+ currency TermSpecAmt;
+ currency TermDB;
+ currency DB7702A;
+ currency DBIgnoringCorr;
+ currency DBReflectingCorr;
+
+ currency deathbft; // Antediluvian.
+ bool haswp; // Antediluvian.
+ bool hasadb; // Antediluvian.
+
+ currency ActualLoan;
+ currency RequestedLoan;
+ currency RequestedWD;
+
+ currency AdbCharge;
+ currency SpouseRiderCharge;
+ currency ChildRiderCharge;
+ currency WpCharge;
+ currency TermCharge;
+
+ currency MlyDed;
+ currency mlydedtonextmodalpmtdate; // Antediluvian.
+
+ currency YearsTotalCoiCharge;
+ currency YearsTotalRiderCharges;
+ double YearsAVRelOnDeath;
+ double YearsLoanRepaidOnDeath;
+ double YearsGrossClaims;
+ double YearsDeathProceeds;
+ double YearsNetClaims;
+ currency YearsTotalNetIntCredited;
+ currency YearsTotalGrossIntCredited;
+ currency YearsTotalLoanIntAccrued;
+ currency YearsTotalPolicyFee;
+ double YearsTotalDacTaxLoad;
+ currency YearsTotalSpecAmtLoad;
+ currency YearsTotalSepAcctLoad;
// For experience rating.
double CoiRetentionRate;
@@ -588,32 +589,32 @@ class LMI_SO AccountValue final
double NextYearsProjectedCoiCharge;
double YearsTotalNetCoiCharge;
- double CumulativeSalesLoad;
+ currency CumulativeSalesLoad;
// Illustrated outlay must be the same for current, guaranteed,
// and all other bases. Outlay components are set on whichever
// basis governs, usually current, then stored for use with all
// other bases.
- std::vector<double> OverridingPmts; // Antediluvian.
- std::vector<double> stored_pmts; // Antediluvian.
+ std::vector<currency> OverridingPmts; // Antediluvian.
+ std::vector<currency> stored_pmts; // Antediluvian.
- std::vector<double> OverridingEePmts;
- std::vector<double> OverridingErPmts;
+ std::vector<currency> OverridingEePmts;
+ std::vector<currency> OverridingErPmts;
// We need no 'OverridingDumpin' because we simply treat dumpin as
// employee premium.
- double OverridingExternal1035Amount;
- double OverridingInternal1035Amount;
+ currency OverridingExternal1035Amount;
+ currency OverridingInternal1035Amount;
- std::vector<double> OverridingLoan;
- std::vector<double> OverridingWD;
+ std::vector<currency> OverridingLoan;
+ std::vector<currency> OverridingWD;
- std::vector<double> SurrChg_; // Of uncertain utility.
+ std::vector<currency> SurrChg_; // Of uncertain utility.
};
//============================================================================
-inline double AccountValue::TotalAccountValue() const
+inline currency AccountValue::TotalAccountValue() const
{
return AVGenAcct + AVSepAcct + AVRegLn + AVPrfLn;
}
diff --git a/basic_values.hpp b/basic_values.hpp
index ce3816f..0e72ed0 100644
--- a/basic_values.hpp
+++ b/basic_values.hpp
@@ -25,6 +25,7 @@
#include "config.hpp"
#include "actuarial_table.hpp" // e_actuarial_table_method
+#include "currency.hpp"
#include "database.hpp"
#include "dbnames.hpp" // e_database_key
#include "mc_enum_type_enums.hpp"
@@ -134,7 +135,7 @@ class LMI_SO BasicValues
product_data const& product () const {return product_;}
product_database const& database() const {return database_;}
- double GetAnnualTgtPrem(int a_year, double a_specamt) const;
+ currency GetAnnualTgtPrem(int a_year, currency a_specamt) const;
std::vector<double> const& GetCorridorFactor() const;
std::vector<double> const& SpreadFor7702() const;
@@ -199,89 +200,89 @@ class LMI_SO BasicValues
round_to<double> const& round_minutiae () const {return
round_minutiae_ ;}
protected:
- double GetModalMinPrem
+ currency GetModalMinPrem
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
) const;
- double GetModalTgtPrem
+ currency GetModalTgtPrem
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
) const;
- double GetModalPremMaxNonMec
+ currency GetModalPremMaxNonMec
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
) const;
- double GetModalPremMinFromTable
+ currency GetModalPremMinFromTable
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
) const;
- double GetModalPremTgtFromTable
+ currency GetModalPremTgtFromTable
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
) const;
- double GetModalPremProxyTable
+ currency GetModalPremProxyTable
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
,double a_table_multiplier
) const;
- double GetModalPremCorridor
+ currency GetModalPremCorridor
(int a_year
,mcenum_mode a_mode
- ,double a_specamt
+ ,currency a_specamt
) const;
- double GetModalPremGLP
+ currency GetModalPremGLP
(int a_duration
,mcenum_mode a_mode
- ,double a_bft_amt
- ,double a_specamt
+ ,currency a_bft_amt
+ ,currency a_specamt
) const;
- double GetModalPremGSP
+ currency GetModalPremGSP
(int a_duration
,mcenum_mode a_mode
- ,double a_bft_amt
- ,double a_specamt
+ ,currency a_bft_amt
+ ,currency a_specamt
) const;
- std::pair<double,double> GetModalPremMlyDedEx
+ std::pair<currency,currency> GetModalPremMlyDedEx
(int year
,mcenum_mode mode
- ,double specamt
- ,double termamt
+ ,currency specamt
+ ,currency termamt
) const;
- double GetListBillPremMlyDed
+ currency GetListBillPremMlyDed
(int year
,mcenum_mode mode
- ,double specamt
+ ,currency specamt
) const;
- std::pair<double,double> GetListBillPremMlyDedEx
+ std::pair<currency,currency> GetListBillPremMlyDedEx
(int year
,mcenum_mode mode
- ,double specamt
- ,double termamt
+ ,currency specamt
+ ,currency termamt
) const;
- double GetModalSpecAmtMax (double annualized_pmt) const;
- double GetModalSpecAmtTgt (double annualized_pmt) const;
- double GetModalSpecAmtMinNonMec(double annualized_pmt) const;
- double GetModalSpecAmtGLP (double annualized_pmt) const;
- double GetModalSpecAmtGSP (double annualized_pmt) const;
- double GetModalSpecAmtCorridor (double annualized_pmt) const;
- double GetModalSpecAmtSalary (int a_year) const;
+ currency GetModalSpecAmtMax (currency annualized_pmt) const;
+ currency GetModalSpecAmtTgt (currency annualized_pmt) const;
+ currency GetModalSpecAmtMinNonMec(currency annualized_pmt) const;
+ currency GetModalSpecAmtGLP (currency annualized_pmt) const;
+ currency GetModalSpecAmtGSP (currency annualized_pmt) const;
+ currency GetModalSpecAmtCorridor (currency annualized_pmt) const;
+ currency GetModalSpecAmtSalary (int a_year) const;
// Deprecated--used only by the antediluvian branch, which does
// not distinguish ee from er premium.
- double GetModalMaxSpecAmt
+ currency GetModalMaxSpecAmt
(mcenum_mode a_mode
- ,double a_pmt
+ ,currency a_pmt
) const;
// Deprecated--used only by the antediluvian branch, which does
// not distinguish ee from er premium.
- double GetModalTgtSpecAmt
+ currency GetModalTgtSpecAmt
(mcenum_mode a_mode
- ,double a_pmt
+ ,currency a_pmt
) const;
std::vector<double> GetTable
(std::string const& TableFile
@@ -293,7 +294,7 @@ class LMI_SO BasicValues
std::vector<double> const& GetBandedCoiRates
(mcenum_gen_basis rate_basis
- ,double a_specamt
+ ,currency a_specamt
) const;
// TODO ?? A priori, protected data is a defect.
@@ -309,13 +310,13 @@ class LMI_SO BasicValues
mcenum_defn_life_ins DefnLifeIns_;
mcenum_defn_material_change DefnMaterialChange_;
mcenum_dbopt_7702 Effective7702DboRop;
- double MaxNAAR;
+ currency MaxNAAR;
int EndtAge;
- double MinSpecAmt; // Antediluvian.
- double MinIssSpecAmt;
- double MinIssBaseSpecAmt;
- double MinRenlSpecAmt;
- double MinRenlBaseSpecAmt;
+ currency MinSpecAmt; // Antediluvian.
+ currency MinIssSpecAmt;
+ currency MinIssBaseSpecAmt;
+ currency MinRenlSpecAmt;
+ currency MinRenlBaseSpecAmt;
bool NoLapseDboLvlOnly;
bool NoLapseUnratedOnly;
bool OptChgCanIncrSA;
@@ -334,7 +335,7 @@ class LMI_SO BasicValues
oenum_modal_prem_type MinPremType;
oenum_modal_prem_type TgtPremType;
bool TgtPremFixedAtIssue;
- double TgtPremMonthlyPolFee;
+ currency TgtPremMonthlyPolFee;
double CurrCoiTable0Limit;
double CurrCoiTable1Limit;
e_actuarial_table_method CoiInforceReentry;
@@ -357,8 +358,8 @@ class LMI_SO BasicValues
double AdbLimit;
double WpLimit;
double SpecAmtLoadLimit;
- double MinWD;
- double WDFee;
+ currency MinWD;
+ currency WDFee;
double WDFeeRate;
bool AllowChangeToDBO2;
@@ -380,7 +381,7 @@ class LMI_SO BasicValues
std::vector<double> MinPremIntSpread_;
- std::vector<double> TieredMEBands;
+ std::vector<currency> TieredMEBands;
std::vector<double> TieredMECharges;
private:
@@ -392,20 +393,20 @@ class LMI_SO BasicValues
double mly_ded_discount_factor(int year, mcenum_mode mode) const;
std::pair<double,double> approx_mly_ded
- (int year
- ,double specamt
+ (int year
+ ,currency specamt
) const;
std::pair<double,double> approx_mly_ded_ex
- (int year
- ,double specamt
- ,double termamt
+ (int year
+ ,currency specamt
+ ,currency termamt
) const;
- double GetModalPremMlyDed
+ currency GetModalPremMlyDed
(int year
,mcenum_mode mode
- ,double specamt
+ ,currency specamt
) const;
- double GetModalSpecAmtMlyDed(double annualized_pmt, mcenum_mode) const;
+ currency GetModalSpecAmtMlyDed(currency annualized_pmt, mcenum_mode) const;
std::vector<double> GetActuarialTable
(std::string const& TableFile
@@ -437,7 +438,7 @@ class LMI_SO BasicValues
std::vector<double> partial_mortality_tpx_;
std::vector<double> partial_mortality_lx_;
- mutable double InitialTargetPremium;
+ mutable currency InitialTargetPremium;
void Init7702();
void Init7702A();
diff --git a/death_benefits.hpp b/death_benefits.hpp
index 46fbeb8..e171d3f 100644
--- a/death_benefits.hpp
+++ b/death_benefits.hpp
@@ -24,6 +24,7 @@
#include "config.hpp"
+#include "currency.hpp"
#include "mc_enum_type_enums.hpp"
#include "round_to.hpp"
@@ -41,12 +42,12 @@ class death_benefits final
);
~death_benefits() = default;
- void set_specamt (double z, int from_year, int to_year);
- void set_supplamt(double z, int from_year, int to_year);
+ void set_specamt (currency z, int from_year, int to_year);
+ void set_supplamt(currency z, int from_year, int to_year);
std::vector<mcenum_dbopt> const& dbopt () const;
- std::vector<double> const& specamt () const;
- std::vector<double> const& supplamt() const;
+ std::vector<currency> const& specamt () const;
+ std::vector<currency> const& supplamt() const;
private:
death_benefits(death_benefits const&) = delete;
@@ -57,8 +58,8 @@ class death_benefits final
round_to<double> round_specamt_;
std::vector<mcenum_dbopt> dbopt_ ;
- std::vector<double> specamt_ ;
- std::vector<double> supplamt_;
+ std::vector<currency> specamt_ ;
+ std::vector<currency> supplamt_;
};
inline std::vector<mcenum_dbopt> const& death_benefits::dbopt() const
@@ -66,12 +67,12 @@ inline std::vector<mcenum_dbopt> const&
death_benefits::dbopt() const
return dbopt_;
}
-inline std::vector<double> const& death_benefits::specamt() const
+inline std::vector<currency> const& death_benefits::specamt() const
{
return specamt_;
}
-inline std::vector<double> const& death_benefits::supplamt() const
+inline std::vector<currency> const& death_benefits::supplamt() const
{
return supplamt_;
}
diff --git a/gpt_specamt.hpp b/gpt_specamt.hpp
index ada76a2..df13000 100644
--- a/gpt_specamt.hpp
+++ b/gpt_specamt.hpp
@@ -24,6 +24,7 @@
#include "config.hpp"
+#include "currency.hpp"
#include "ihs_irc7702.hpp" // Irc7702::EIOBasis
#include "mc_enum_type_enums.hpp" // mcenum_dbopt_7702
@@ -53,24 +54,24 @@ class gpt_specamt
typedef Irc7702::EIOBasis EIOBasis;
public:
- static double CalculateGLPSpecAmt
+ static currency CalculateGLPSpecAmt
(BasicValues const& a_Values
,int a_Duration
- ,double a_Premium
+ ,currency a_Premium
,mcenum_dbopt_7702 a_DBOpt
);
- static double CalculateGSPSpecAmt
+ static currency CalculateGSPSpecAmt
(BasicValues const& a_Values
,int a_Duration
- ,double a_Premium
+ ,currency a_Premium
);
private:
- static double CalculateSpecAmt
+ static currency CalculateSpecAmt
(BasicValues const& a_Values
,Irc7702::EIOBasis a_EIOBasis
,int a_Duration
- ,double a_Premium
+ ,currency a_Premium
,double a_NetPmtFactorTgt
,double a_NetPmtFactorExc
);
diff --git a/outlay.hpp b/outlay.hpp
index 9bc6044..dc2afe0 100644
--- a/outlay.hpp
+++ b/outlay.hpp
@@ -24,6 +24,7 @@
#include "config.hpp"
+#include "currency.hpp"
#include "mc_enum_type_enums.hpp"
#include "round_to.hpp"
@@ -44,61 +45,61 @@ class modal_outlay final
);
~modal_outlay() = default;
- double dumpin () const;
- double external_1035_amount () const;
- double internal_1035_amount () const;
- std::vector<double> const& ee_modal_premiums () const;
+ currency dumpin () const;
+ currency external_1035_amount () const;
+ currency internal_1035_amount () const;
+ std::vector<currency> const& ee_modal_premiums () const;
std::vector<mcenum_mode> const& ee_premium_modes () const;
- std::vector<double> const& er_modal_premiums () const;
+ std::vector<currency> const& er_modal_premiums () const;
std::vector<mcenum_mode> const& er_premium_modes () const;
- std::vector<double> const& withdrawals () const;
- std::vector<double> const& new_cash_loans () const;
+ std::vector<currency> const& withdrawals () const;
+ std::vector<currency> const& new_cash_loans () const;
private:
modal_outlay(modal_outlay const&) = delete;
modal_outlay& operator=(modal_outlay const&) = delete;
// Not yet used, but needed for MEC avoidance.
- void set_external_1035_amount(double z);
- void set_internal_1035_amount(double z);
+ void set_external_1035_amount(currency z);
+ void set_internal_1035_amount(currency z);
- void set_ee_modal_premiums(double z, int from_year, int to_year);
- void set_er_modal_premiums(double z, int from_year, int to_year);
- void set_er_modal_premiums(std::vector<double> const&);
- void set_withdrawals (double z, int from_year, int to_year);
- void set_new_cash_loans (double z, int from_year, int to_year);
+ void set_ee_modal_premiums(currency z, int from_year, int to_year);
+ void set_er_modal_premiums(currency z, int from_year, int to_year);
+ void set_er_modal_premiums(std::vector<currency> const&);
+ void set_withdrawals (currency z, int from_year, int to_year);
+ void set_new_cash_loans (currency z, int from_year, int to_year);
round_to<double> round_gross_premium_;
round_to<double> round_withdrawal_;
round_to<double> round_loan_;
- double dumpin_;
- double external_1035_amount_;
- double internal_1035_amount_;
- std::vector<double> ee_modal_premiums_;
+ currency dumpin_;
+ currency external_1035_amount_;
+ currency internal_1035_amount_;
+ std::vector<currency> ee_modal_premiums_;
std::vector<mcenum_mode> ee_premium_modes_;
- std::vector<double> er_modal_premiums_;
+ std::vector<currency> er_modal_premiums_;
std::vector<mcenum_mode> er_premium_modes_;
- std::vector<double> withdrawals_;
- std::vector<double> new_cash_loans_;
+ std::vector<currency> withdrawals_;
+ std::vector<currency> new_cash_loans_;
};
-inline double modal_outlay::dumpin() const
+inline currency modal_outlay::dumpin() const
{
return dumpin_;
}
-inline double modal_outlay::external_1035_amount() const
+inline currency modal_outlay::external_1035_amount() const
{
return external_1035_amount_;
}
-inline double modal_outlay::internal_1035_amount() const
+inline currency modal_outlay::internal_1035_amount() const
{
return internal_1035_amount_;
}
-inline std::vector<double> const& modal_outlay::ee_modal_premiums() const
+inline std::vector<currency> const& modal_outlay::ee_modal_premiums() const
{
return ee_modal_premiums_;
}
@@ -108,7 +109,7 @@ inline std::vector<mcenum_mode> const&
modal_outlay::ee_premium_modes() const
return ee_premium_modes_;
}
-inline std::vector<double> const& modal_outlay::er_modal_premiums() const
+inline std::vector<currency> const& modal_outlay::er_modal_premiums() const
{
return er_modal_premiums_;
}
@@ -118,12 +119,12 @@ inline std::vector<mcenum_mode> const&
modal_outlay::er_premium_modes() const
return er_premium_modes_;
}
-inline std::vector<double> const& modal_outlay::withdrawals() const
+inline std::vector<currency> const& modal_outlay::withdrawals() const
{
return withdrawals_;
}
-inline std::vector<double> const& modal_outlay::new_cash_loans() const
+inline std::vector<currency> const& modal_outlay::new_cash_loans() const
{
return new_cash_loans_;
}
- [lmi-commits] [lmi] branch valyuta/002 created (now 9433c8e), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 ef7fe2f 01/65: Change type of currency variables to 'currency' in headers,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/002 540c4f3 11/65: currency(0.0), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 e260d89 14/65: avoid operator double(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 deba50c 25/65: assert rounding to currency makes sense, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 7dc9331 32/65: round.c(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 915d111 26/65: avoid operator double(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 d837132 38/65: Overload currency ctor, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 5d2e8ec 49/65: prefer to avoid operator=(double)?, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 015253b 10/65: add an alternative, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 346c95b 05/65: improve, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 c4e0809 24/65: use round_to<>.c(), Greg Chicares, 2020/09/16