FAILURE MAP
← Case archive

FA-59576 / Subscription proration billing / Open access

Credit notes and customer balance on an invoice: remaining balance update · case 01

Customer balances after invoicing are wrong whenever credit notes were applied.

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

ROOT CAUSE

The balance is reduced by the credit-note amount applied instead of the balance amount applied.

VERIFIED REPAIR

Restore the contract rule at the remaining balance update step: use `bal -= use_bal`.

Unsuccessful approach: The attempt recomputes from the starting balance, dropping the credit-note excess added to it.

Case contract

Input {total, credit_notes, balance, min_payment}. Credit notes apply first, capped at the total; any excess credit-note value joins the customer balance. The balance then applies up to the remaining due. A remaining due above 0 but below min_payment is carried to the next invoice instead of charged. Return [due, balance_after, carried].

Why this case matters

Proration credits land as credit notes and balances whose application order determines the charge.

1 / The failure

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

N = 1
observations = []
def solve(x):
    due = x['total']
    cn = sum(x['credit_notes'])
    use_cn = min(cn, due)
    due -= use_cn
    bal = x['balance'] + (cn - use_cn)
    use_bal = min(bal, due)
    due -= use_bal
    bal -= use_cn
    carried = 0
    if 0 < due < x['min_payment']:
        carried = due
        due = 0
    return [due, bal, carried]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression (boundary)', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression (boundary)', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0]), ('normal control', {'total': 165, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [165, 0, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('partial-repair probe', {'total': 14659, 'credit_notes': [16457, 12670], 'balance': 0, 'min_payment': 50}, [0, 14468, 0]), ('partial-repair probe', {'total': 62, 'credit_notes': [3609], 'balance': 0, 'min_payment': 0}, [0, 3547, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [192, 0, 0]), ('normal control', {'total': 291, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [291, 0, 0]), ('normal control', {'total': 237, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [237, 0, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression (boundary)', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('partial-repair probe', {'total': 10727, 'credit_notes': [13715], 'balance': 0, 'min_payment': 100}, [0, 2988, 0]), ('partial-repair probe', {'total': 211, 'credit_notes': [560, 8068, 6056], 'balance': 0, 'min_payment': 50}, [0, 14473, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 57, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [57, 0, 0]), ('normal control', {'total': 11, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 11]), ('normal control', {'total': 103, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [103, 0, 0]), ('normal control', {'total': 18761, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [18761, 0, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), 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 0[0, 2196, 0][0, 2249, 0]Failed
regression (boundary) 1[50, -1000, 0][50, 0, 0]Failed
partial-repair probe 2[0, 15019, 0][0, 15268, 0]Failed
partial-repair probe 3[0, 19368, 0][0, 19667, 0]Failed
boundary control 4[50, 0, 0][50, 0, 0]Passed
boundary control 5[0, 0, 40][0, 0, 40]Passed
normal control 6[294, 0, 0][294, 0, 0]Passed
normal control 7[36738, 0, 0][36738, 0, 0]Passed
normal control 8[2985, 0, 0][2985, 0, 0]Passed
normal control 9[79, 0, 0][79, 0, 0]Passed

SHA-256 / e95bdf2da28c976dd7a51781da7dc47c84ebb057213dc091f557abcb73e27b0c

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    due = x['total']
    cn = sum(x['credit_notes'])
    use_cn = min(cn, due)
    due -= use_cn
    bal = x['balance'] + (cn - use_cn)
    use_bal = min(bal, due)
    due -= use_bal
    bal = x['balance'] - use_bal
    carried = 0
    if 0 < due < x['min_payment']:
        carried = due
        due = 0
    return [due, bal, carried]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression (boundary)', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression (boundary)', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0]), ('normal control', {'total': 165, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [165, 0, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('partial-repair probe', {'total': 14659, 'credit_notes': [16457, 12670], 'balance': 0, 'min_payment': 50}, [0, 14468, 0]), ('partial-repair probe', {'total': 62, 'credit_notes': [3609], 'balance': 0, 'min_payment': 0}, [0, 3547, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [192, 0, 0]), ('normal control', {'total': 291, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [291, 0, 0]), ('normal control', {'total': 237, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [237, 0, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression (boundary)', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('partial-repair probe', {'total': 10727, 'credit_notes': [13715], 'balance': 0, 'min_payment': 100}, [0, 2988, 0]), ('partial-repair probe', {'total': 211, 'credit_notes': [560, 8068, 6056], 'balance': 0, 'min_payment': 50}, [0, 14473, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 57, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [57, 0, 0]), ('normal control', {'total': 11, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 11]), ('normal control', {'total': 103, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [103, 0, 0]), ('normal control', {'total': 18761, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [18761, 0, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), 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 0[0, 0, 0][0, 2249, 0]Failed
regression (boundary) 1[50, 0, 0][50, 0, 0]Passed
partial-repair probe 2[0, 0, 0][0, 15268, 0]Failed
partial-repair probe 3[0, 0, 0][0, 19667, 0]Failed
boundary control 4[50, 0, 0][50, 0, 0]Passed
boundary control 5[0, 0, 40][0, 0, 40]Passed
normal control 6[294, 0, 0][294, 0, 0]Passed
normal control 7[36738, 0, 0][36738, 0, 0]Passed
normal control 8[2985, 0, 0][2985, 0, 0]Passed
normal control 9[79, 0, 0][79, 0, 0]Passed

SHA-256 / fdc1eaf26074a848bf762c7abeadb0e727102b0ade7e10099e5c28b1833f3312

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    due = x['total']
    cn = sum(x['credit_notes'])
    use_cn = min(cn, due)
    due -= use_cn
    bal = x['balance'] + (cn - use_cn)
    use_bal = min(bal, due)
    due -= use_bal
    bal -= use_bal
    carried = 0
    if 0 < due < x['min_payment']:
        carried = due
        due = 0
    return [due, bal, carried]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression (boundary)', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression (boundary)', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0]), ('normal control', {'total': 165, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [165, 0, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('partial-repair probe', {'total': 14659, 'credit_notes': [16457, 12670], 'balance': 0, 'min_payment': 50}, [0, 14468, 0]), ('partial-repair probe', {'total': 62, 'credit_notes': [3609], 'balance': 0, 'min_payment': 0}, [0, 3547, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [192, 0, 0]), ('normal control', {'total': 291, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [291, 0, 0]), ('normal control', {'total': 237, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [237, 0, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression (boundary)', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('partial-repair probe', {'total': 10727, 'credit_notes': [13715], 'balance': 0, 'min_payment': 100}, [0, 2988, 0]), ('partial-repair probe', {'total': 211, 'credit_notes': [560, 8068, 6056], 'balance': 0, 'min_payment': 50}, [0, 14473, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 57, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [57, 0, 0]), ('normal control', {'total': 11, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 11]), ('normal control', {'total': 103, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [103, 0, 0]), ('normal control', {'total': 18761, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [18761, 0, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), 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 0[0, 2249, 0][0, 2249, 0]Passed
regression (boundary) 1[50, 0, 0][50, 0, 0]Passed
partial-repair probe 2[0, 15268, 0][0, 15268, 0]Passed
partial-repair probe 3[0, 19667, 0][0, 19667, 0]Passed
boundary control 4[50, 0, 0][50, 0, 0]Passed
boundary control 5[0, 0, 40][0, 0, 40]Passed
normal control 6[294, 0, 0][294, 0, 0]Passed
normal control 7[36738, 0, 0][36738, 0, 0]Passed
normal control 8[2985, 0, 0][2985, 0, 0]Passed
normal control 9[79, 0, 0][79, 0, 0]Passed

SHA-256 / fe8819d1b3fdd3b69b950cf4f2dc642202d9ee7cd77f2c57afa63d366b974306

Verification & scope

A deterministic teaching model of a stipulated billing rule. It makes no claim to reproduce any billing provider's exact behaviour and is not billing software. 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:37.597367+00:00.

Case digest / 7baf833cb14df7931572d2aa04ba8d4e506b8bde43fd6eeea49f1e69a5c93f36