pub struct AmortizationSolution { /* private fields */ }Expand description
Full amortization setup: inputs, level payment, formulas, and access to a period series.
Create with amortization_solution (returns FinanceResult).
§Examples
use finance_solution::*;
let s = amortization_solution(0.08 / 12.0, 12, 10_000.0, 0.0, false).unwrap();
println!("{}", s.formula());
println!("{}", s.symbolic_formula());
assert_eq!(s.periods(), 12);
s.print_table();print_table() is sugar for series().print_table(true, true) and looks like:
period payment principal interest balance ... payments_remaining
------ --------- --------- -------- ---------- ... ------------------
1 -869.8843 -803.2176 -66.6667 9_196.7824 ... -9_568.7272
2 -869.8843 -808.5724 -61.3119 8_388.2100 ... -8_698.8429
...
12 -869.8843 -864.1235 -5.7608 -0.0000 ... 0.0000Implementations§
Source§impl AmortizationSolution
impl AmortizationSolution
Sourcepub fn present_value(&self) -> f64
pub fn present_value(&self) -> f64
Present value (principal).
Sourcepub fn future_value(&self) -> f64
pub fn future_value(&self) -> f64
Future value (balloon / residual).
Sourcepub fn due_at_beginning(&self) -> bool
pub fn due_at_beginning(&self) -> bool
Whether payment is due at the beginning of each period.
Sourcepub fn sum_of_payments(&self) -> f64
pub fn sum_of_payments(&self) -> f64
payment * periods.
Sourcepub fn sum_of_interest(&self) -> f64
pub fn sum_of_interest(&self) -> f64
Total interest over the full term (sum_of_payments + present_value + future_value).
Sourcepub fn symbolic_formula(&self) -> &str
pub fn symbolic_formula(&self) -> &str
Symbolic formula (e.g. pmt = ...).
Sourcepub fn ipmt(&self, period: u32) -> FinanceResult<f64>
pub fn ipmt(&self, period: u32) -> FinanceResult<f64>
Interest portion for a 1-based period (Excel IPMT).
§Errors
FinanceError::InvalidPeriod if period is not in 1..=periods.
Sourcepub fn ppmt(&self, period: u32) -> FinanceResult<f64>
pub fn ppmt(&self, period: u32) -> FinanceResult<f64>
Principal portion for a 1-based period (Excel PPMT).
§Errors
FinanceError::InvalidPeriod if period is not in 1..=periods.
Sourcepub fn cumipmt(&self, start_period: u32, end_period: u32) -> FinanceResult<f64>
pub fn cumipmt(&self, start_period: u32, end_period: u32) -> FinanceResult<f64>
Cumulative interest from start_period..=end_period (1-based, inclusive).
§Errors
FinanceError::InvalidPeriod if the range is empty, inverted, or outside 1..=periods.
Sourcepub fn cumprinc(&self, start_period: u32, end_period: u32) -> FinanceResult<f64>
pub fn cumprinc(&self, start_period: u32, end_period: u32) -> FinanceResult<f64>
Cumulative principal from start_period..=end_period (1-based, inclusive).
§Errors
FinanceError::InvalidPeriod if the range is empty, inverted, or outside 1..=periods.
Sourcepub fn series(&self) -> AmortizationSeries
pub fn series(&self) -> AmortizationSeries
Period-by-period amortization schedule.
§Examples
use finance_solution::*;
let series = amortization_solution(0.08 / 12.0, 12, 10_000.0, 0.0, false)
.unwrap()
.series();
for row in series.iter() {
assert_approx_equal!(row.principal() + row.interest(), row.payment());
}
series.print_table(true, true);Example terminal output (first/last rows; full 12-period table in the module docs):
period payment principal interest balance principal_to_date ...
------ --------- --------- -------- ---------- ----------------- ...
1 -869.8843 -803.2176 -66.6667 9_196.7824 -803.2176 ...
...
12 -869.8843 -864.1235 -5.7608 -0.0000 -10_000.0000 ...Sourcepub fn print_table(&self)
pub fn print_table(&self)
Print the full schedule with running totals and remaining amounts.
Sourcepub fn print_table_locale(&self, locale: &Locale, precision: usize)
pub fn print_table_locale(&self, locale: &Locale, precision: usize)
Locale-aware table (thousands separators, decimal places).
Trait Implementations§
Source§impl Clone for AmortizationSolution
impl Clone for AmortizationSolution
Source§fn clone(&self) -> AmortizationSolution
fn clone(&self) -> AmortizationSolution
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AmortizationSolution
impl RefUnwindSafe for AmortizationSolution
impl Send for AmortizationSolution
impl Sync for AmortizationSolution
impl Unpin for AmortizationSolution
impl UnsafeUnpin for AmortizationSolution
impl UnwindSafe for AmortizationSolution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more