finanza/interest/amortization

Amortization schedule generation for an amortising loan.

The schedule lists, for each period, the periodic payment, the portion of that payment that goes to interest, the portion that reduces principal, and the resulting outstanding balance.

Types

One line of an amortisation schedule. Inspect with the accessors: index, payment, interest, principal_paid, balance.

pub opaque type Period

Values

pub fn balance(p p: Period) -> decimal.Decimal

Remaining balance after this period.

pub fn index(p p: Period) -> Int

1-based period number.

pub fn interest(p p: Period) -> decimal.Decimal

Interest component of the payment.

pub fn payment(p p: Period) -> decimal.Decimal

Total payment for this period.

pub fn principal_paid(p p: Period) -> decimal.Decimal

Principal component of the payment.

pub fn schedule(
  principal principal: decimal.Decimal,
  rate_per_period rate_per_period: decimal.Decimal,
  periods periods: Int,
  digits digits: Int,
) -> Result(List(Period), interest.InterestError)

Build a full amortisation schedule for an amortising loan.

Each row in the returned list is a Period. All monetary values are rounded to digits decimal places with HalfEven. The final row is adjusted so the outstanding balance closes to zero exactly.

Search Document