How the Decision tools debt payoff planner calculator is verified

Inputs

InputFieldType
Your debtsdebtsarray
Total you can pay each monthmonthlyBudgetnumber
Which debt gets the extra moneystrategystring

The formula

Each derived value below is computed by the Valem engine from the expression shown, in this order. Nothing else runs — there is no hidden code path.

Derived valueFieldFormula (JSONata)
Total owed todaytotalBalance$round($sum($map(debts, function($d) { $d.balance })), 2)
Total MinimumstotalMinimums$round($sum($map(debts, function($d) { $d.minPayment })), 2)
Avalancheavalanche$simulate($sort(debts, function($x, $y) { $x.aprPct < $y.aprPct }), monthlyBudget, $const.maxMonths)
Snowballsnowball$simulate($sort(debts, function($x, $y) { $x.balance > $y.balance }), monthlyBudget, $const.maxMonths)
Months to debt freemonthsToFree( $s := strategy = "snowball" ? snowball : avalanche; $s.months )
Interest you paytotalInterest( $s := strategy = "snowball" ? snowball : avalanche; $s.interest )
Payoff OrderpayoffOrder( $s := strategy = "snowball" ? snowball : avalanche; $join($s.order, " → ") )
Avalanche savesinterestSaved( $s := snowball; $a := avalanche; $round($s.interest - $a.interest, 2) )
Clears In HorizonclearsInHorizon( $s := strategy = "snowball" ? snowball : avalanche; $s.cleared )
What you still owe, month by monthschedule( $s := strategy = "snowball" ? snowball : avalanche; [$s.history] )

Rates and thresholds

The expressions above read these as $const. They are the figures the annual refresh replaces, so they live as data rather than being written into the formulas — which is what makes a year-on-year change a one-line diff instead of an edit to arithmetic.

ConstantValue
maxMonths120

Test vectors (3)

Every case is executed against this model on each build, by the Java engine and independently by a JavaScript one. A mismatch of a single cent fails the build, so the page cannot ship advertising a figure the model no longer produces.

Case 1 — three debts totalling 11,500 on a 600 budget, avalanche — highest rate first

given monthlyBudget600
given strategyavalanche
expect totalBalance11500
expect totalMinimums265
expect monthsToFree23
expect totalInterest1509.23
expect clearsInHorizontrue
expect interestSaved112.56
expect schedule[0].interest142.5
expect schedule[0].balance11042.5
expect schedule[22].balance0

Case 2 — the same debts on snowball — clears in the same 23 months but costs 112.56 more in interest

given monthlyBudget600
given strategysnowball
expect monthsToFree23
expect totalInterest1621.79
expect interestSaved112.56

Case 3 — paying only the minimums stretches it to 66 months and nearly quadruples the interest

given monthlyBudget265
given strategyavalanche
expect monthsToFree66
expect totalInterest5876.6
expect interestSaved30.42
expect clearsInHorizontrue

Sources

Check it yourself — and reuse it

The whole model as JSON — inputs, outputs, formulas, vectors and sources in one re-runnable document.

This model is published under CC BY 4.0: use it, adapt it, build on it, with attribution. The licence covers the model — the expression of each rule and the arrangement of the catalog. The rates and thresholds are law, and nobody licenses those; the sources above are where they come from.

← Back to the Decision tools debt payoff planner calculator

Built with Valem — a live, verifiable calculator you can fork and embed.