Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1.76 KB

README.md

File metadata and controls

50 lines (40 loc) · 1.76 KB

AmortizationScheduleCalculator

Simple library to generate an Amortization Schedule for periodic payments or installments. Using this table can can show you how much will go toward the principal and how much will go toward the interest

CircleCI

Installation

If available in Hex, the package can be installed by adding amortization_schedule_calculator to your list of dependencies in mix.exs:

def deps do
  [
    {:amortization_schedule_calculator, "~> 0.0.1"}
  ]
end

How to Use

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<:USD, 2.99>,
  begin_balance: #Money<:USD, 597.01>,
  end_balance: #Money<:USD, 0.45>,
  month: ~D[2048-10-01],
  monthly_extra_payment: #Money<:USD, 0>,
  one_time_payments: nil,
  pay_off_achieved: false,
  principal: #Money<:USD, 596.56>,
  total_interest_paid: #Money<:USD, 115838.45>,
  total_payment: #Money<:USD, 599.55>,
  total_principal_paid: #Money<:USD, 99999.55>
}

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/amortization_schedule_calculator.