pub struct PaymentSolution(/* private fields */);Implementations§
Source§impl PaymentSolution
impl PaymentSolution
pub fn print_table(&self)
Sourcepub fn series(&self) -> PaymentSeries
pub fn series(&self) -> PaymentSeries
Calculates the period-by-period details of a payment calculation including how the payment is broken down between principal and interest.
§Examples
An amortized loan. Uses [payment].
use finance_solution::*;
let years = 5;
// The annual percentage rate is 15% and the interest will compound monthly.
let rate = convert_apr_to_epr(0.15, 12);
// Each period will be one month.
let periods = years * 12;
// The amount of the loan is $20,000.
let present_value = 20_000;
// The loan will be fully paid off ot the end of the last period.
let future_value = 0;
// Payments are due at the end of the month.
let due_at_beginning = false;
// Calculate the payment, creating a struct that contains additional information and the option
// to generate period-by-period details.
let solution = payment_solution(rate, periods, present_value, future_value, due_at_beginning);
dbg!(&solution);
// Calculate the month-by-month details including the principal and interest paid every month.
let series = solution.series();
dbg!(&series);
// Confirm that we have one entry for each period.
assert_eq!(periods as usize, series.len());
// Print the period detail numbers as a formatted table.
let include_running_totals = true;
let include_remaining_amounts = true;
let locale = num_format::Locale::en;
let precision = 2; // Two decimal places.
series.print_table_locale(include_running_totals, include_remaining_amounts, &locale, precision);
// As above but print only the last period for every yeor of the loan, that is periods 12, 24,
// 36, 48, and 60; and use default formatting.
series
.filter(|x| x.period() % 12 == 0)
.print_table(include_running_totals, include_remaining_amounts);pub fn print_ab_comparison( &self, other: &PaymentSolution, include_running_totals: bool, include_remaining_amounts: bool, )
pub fn print_ab_comparison_locale( &self, other: &PaymentSolution, include_running_totals: bool, include_remaining_amounts: bool, locale: &Locale, precision: usize, )
Methods from Deref<Target = CashflowSolution>§
pub fn calculated_field(&self) -> &CashflowVariable
pub fn rate(&self) -> f64
pub fn periods(&self) -> u32
pub fn present_value(&self) -> f64
pub fn future_value(&self) -> f64
pub fn due_at_beginning(&self) -> bool
pub fn payment(&self) -> f64
pub fn sum_of_payments(&self) -> f64
pub fn sum_of_interest(&self) -> f64
pub fn formula(&self) -> &str
pub fn symbolic_formula(&self) -> &str
Trait Implementations§
Source§impl Clone for PaymentSolution
impl Clone for PaymentSolution
Source§fn clone(&self) -> PaymentSolution
fn clone(&self) -> PaymentSolution
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PaymentSolution
impl Debug for PaymentSolution
Auto Trait Implementations§
impl Freeze for PaymentSolution
impl RefUnwindSafe for PaymentSolution
impl Send for PaymentSolution
impl Sync for PaymentSolution
impl Unpin for PaymentSolution
impl UnwindSafe for PaymentSolution
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
Mutably borrows from an owned value. Read more