[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 5afe8dc 6/7: Round values in class modal_outl
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 5afe8dc 6/7: Round values in class modal_outlay |
Date: |
Sun, 23 Aug 2020 18:00:52 -0400 (EDT) |
branch: master
commit 5afe8dcd17c9e01a59f38077e373c2b048f881ca
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Round values in class modal_outlay
This happens to have no effect on lmi's regression testing, which
doesn't encompass improbabilities like paying pi dollars. However, it
does have an effect that can be seen by entering payments in fractional
cents, or by changing the gross-payment rounding rule (say, downward to
whole dollars) and running a regression test.
---
outlay.cpp | 28 ++++++++++++++++------------
outlay.hpp | 4 ++--
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/outlay.cpp b/outlay.cpp
index 285478d..88ab2fb 100644
--- a/outlay.cpp
+++ b/outlay.cpp
@@ -35,42 +35,46 @@ modal_outlay::modal_outlay
,round_to<double> const& round_loan
)
:round_gross_premium_ {round_gross_premium}
- ,round_withdrawal_ {round_withdrawal}
- ,round_loan_ {round_loan}
- ,dumpin_ {yi.Dumpin}
- ,external_1035_amount_ {yi.External1035ExchangeAmount}
- ,internal_1035_amount_ {yi.Internal1035ExchangeAmount}
- ,ee_modal_premiums_ {yi.Payment}
- ,ee_premium_modes_ {yi.PaymentMode}
- ,er_modal_premiums_ {yi.CorporationPayment}
- ,er_premium_modes_ {yi.CorporationPaymentMode}
- ,withdrawals_ {yi.Withdrawal}
- ,new_cash_loans_ {yi.NewLoan}
+ ,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)
}
{
}
void modal_outlay::set_ee_modal_premiums(double z, int from_year, int to_year)
{
+ z = round_gross_premium_(z);
std::fill_n(ee_modal_premiums_.begin() + from_year, to_year - from_year,
z);
}
void modal_outlay::set_er_modal_premiums(double z, int from_year, int to_year)
{
+ z = round_gross_premium_(z);
std::fill_n(er_modal_premiums_.begin() + from_year, to_year - from_year,
z);
}
void modal_outlay::set_er_modal_premiums(std::vector<double> const& z)
{
LMI_ASSERT(z.size() == er_modal_premiums_.size());
- er_modal_premiums_ = z;
+ er_modal_premiums_ = round_gross_premium_(z);
}
void modal_outlay::set_withdrawals(double z, int from_year, int to_year)
{
+ z = round_withdrawal_(z);
std::fill_n(withdrawals_.begin() + from_year, to_year - from_year, z);
}
void modal_outlay::set_new_cash_loans(double z, int from_year, int to_year)
{
+ z = round_loan_(z);
std::fill_n(new_cash_loans_.begin() + from_year, to_year - from_year, z);
}
diff --git a/outlay.hpp b/outlay.hpp
index fd4a361..f8baf36 100644
--- a/outlay.hpp
+++ b/outlay.hpp
@@ -130,12 +130,12 @@ inline std::vector<double> const&
modal_outlay::new_cash_loans() const
inline void modal_outlay::set_external_1035_amount(double z)
{
- external_1035_amount_ = z;
+ external_1035_amount_ = round_gross_premium_(z);
}
inline void modal_outlay::set_internal_1035_amount(double z)
{
- internal_1035_amount_ = z;
+ internal_1035_amount_ = round_gross_premium_(z);
}
#endif // outlay_hpp
- [lmi-commits] [lmi] master updated (d9955ce -> b83bdf0), Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master 9cbb041 1/7: Prefer 'git switch' to optionless 'git checkout', Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master 9553083 4/7: Prepare to round in class modal_outlay, Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master a92e5c3 5/7: Overload rounding function objects to handle vectors, Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master 7ac2bd0 2/7: Say why a header is included, Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master 2ceaa93 3/7: Change order of loans and withdrawals in class modal_outlay, Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master b83bdf0 7/7: Improve concinnity, Greg Chicares, 2020/08/23
- [lmi-commits] [lmi] master 5afe8dc 6/7: Round values in class modal_outlay,
Greg Chicares <=