aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorGuillermo Ramos2025-03-14 11:52:09 +0100
committerGuillermo Ramos2025-03-15 13:33:30 +0100
commita05b9066900a017ac75e77e687f5414ad6f8d25a (patch)
treec85eb5a1519a4c8b50fb6fc9c6d5e9dfe19b3c12 /src/lib.rs
parent8dff02998db9eac1efacf555ccbdec198d7fe213 (diff)
downloadhiccup-a05b9066900a017ac75e77e687f5414ad6f8d25a.tar.gz
New update: change interest rate
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1f4a977..597a360 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -90,6 +90,10 @@ impl Simulation {
self.payed.principal += principal;
self.payed_amortized += principal;
}
+ SimUpdate::SetI1(i1) => {
+ st.i12 = i1 / 12.0;
+ st.calculate_monthly();
+ }
}
}
}
@@ -261,6 +265,7 @@ impl SimUpdates {
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum SimUpdate {
Amortize(f64),
+ SetI1(f64),
}
impl fmt::Display for SimUpdate {
@@ -270,6 +275,9 @@ impl fmt::Display for SimUpdate {
Self::Amortize(principal) => {
write!(f, "{principal:.2} amortized to reduce pending quotas]")
}
+ Self::SetI1(i1) => {
+ write!(f, "I1 set to {i1:.2}]")
+ }
}
}
}
@@ -296,6 +304,9 @@ fn flatten_amortizations(updates: Vec<SimUpdate>) -> Vec<SimUpdate> {
SimUpdate::Amortize(n) => {
amortized += n;
}
+ SimUpdate::SetI1(_) => {
+ result.push(update);
+ }
}
}
if amortized > 0. {