Special projects

LoanPlan

Loan repayment schedules in whole cents: annuity, differentiated and interest-only, three day-count bases and early repayments. The last payment carries no rounding tail.

Type
Calculation library
Stack
C++ · CLI
Code
Open on GitHub
Year
2026

A schedule calculating machine

A stack of coins is the balance owed. Each turn of the crank prints a row: interest, principal and the new balance. The last row empties the stack exactly, with no tail.

LOANPLAN
The printing head and the fresh row: the parts to watchThe coin stack is the balance owed; one coin is 5,000 ₽The tape: each row holds interest, principal and balance; a diamond at the edge is an early repaymentA tabletop model of the calculation in LoanPlan, a C++ library with a CLI that builds loan repayment schedules. Amounts are whole cents, and interest is computed with integers and rounded once per period. Here the loan is 250,000.00 ₽ over 24 months at 14.5 % a year, annuity; a month’s interest is the balance × 14.5 % ÷ 12, with half a kopeck rounded up (the library adds three day-count bases: Actual/365, Actual/360 and 30E/360). The payment is the smallest whole-kopeck amount that repays the loan on time: a binary search finds it using the same calculation that prints the tape. Each crank turn is one month: the head prints interest, principal and balance while the coin stack (5,000 ₽ a coin) shrinks. An early repayment of 40,000.00 ₽ lifts a whole column of coins at once, and in this model the payment is recomputed for the remaining term. The last row empties the balance exactly, with no rounding tail.

Money without fractions

Amounts are stored as whole cents, and interest is computed with integers and rounded once per period. The annuity payment is the smallest whole-cent amount that repays the loan on time: a binary search finds it using the same calculation that prints the table.

Invariants

Each opening balance equals the previous closing balance, the final balance is zero, and principal paid plus early repayments equals the amount lent. A schedule starting on 31 January moves to 29 February and back to 31 March.

Under the hood

  • Annuity, differentiated and interest-only.
  • Actual/365, Actual/360 and 30E/360 day counts.
  • Early repayments and a fixed fee.
  • 1 to 1,200 months, JSON in and out.
  • Integer arithmetic with no floats.
Code on GitHub

Shall we talk about your project?

Discuss your project