FAILURE MAP
← Case archive

FA-59566 / Subscription proration billing / Open access

Credit notes and customer balance on an invoice: balance application cap · case 01

Customers with large balances see negative amounts due and a drained balance.

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

ROOT CAUSE

The balance is applied in full without capping at the remaining due.

VERIFIED REPAIR

Restore the contract rule at the balance application cap step: use `use_bal = min(bal, due)`.

Unsuccessful approach: The attempt caps by the original total, ignoring the credit notes already applied.

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 = bal
    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', {'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]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('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': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('normal control', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('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': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('normal control', {'total': 27004, 'credit_notes': [11844, 8578], 'balance': 0, 'min_payment': 0}, [6582, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 32368, 'credit_notes': [17289, 13095], 'balance': 0, 'min_payment': 0}, [1984, 0, 0]), ('normal control', {'total': 36798, 'credit_notes': [1788], 'balance': 11576, 'min_payment': 50}, [23434, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 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': 34021, 'credit_notes': [12282], 'balance': 0, 'min_payment': 100}, [21739, 0, 0]), ('normal control', {'total': 14007, 'credit_notes': [8643], 'balance': 0, 'min_payment': 50}, [5364, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 9414, 'credit_notes': [5208], 'balance': 5543, 'min_payment': 50}, [0, 1337, 0]), ('boundary control', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 43066, 'credit_notes': [366, 14060, 1522], 'balance': 2601, 'min_payment': 100}, [24517, 0, 0]), ('normal control', {'total': 38060, 'credit_notes': [14975, 2846], 'balance': 13326, 'min_payment': 50}, [6913, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0])], [('regression', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 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': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0]), ('normal control', {'total': 48418, 'credit_notes': [6075], 'balance': 0, 'min_payment': 100}, [42343, 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])]]
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[-2249, 0, 0][0, 2249, 0]Failed
regression 1[-15268, 0, 0][0, 15268, 0]Failed
partial-repair probe 2[-19667, 0, 0][0, 19667, 0]Failed
partial-repair probe 3[-35064, 0, 0][0, 35064, 0]Failed
boundary control 4[50, 0, 0][50, 0, 0]Passed
boundary control 5[50, 0, 0][50, 0, 0]Passed
normal control 6[294, 0, 0][294, 0, 0]Passed
normal control 7[36738, 0, 0][36738, 0, 0]Passed
normal control 8[27156, 0, 0][27156, 0, 0]Passed
normal control 9[4442, 0, 0][4442, 0, 0]Passed

SHA-256 / afd35b13830f150a30aacd6d67816eef2912aa7691e74adafe4abc404d50b8f5

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, x['total'])
    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', {'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]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('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': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('normal control', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('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': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('normal control', {'total': 27004, 'credit_notes': [11844, 8578], 'balance': 0, 'min_payment': 0}, [6582, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 32368, 'credit_notes': [17289, 13095], 'balance': 0, 'min_payment': 0}, [1984, 0, 0]), ('normal control', {'total': 36798, 'credit_notes': [1788], 'balance': 11576, 'min_payment': 50}, [23434, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 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': 34021, 'credit_notes': [12282], 'balance': 0, 'min_payment': 100}, [21739, 0, 0]), ('normal control', {'total': 14007, 'credit_notes': [8643], 'balance': 0, 'min_payment': 50}, [5364, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 9414, 'credit_notes': [5208], 'balance': 5543, 'min_payment': 50}, [0, 1337, 0]), ('boundary control', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 43066, 'credit_notes': [366, 14060, 1522], 'balance': 2601, 'min_payment': 100}, [24517, 0, 0]), ('normal control', {'total': 38060, 'credit_notes': [14975, 2846], 'balance': 13326, 'min_payment': 50}, [6913, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0])], [('regression', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 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': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0]), ('normal control', {'total': 48418, 'credit_notes': [6075], 'balance': 0, 'min_payment': 100}, [42343, 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])]]
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[-53, 2196, 0][0, 2249, 0]Failed
regression 1[-249, 15019, 0][0, 15268, 0]Failed
partial-repair probe 2[-299, 19368, 0][0, 19667, 0]Failed
partial-repair probe 3[-7761, 27303, 0][0, 35064, 0]Failed
boundary control 4[50, 0, 0][50, 0, 0]Passed
boundary control 5[50, 0, 0][50, 0, 0]Passed
normal control 6[294, 0, 0][294, 0, 0]Passed
normal control 7[36738, 0, 0][36738, 0, 0]Passed
normal control 8[27156, 0, 0][27156, 0, 0]Passed
normal control 9[4442, 0, 0][4442, 0, 0]Passed

SHA-256 / 587200e9f48cb2261d092ff9940a3437ce92029b0fd12c091013bbd06c5c99e4

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', {'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]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('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': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('normal control', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('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': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('normal control', {'total': 27004, 'credit_notes': [11844, 8578], 'balance': 0, 'min_payment': 0}, [6582, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 32368, 'credit_notes': [17289, 13095], 'balance': 0, 'min_payment': 0}, [1984, 0, 0]), ('normal control', {'total': 36798, 'credit_notes': [1788], 'balance': 11576, 'min_payment': 50}, [23434, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 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': 34021, 'credit_notes': [12282], 'balance': 0, 'min_payment': 100}, [21739, 0, 0]), ('normal control', {'total': 14007, 'credit_notes': [8643], 'balance': 0, 'min_payment': 50}, [5364, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 9414, 'credit_notes': [5208], 'balance': 5543, 'min_payment': 50}, [0, 1337, 0]), ('boundary control', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 43066, 'credit_notes': [366, 14060, 1522], 'balance': 2601, 'min_payment': 100}, [24517, 0, 0]), ('normal control', {'total': 38060, 'credit_notes': [14975, 2846], 'balance': 13326, 'min_payment': 50}, [6913, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0])], [('regression', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 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': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0]), ('normal control', {'total': 48418, 'credit_notes': [6075], 'balance': 0, 'min_payment': 100}, [42343, 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])]]
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 1[0, 15268, 0][0, 15268, 0]Passed
partial-repair probe 2[0, 19667, 0][0, 19667, 0]Passed
partial-repair probe 3[0, 35064, 0][0, 35064, 0]Passed
boundary control 4[50, 0, 0][50, 0, 0]Passed
boundary control 5[50, 0, 0][50, 0, 0]Passed
normal control 6[294, 0, 0][294, 0, 0]Passed
normal control 7[36738, 0, 0][36738, 0, 0]Passed
normal control 8[27156, 0, 0][27156, 0, 0]Passed
normal control 9[4442, 0, 0][4442, 0, 0]Passed

SHA-256 / 6c63b4f2c21186e752de3fc9f85fcf68f4af19a0e44ed6c0e00eda65026ea2da

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.527013+00:00.

Case digest / 57814293e8b06341b5191b38a144486df15684785ad12557c841fb1b8f287234