Calendar math is hard (so the engine has golden tests)
The heart of PayDown is a pure TypeScript payoff engine with zero app dependencies — the same math runs on the phone and, later, on the web.
Originally published at getpaydown.com ↗
The heart of PayDown is a pure TypeScript payoff engine with zero app dependencies — the same math runs on the phone and, later, on the web.
It works in whole days: no timezones, no DST, no clock. Dates are stored as integers. That sounds academic until you see the bugs it surfaced during the build:
- The weekday off-by-one. Twice, "biweekly on Friday" landed on Thursday because of a wrong assumption about which day is day zero. Claude fixed it with tests pinned to calendar truth — dates a human can verify against a wall calendar.
- Month-end drift. A payment anchored to Jan 31 must hit Feb 28, then Mar 31 — not slide to the 28th forever. Anchor-preserving month math handles it.
Every projection — daily interest accrual, extra-payment cascades, freed-minimum rollovers — is pinned against an independent Python implementation Claude wrote separately. Dates must match exactly; interest within a dollar. If the two ever disagree, a test fails.
The rule that came out of this build: AI parses, deterministic code computes. Always.