Struct PaymentSolution

Source
pub struct PaymentSolution(/* private fields */);

Implementations§

Source§

impl PaymentSolution

Source

pub fn print_table(&self)

Source

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);
Source

pub fn print_ab_comparison( &self, other: &PaymentSolution, include_running_totals: bool, include_remaining_amounts: bool, )

Source

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>§

Source

pub fn calculated_field(&self) -> &CashflowVariable

Source

pub fn rate(&self) -> f64

Source

pub fn periods(&self) -> u32

Source

pub fn present_value(&self) -> f64

Source

pub fn future_value(&self) -> f64

Source

pub fn due_at_beginning(&self) -> bool

Source

pub fn payment(&self) -> f64

Source

pub fn sum_of_payments(&self) -> f64

Source

pub fn sum_of_interest(&self) -> f64

Source

pub fn formula(&self) -> &str

Source

pub fn symbolic_formula(&self) -> &str

Trait Implementations§

Source§

impl Clone for PaymentSolution

Source§

fn clone(&self) -> PaymentSolution

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PaymentSolution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for PaymentSolution

Source§

type Target = CashflowSolution

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.