amortization_schedule_calculator v0.0.1 AmortizationScheduleCalculator
A library created to calculate a loan amortization schedule.
Link to this section Summary
Functions
Calculates the Amortization Schedule given a start monthly, total amount, interest rate and term in months
Link to this section Types
Link to this type
t()
t() :: %AmortizationScheduleCalculator{ annual_interest_rate: annual_interest_rate(), loan_amount: Decimal.t(), monthly_extra_payment: monthly_payment(), one_time_extra_payments: one_time_extra_payments(), start_date: start_date(), term_in_months: term_in_months() }
Link to this section Functions
Link to this function
run(params)
run(t()) :: [ %AmortizationScheduleCalculator.ScheduleLine{ interest: term(), loan_amount: term(), month: term(), monthly_extra_payment: term(), one_time_payments: term(), pay_off_achieved: term(), principal: term(), total_interest_paid: term(), total_payment: term(), total_principal_paid: term() } ]
Calculates the Amortization Schedule given a start monthly, total amount, interest rate and term in months.
Examples
iex> start = Timex.parse!("10/02/2018", "%m/%d/%Y", :strftime) |> Timex.to_date
iex> loan = Money.new(:usd, 100000)
iex> rate = Decimal.new(0.06)
iex> term_in_months = 360
iex> %AmortizationScheduleCalculator{loan_amount: loan, annual_interest_rate: rate, start_date: start, term_in_months: 360} |> AmortizationScheduleCalculator.run |> List.last
%AmortizationScheduleCalculator.ScheduleLine{
interest: Money.new(:USD, "2.99"),
loan_amount: Money.new(:USD, "0.45"),
month: ~D[2048-10-01],
monthly_extra_payment: Money.new(:USD, "0"),
one_time_payments: nil,
pay_off_achieved: false,
principal: Money.new(:USD, "596.56"),
total_interest_paid: Money.new(:USD, "115838.45"),
total_payment: Money.new(:USD, "599.55"),
total_principal_paid: Money.new(:USD, "99999.55")
}