FAILURE MAP
← Case archive

FA-58651 / Loan amortization schedules / Open access

Payoff quote with per diem: interest day count · case 01

Payoff quotes charge one extra day of interest.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Both the last paid day and the payoff day are counted.

VERIFIED REPAIR

Charge payoff_day - last_paid_day days.

Unsuccessful approach: Subtracting a day drops the payoff day itself.

Case contract

x = {'balance', 'rate_bp', 'last_paid_day', 'payoff_day', 'basis', 'fees_due', 'escrow' (credit, may be negative), 'penalty_bp', 'penalty_until'}. Per diem = round_half_up(balance*bp/(10000*basis)); interest = per diem * (payoff_day - last_paid_day). Penalty = round_half_up(balance*penalty_bp/10000) when payoff_day <= penalty_until, else 0. Payoff = balance + interest + fees + penalty - escrow. Return {'per_diem', 'interest', 'penalty', 'payoff'}.

Why this case matters

Amortization engines drive borrower statements, payoff quotes and investor remittances; a misplaced rounding step, boundary or ordering rule compounds across hundreds of periods.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    def rnd(n, d):
        q, r = divmod(n, d)
        return q + (1 if 2 * r >= d else 0)
    per_diem = rnd(x['balance'] * x['rate_bp'], 10000 * x['basis'])
    days = x['payoff_day'] - x['last_paid_day'] + 1
    interest = per_diem * days
    penalty = rnd(x['balance'] * x['penalty_bp'], 10000) if x['payoff_day'] <= x['penalty_until'] else 0
    payoff = x['balance'] + interest + x['fees_due'] + penalty - x['escrow']
    return {'per_diem': per_diem, 'interest': interest, 'penalty': penalty, 'payoff': payoff}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: interest day count', {'balance': 100000, 'rate_bp': 600, 'last_paid_day': 100, 'payoff_day': 145, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 0, 'penalty_until': 115}, {'per_diem': 17, 'interest': 765, 'penalty': 0, 'payoff': 108265}], ['sample 1', {'balance': 999999, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 10}, {'per_diem': 164, 'interest': 164, 'penalty': 0, 'payoff': 1000163}], ['sample 2', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 16, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 31}, {'per_diem': 35, 'interest': 525, 'penalty': 1000, 'payoff': 93025}], ['sample 3', {'balance': 12345678, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 41, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 40}, {'per_diem': 2058, 'interest': 63798, 'penalty': 0, 'payoff': 12400976}], ['sample 4', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 55, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 25}, {'per_diem': 1543, 'interest': 69435, 'penalty': 0, 'payoff': 12415113}], ['sample 5', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 41, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 25}, {'per_diem': 2, 'interest': 62, 'penalty': 0, 'payoff': -6938}], ['sample 6', {'balance': 100000, 'rate_bp': 600, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 1}, {'per_diem': 16, 'interest': 720, 'penalty': 0, 'payoff': 88720}]], [['regression: interest day count', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 342, 'interest': 15390, 'penalty': 0, 'payoff': 1022889}], ['sample 1', {'balance': 100000, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 2, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 61}, {'per_diem': 13, 'interest': 13, 'penalty': 2000, 'payoff': 105513}], ['sample 2', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 25, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 10}, {'per_diem': 34, 'interest': 510, 'penalty': 0, 'payoff': 100510}], ['sample 3', {'balance': 999999, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 61}, {'per_diem': 125, 'interest': 3750, 'penalty': 0, 'payoff': 1007249}], ['sample 4', {'balance': 12345678, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 4228, 'interest': 4228, 'penalty': 0, 'payoff': 12337906}], ['sample 5', {'balance': 100000, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 101, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 130}, {'per_diem': 12, 'interest': 12, 'penalty': 2000, 'payoff': 90012}], ['sample 6', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 40}, {'per_diem': 1522, 'interest': 1522, 'penalty': 246914, 'payoff': 12598114}]], [['regression: interest day count', {'balance': 5000, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 55, 'basis': 365, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 1, 'interest': 45, 'penalty': 0, 'payoff': 9045}], ['sample 1', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 31}, {'per_diem': 35, 'interest': 1575, 'penalty': 0, 'payoff': 89575}], ['sample 2', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 25, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 342, 'interest': 5130, 'penalty': 0, 'payoff': 1005129}], ['sample 3', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 16}, {'per_diem': 1543, 'interest': 46290, 'penalty': 0, 'payoff': 12383468}], ['sample 4', {'balance': 12345678, 'rate_bp': 600, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 31}, {'per_diem': 2058, 'interest': 61740, 'penalty': 246914, 'payoff': 12654332}], ['sample 5', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 2, 'basis': 365, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 34, 'interest': 34, 'penalty': 0, 'payoff': 91534}], ['sample 6', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 115}, {'per_diem': 35, 'interest': 1050, 'penalty': 0, 'payoff': 108550}]], [['regression: interest day count', {'balance': 5000, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 40, 'basis': 365, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 70}, {'per_diem': 1, 'interest': 30, 'penalty': 100, 'payoff': 8630}], ['sample 1', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 32, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 1522, 'interest': 47182, 'penalty': 0, 'payoff': 12400360}], ['sample 2', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 16}, {'per_diem': 2, 'interest': 90, 'penalty': 0, 'payoff': -6910}], ['sample 3', {'balance': 5000, 'rate_bp': 600, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 100}, {'per_diem': 1, 'interest': 30, 'penalty': 0, 'payoff': 12530}], ['sample 4', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 360, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 130}, {'per_diem': 347, 'interest': 5205, 'penalty': 20000, 'payoff': 1029204}], ['sample 5', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 365, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 160}, {'per_diem': 2, 'interest': 30, 'penalty': 50, 'payoff': -3420}], ['sample 6', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 61}, {'per_diem': 34, 'interest': 1530, 'penalty': 0, 'payoff': 101530}]], [['regression: interest day count', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 131, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 115}, {'per_diem': 347, 'interest': 10757, 'penalty': 0, 'payoff': 1014256}], ['sample 1', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 160}, {'per_diem': 1543, 'interest': 23145, 'penalty': 123457, 'payoff': 12495780}], ['sample 2', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 101, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 130}, {'per_diem': 1522, 'interest': 1522, 'penalty': 123457, 'payoff': 12478157}], ['sample 3', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 130}, {'per_diem': 1522, 'interest': 45660, 'penalty': 0, 'payoff': 12379338}], ['sample 4', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 1}, {'per_diem': 1543, 'interest': 46290, 'penalty': 0, 'payoff': 12399468}], ['sample 5', {'balance': 999999, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 40, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 70}, {'per_diem': 167, 'interest': 5010, 'penalty': 0, 'payoff': 1005009}], ['sample 6', {'balance': 999999, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 16}, {'per_diem': 125, 'interest': 3750, 'penalty': 0, 'payoff': 1007749}]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: interest day count{'interest': 782, 'payoff': 108282, 'penalty': 0, 'per_diem': 17}{'interest': 765, 'payoff': 108265, 'penalty': 0, 'per_diem': 17}Failed
sample 1{'interest': 328, 'payoff': 1000327, 'penalty': 0, 'per_diem': 164}{'interest': 164, 'payoff': 1000163, 'penalty': 0, 'per_diem': 164}Failed
sample 2{'interest': 560, 'payoff': 93060, 'penalty': 1000, 'per_diem': 35}{'interest': 525, 'payoff': 93025, 'penalty': 1000, 'per_diem': 35}Failed
sample 3{'interest': 65856, 'payoff': 12403034, 'penalty': 0, 'per_diem': 2058}{'interest': 63798, 'payoff': 12400976, 'penalty': 0, 'per_diem': 2058}Failed
sample 4{'interest': 70978, 'payoff': 12416656, 'penalty': 0, 'per_diem': 1543}{'interest': 69435, 'payoff': 12415113, 'penalty': 0, 'per_diem': 1543}Failed
sample 5{'interest': 64, 'payoff': -6936, 'penalty': 0, 'per_diem': 2}{'interest': 62, 'payoff': -6938, 'penalty': 0, 'per_diem': 2}Failed
sample 6{'interest': 736, 'payoff': 88736, 'penalty': 0, 'per_diem': 16}{'interest': 720, 'payoff': 88720, 'penalty': 0, 'per_diem': 16}Failed

SHA-256 / 885da1d08376d7ed663e1f95624bdfdf23dd7544c659f366d414c4f4c84f8f66

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    def rnd(n, d):
        q, r = divmod(n, d)
        return q + (1 if 2 * r >= d else 0)
    per_diem = rnd(x['balance'] * x['rate_bp'], 10000 * x['basis'])
    days = x['payoff_day'] - x['last_paid_day'] - 1
    interest = per_diem * days
    penalty = rnd(x['balance'] * x['penalty_bp'], 10000) if x['payoff_day'] <= x['penalty_until'] else 0
    payoff = x['balance'] + interest + x['fees_due'] + penalty - x['escrow']
    return {'per_diem': per_diem, 'interest': interest, 'penalty': penalty, 'payoff': payoff}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: interest day count', {'balance': 100000, 'rate_bp': 600, 'last_paid_day': 100, 'payoff_day': 145, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 0, 'penalty_until': 115}, {'per_diem': 17, 'interest': 765, 'penalty': 0, 'payoff': 108265}], ['sample 1', {'balance': 999999, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 10}, {'per_diem': 164, 'interest': 164, 'penalty': 0, 'payoff': 1000163}], ['sample 2', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 16, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 31}, {'per_diem': 35, 'interest': 525, 'penalty': 1000, 'payoff': 93025}], ['sample 3', {'balance': 12345678, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 41, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 40}, {'per_diem': 2058, 'interest': 63798, 'penalty': 0, 'payoff': 12400976}], ['sample 4', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 55, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 25}, {'per_diem': 1543, 'interest': 69435, 'penalty': 0, 'payoff': 12415113}], ['sample 5', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 41, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 25}, {'per_diem': 2, 'interest': 62, 'penalty': 0, 'payoff': -6938}], ['sample 6', {'balance': 100000, 'rate_bp': 600, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 1}, {'per_diem': 16, 'interest': 720, 'penalty': 0, 'payoff': 88720}]], [['regression: interest day count', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 342, 'interest': 15390, 'penalty': 0, 'payoff': 1022889}], ['sample 1', {'balance': 100000, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 2, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 61}, {'per_diem': 13, 'interest': 13, 'penalty': 2000, 'payoff': 105513}], ['sample 2', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 25, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 10}, {'per_diem': 34, 'interest': 510, 'penalty': 0, 'payoff': 100510}], ['sample 3', {'balance': 999999, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 61}, {'per_diem': 125, 'interest': 3750, 'penalty': 0, 'payoff': 1007249}], ['sample 4', {'balance': 12345678, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 4228, 'interest': 4228, 'penalty': 0, 'payoff': 12337906}], ['sample 5', {'balance': 100000, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 101, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 130}, {'per_diem': 12, 'interest': 12, 'penalty': 2000, 'payoff': 90012}], ['sample 6', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 40}, {'per_diem': 1522, 'interest': 1522, 'penalty': 246914, 'payoff': 12598114}]], [['regression: interest day count', {'balance': 5000, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 55, 'basis': 365, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 1, 'interest': 45, 'penalty': 0, 'payoff': 9045}], ['sample 1', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 31}, {'per_diem': 35, 'interest': 1575, 'penalty': 0, 'payoff': 89575}], ['sample 2', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 25, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 342, 'interest': 5130, 'penalty': 0, 'payoff': 1005129}], ['sample 3', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 16}, {'per_diem': 1543, 'interest': 46290, 'penalty': 0, 'payoff': 12383468}], ['sample 4', {'balance': 12345678, 'rate_bp': 600, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 31}, {'per_diem': 2058, 'interest': 61740, 'penalty': 246914, 'payoff': 12654332}], ['sample 5', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 2, 'basis': 365, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 34, 'interest': 34, 'penalty': 0, 'payoff': 91534}], ['sample 6', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 115}, {'per_diem': 35, 'interest': 1050, 'penalty': 0, 'payoff': 108550}]], [['regression: interest day count', {'balance': 5000, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 40, 'basis': 365, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 70}, {'per_diem': 1, 'interest': 30, 'penalty': 100, 'payoff': 8630}], ['sample 1', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 32, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 1522, 'interest': 47182, 'penalty': 0, 'payoff': 12400360}], ['sample 2', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 16}, {'per_diem': 2, 'interest': 90, 'penalty': 0, 'payoff': -6910}], ['sample 3', {'balance': 5000, 'rate_bp': 600, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 100}, {'per_diem': 1, 'interest': 30, 'penalty': 0, 'payoff': 12530}], ['sample 4', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 360, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 130}, {'per_diem': 347, 'interest': 5205, 'penalty': 20000, 'payoff': 1029204}], ['sample 5', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 365, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 160}, {'per_diem': 2, 'interest': 30, 'penalty': 50, 'payoff': -3420}], ['sample 6', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 61}, {'per_diem': 34, 'interest': 1530, 'penalty': 0, 'payoff': 101530}]], [['regression: interest day count', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 131, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 115}, {'per_diem': 347, 'interest': 10757, 'penalty': 0, 'payoff': 1014256}], ['sample 1', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 160}, {'per_diem': 1543, 'interest': 23145, 'penalty': 123457, 'payoff': 12495780}], ['sample 2', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 101, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 130}, {'per_diem': 1522, 'interest': 1522, 'penalty': 123457, 'payoff': 12478157}], ['sample 3', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 130}, {'per_diem': 1522, 'interest': 45660, 'penalty': 0, 'payoff': 12379338}], ['sample 4', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 1}, {'per_diem': 1543, 'interest': 46290, 'penalty': 0, 'payoff': 12399468}], ['sample 5', {'balance': 999999, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 40, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 70}, {'per_diem': 167, 'interest': 5010, 'penalty': 0, 'payoff': 1005009}], ['sample 6', {'balance': 999999, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 16}, {'per_diem': 125, 'interest': 3750, 'penalty': 0, 'payoff': 1007749}]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: interest day count{'interest': 748, 'payoff': 108248, 'penalty': 0, 'per_diem': 17}{'interest': 765, 'payoff': 108265, 'penalty': 0, 'per_diem': 17}Failed
sample 1{'interest': 0, 'payoff': 999999, 'penalty': 0, 'per_diem': 164}{'interest': 164, 'payoff': 1000163, 'penalty': 0, 'per_diem': 164}Failed
sample 2{'interest': 490, 'payoff': 92990, 'penalty': 1000, 'per_diem': 35}{'interest': 525, 'payoff': 93025, 'penalty': 1000, 'per_diem': 35}Failed
sample 3{'interest': 61740, 'payoff': 12398918, 'penalty': 0, 'per_diem': 2058}{'interest': 63798, 'payoff': 12400976, 'penalty': 0, 'per_diem': 2058}Failed
sample 4{'interest': 67892, 'payoff': 12413570, 'penalty': 0, 'per_diem': 1543}{'interest': 69435, 'payoff': 12415113, 'penalty': 0, 'per_diem': 1543}Failed
sample 5{'interest': 60, 'payoff': -6940, 'penalty': 0, 'per_diem': 2}{'interest': 62, 'payoff': -6938, 'penalty': 0, 'per_diem': 2}Failed
sample 6{'interest': 704, 'payoff': 88704, 'penalty': 0, 'per_diem': 16}{'interest': 720, 'payoff': 88720, 'penalty': 0, 'per_diem': 16}Failed

SHA-256 / 85e27ebaa550b5c772f5f30651233e810c462337e1b02b46479322e9197675dd

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    def rnd(n, d):
        q, r = divmod(n, d)
        return q + (1 if 2 * r >= d else 0)
    per_diem = rnd(x['balance'] * x['rate_bp'], 10000 * x['basis'])
    days = x['payoff_day'] - x['last_paid_day']
    interest = per_diem * days
    penalty = rnd(x['balance'] * x['penalty_bp'], 10000) if x['payoff_day'] <= x['penalty_until'] else 0
    payoff = x['balance'] + interest + x['fees_due'] + penalty - x['escrow']
    return {'per_diem': per_diem, 'interest': interest, 'penalty': penalty, 'payoff': payoff}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: interest day count', {'balance': 100000, 'rate_bp': 600, 'last_paid_day': 100, 'payoff_day': 145, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 0, 'penalty_until': 115}, {'per_diem': 17, 'interest': 765, 'penalty': 0, 'payoff': 108265}], ['sample 1', {'balance': 999999, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 10}, {'per_diem': 164, 'interest': 164, 'penalty': 0, 'payoff': 1000163}], ['sample 2', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 16, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 31}, {'per_diem': 35, 'interest': 525, 'penalty': 1000, 'payoff': 93025}], ['sample 3', {'balance': 12345678, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 41, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 40}, {'per_diem': 2058, 'interest': 63798, 'penalty': 0, 'payoff': 12400976}], ['sample 4', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 55, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 25}, {'per_diem': 1543, 'interest': 69435, 'penalty': 0, 'payoff': 12415113}], ['sample 5', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 41, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 25}, {'per_diem': 2, 'interest': 62, 'penalty': 0, 'payoff': -6938}], ['sample 6', {'balance': 100000, 'rate_bp': 600, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 1}, {'per_diem': 16, 'interest': 720, 'penalty': 0, 'payoff': 88720}]], [['regression: interest day count', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 342, 'interest': 15390, 'penalty': 0, 'payoff': 1022889}], ['sample 1', {'balance': 100000, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 2, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 61}, {'per_diem': 13, 'interest': 13, 'penalty': 2000, 'payoff': 105513}], ['sample 2', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 25, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 10}, {'per_diem': 34, 'interest': 510, 'penalty': 0, 'payoff': 100510}], ['sample 3', {'balance': 999999, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 61}, {'per_diem': 125, 'interest': 3750, 'penalty': 0, 'payoff': 1007249}], ['sample 4', {'balance': 12345678, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 4228, 'interest': 4228, 'penalty': 0, 'payoff': 12337906}], ['sample 5', {'balance': 100000, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 101, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 200, 'penalty_until': 130}, {'per_diem': 12, 'interest': 12, 'penalty': 2000, 'payoff': 90012}], ['sample 6', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 11, 'basis': 365, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 40}, {'per_diem': 1522, 'interest': 1522, 'penalty': 246914, 'payoff': 12598114}]], [['regression: interest day count', {'balance': 5000, 'rate_bp': 450, 'last_paid_day': 10, 'payoff_day': 55, 'basis': 365, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 1, 'interest': 45, 'penalty': 0, 'payoff': 9045}], ['sample 1', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 31}, {'per_diem': 35, 'interest': 1575, 'penalty': 0, 'payoff': 89575}], ['sample 2', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 10, 'payoff_day': 25, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 40}, {'per_diem': 342, 'interest': 5130, 'penalty': 0, 'payoff': 1005129}], ['sample 3', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 16}, {'per_diem': 1543, 'interest': 46290, 'penalty': 0, 'payoff': 12383468}], ['sample 4', {'balance': 12345678, 'rate_bp': 600, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 31}, {'per_diem': 2058, 'interest': 61740, 'penalty': 246914, 'payoff': 12654332}], ['sample 5', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 2, 'basis': 365, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 34, 'interest': 34, 'penalty': 0, 'payoff': 91534}], ['sample 6', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 115}, {'per_diem': 35, 'interest': 1050, 'penalty': 0, 'payoff': 108550}]], [['regression: interest day count', {'balance': 5000, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 40, 'basis': 365, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 200, 'penalty_until': 70}, {'per_diem': 1, 'interest': 30, 'penalty': 100, 'payoff': 8630}], ['sample 1', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 32, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 1}, {'per_diem': 1522, 'interest': 47182, 'penalty': 0, 'payoff': 12400360}], ['sample 2', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 360, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 16}, {'per_diem': 2, 'interest': 90, 'penalty': 0, 'payoff': -6910}], ['sample 3', {'balance': 5000, 'rate_bp': 600, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 100}, {'per_diem': 1, 'interest': 30, 'penalty': 0, 'payoff': 12530}], ['sample 4', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 360, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 130}, {'per_diem': 347, 'interest': 5205, 'penalty': 20000, 'payoff': 1029204}], ['sample 5', {'balance': 5000, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 365, 'fees_due': 3500, 'escrow': 12000, 'penalty_bp': 100, 'penalty_until': 160}, {'per_diem': 2, 'interest': 30, 'penalty': 50, 'payoff': -3420}], ['sample 6', {'balance': 100000, 'rate_bp': 1250, 'last_paid_day': 1, 'payoff_day': 46, 'basis': 365, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 61}, {'per_diem': 34, 'interest': 1530, 'penalty': 0, 'payoff': 101530}]], [['regression: interest day count', {'balance': 999999, 'rate_bp': 1250, 'last_paid_day': 100, 'payoff_day': 131, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 115}, {'per_diem': 347, 'interest': 10757, 'penalty': 0, 'payoff': 1014256}], ['sample 1', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 115, 'basis': 360, 'fees_due': 3500, 'escrow': 0, 'penalty_bp': 100, 'penalty_until': 160}, {'per_diem': 1543, 'interest': 23145, 'penalty': 123457, 'payoff': 12495780}], ['sample 2', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 101, 'basis': 365, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 100, 'penalty_until': 130}, {'per_diem': 1522, 'interest': 1522, 'penalty': 123457, 'payoff': 12478157}], ['sample 3', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 100, 'payoff_day': 130, 'basis': 365, 'fees_due': 0, 'escrow': 12000, 'penalty_bp': 0, 'penalty_until': 130}, {'per_diem': 1522, 'interest': 45660, 'penalty': 0, 'payoff': 12379338}], ['sample 4', {'balance': 12345678, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 3500, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 1}, {'per_diem': 1543, 'interest': 46290, 'penalty': 0, 'payoff': 12399468}], ['sample 5', {'balance': 999999, 'rate_bp': 600, 'last_paid_day': 10, 'payoff_day': 40, 'basis': 360, 'fees_due': 0, 'escrow': 0, 'penalty_bp': 0, 'penalty_until': 70}, {'per_diem': 167, 'interest': 5010, 'penalty': 0, 'payoff': 1005009}], ['sample 6', {'balance': 999999, 'rate_bp': 450, 'last_paid_day': 1, 'payoff_day': 31, 'basis': 360, 'fees_due': 0, 'escrow': -4000, 'penalty_bp': 200, 'penalty_until': 16}, {'per_diem': 125, 'interest': 3750, 'penalty': 0, 'payoff': 1007749}]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: interest day count{'interest': 765, 'payoff': 108265, 'penalty': 0, 'per_diem': 17}{'interest': 765, 'payoff': 108265, 'penalty': 0, 'per_diem': 17}Passed
sample 1{'interest': 164, 'payoff': 1000163, 'penalty': 0, 'per_diem': 164}{'interest': 164, 'payoff': 1000163, 'penalty': 0, 'per_diem': 164}Passed
sample 2{'interest': 525, 'payoff': 93025, 'penalty': 1000, 'per_diem': 35}{'interest': 525, 'payoff': 93025, 'penalty': 1000, 'per_diem': 35}Passed
sample 3{'interest': 63798, 'payoff': 12400976, 'penalty': 0, 'per_diem': 2058}{'interest': 63798, 'payoff': 12400976, 'penalty': 0, 'per_diem': 2058}Passed
sample 4{'interest': 69435, 'payoff': 12415113, 'penalty': 0, 'per_diem': 1543}{'interest': 69435, 'payoff': 12415113, 'penalty': 0, 'per_diem': 1543}Passed
sample 5{'interest': 62, 'payoff': -6938, 'penalty': 0, 'per_diem': 2}{'interest': 62, 'payoff': -6938, 'penalty': 0, 'per_diem': 2}Passed
sample 6{'interest': 720, 'payoff': 88720, 'penalty': 0, 'per_diem': 16}{'interest': 720, 'payoff': 88720, 'penalty': 0, 'per_diem': 16}Passed

SHA-256 / 8441ee93cbae314f48f9092ed8db683ba49104cfb5912304e2b239badef88343

Verification & scope

A deterministic bounded teaching model with stipulated toy lending rules stated in the contract; money is integer cents and rates are basis points; it makes no claim of conformance to any regulation, servicing standard or product. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:46:28.744260+00:00.

Case digest / 334cebe43979a258f36acf0df688177d38d684df0ac9e1e6f15f308306ff18d4