{"abstract":"Credit notes larger than the invoice lose their excess value.","category":"Subscription proration billing","checks":10,"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].","evaluation_group":"w2-subscription-proration-credit-balance-application","failed_approach":"The attempt adds the full credit-note value to the balance, double counting the applied part.","family":"w2-subscription-proration-credit-balance-application-excess-credit-note-to-balance","id":"FA-59561","implementations":{"attempt":{"sha256":"374ec9e34ce74c3882cf9a8cfaf2c53f4d4fd7c17d96c2f521ce1a048a0187e5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    due = x['total']\n    cn = sum(x['credit_notes'])\n    use_cn = min(cn, due)\n    due -= use_cn\n    bal = x['balance'] + cn\n    use_bal = min(bal, due)\n    due -= use_bal\n    bal -= use_bal\n    carried = 0\n    if 0 < due < x['min_payment']:\n        carried = due\n        due = 0\n    return [due, bal, carried]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('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 (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 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': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe (boundary)', {'total': 520, 'credit_notes': [300], 'balance': 199, 'min_payment': 50}, [0, 0, 21]), ('partial-repair probe', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 18, 'credit_notes': [], 'balance': 23152, 'min_payment': 0}, [0, 23134, 0]), ('normal control', {'total': 1, 'credit_notes': [], 'balance': 25350, 'min_payment': 50}, [0, 25349, 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': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('boundary control', {'total': 100, 'credit_notes': [], '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': 18849, 'credit_notes': [], 'balance': 21401, 'min_payment': 50}, [0, 2552, 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': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 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': 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': 82, 'credit_notes': [], 'balance': 29441, 'min_payment': 50}, [0, 29359, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('partial-repair probe', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 83, 'credit_notes': [], 'balance': 9256, 'min_payment': 50}, [0, 9173, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 3623, 'min_payment': 100}, [0, 3487, 0]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0])]]\nfor i, (label, args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (label, i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"80bcaf8947984ff43fa0092ebc19f8814a8ff78ddd4f7641999d23507d734f9f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    due = x['total']\n    cn = sum(x['credit_notes'])\n    use_cn = min(cn, due)\n    due -= use_cn\n    bal = x['balance']\n    use_bal = min(bal, due)\n    due -= use_bal\n    bal -= use_bal\n    carried = 0\n    if 0 < due < x['min_payment']:\n        carried = due\n        due = 0\n    return [due, bal, carried]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('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 (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 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': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe (boundary)', {'total': 520, 'credit_notes': [300], 'balance': 199, 'min_payment': 50}, [0, 0, 21]), ('partial-repair probe', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 18, 'credit_notes': [], 'balance': 23152, 'min_payment': 0}, [0, 23134, 0]), ('normal control', {'total': 1, 'credit_notes': [], 'balance': 25350, 'min_payment': 50}, [0, 25349, 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': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('boundary control', {'total': 100, 'credit_notes': [], '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': 18849, 'credit_notes': [], 'balance': 21401, 'min_payment': 50}, [0, 2552, 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': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 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': 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': 82, 'credit_notes': [], 'balance': 29441, 'min_payment': 50}, [0, 29359, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('partial-repair probe', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 83, 'credit_notes': [], 'balance': 9256, 'min_payment': 50}, [0, 9173, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 3623, 'min_payment': 100}, [0, 3487, 0]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0])]]\nfor i, (label, args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (label, i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"a51fd5bbe16fa3e2d360db43156ef969959d8e126e6d583b26a7c7677e59b4a0","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    due = x['total']\n    cn = sum(x['credit_notes'])\n    use_cn = min(cn, due)\n    due -= use_cn\n    bal = x['balance'] + (cn - use_cn)\n    use_bal = min(bal, due)\n    due -= use_bal\n    bal -= use_bal\n    carried = 0\n    if 0 < due < x['min_payment']:\n        carried = due\n        due = 0\n    return [due, bal, carried]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('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 (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 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': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe (boundary)', {'total': 520, 'credit_notes': [300], 'balance': 199, 'min_payment': 50}, [0, 0, 21]), ('partial-repair probe', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 18, 'credit_notes': [], 'balance': 23152, 'min_payment': 0}, [0, 23134, 0]), ('normal control', {'total': 1, 'credit_notes': [], 'balance': 25350, 'min_payment': 50}, [0, 25349, 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': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('boundary control', {'total': 100, 'credit_notes': [], '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': 18849, 'credit_notes': [], 'balance': 21401, 'min_payment': 50}, [0, 2552, 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': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 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': 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': 82, 'credit_notes': [], 'balance': 29441, 'min_payment': 50}, [0, 29359, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('partial-repair probe', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 83, 'credit_notes': [], 'balance': 9256, 'min_payment': 50}, [0, 9173, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 3623, 'min_payment': 100}, [0, 3487, 0]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0])]]\nfor i, (label, args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (label, i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-subscription-proration-credit-balance-application-excess-credit-note-to-balance","generated_at":"2026-09-29T14:46:37.526935+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Proration credits land as credit notes and balances whose application order determines the charge.","repair":"Restore the contract rule at the excess credit note to balance step: use `bal = x['balance'] + (cn - use_cn)`.","root_cause":"The unused part of the credit notes is discarded instead of added to the balance.","sha256":"d6a324474536e761068d68ef252513c449d846030ea17c5f41f7fe1d784c8c53","title":"Credit notes and customer balance on an invoice: excess credit note to balance · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":38.781,"exit_code":1,"observations":[{"actual":[0,2302,0],"check":"regression 0","expected":[0,2249,0],"passed":false},{"actual":[0,15517,0],"check":"regression 1","expected":[0,15268,0],"passed":false},{"actual":[0,950,0],"check":"partial-repair probe (boundary) 2","expected":[50,0,0],"passed":false},{"actual":[0,1000,0],"check":"partial-repair probe (boundary) 3","expected":[100,0,0],"passed":false},{"actual":[50,0,0],"check":"boundary control 4","expected":[50,0,0],"passed":true},{"actual":[0,0,70],"check":"boundary control 5","expected":[0,0,70],"passed":true},{"actual":[0,13035,0],"check":"normal control 6","expected":[0,13035,0],"passed":true},{"actual":[294,0,0],"check":"normal control 7","expected":[294,0,0],"passed":true},{"actual":[36738,0,0],"check":"normal control 8","expected":[36738,0,0],"passed":true},{"actual":[2985,0,0],"check":"normal control 9","expected":[2985,0,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 2302, 0], \"expected\": [0, 2249, 0], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [0, 15517, 0], \"expected\": [0, 15268, 0], \"passed\": false}, {\"check\": \"partial-repair probe (boundary) 2\", \"actual\": [0, 950, 0], \"expected\": [50, 0, 0], \"passed\": false}, {\"check\": \"partial-repair probe (boundary) 3\", \"actual\": [0, 1000, 0], \"expected\": [100, 0, 0], \"passed\": false}, {\"check\": \"boundary control 4\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"boundary control 5\", \"actual\": [0, 0, 70], \"expected\": [0, 0, 70], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [0, 13035, 0], \"expected\": [0, 13035, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [294, 0, 0], \"expected\": [294, 0, 0], \"passed\": true}, {\"check\": \"normal control 8\", \"actual\": [36738, 0, 0], \"expected\": [36738, 0, 0], \"passed\": true}, {\"check\": \"normal control 9\", \"actual\": [2985, 0, 0], \"expected\": [2985, 0, 0], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.475,"exit_code":1,"observations":[{"actual":[0,0,0],"check":"regression 0","expected":[0,2249,0],"passed":false},{"actual":[0,0,0],"check":"regression 1","expected":[0,15268,0],"passed":false},{"actual":[50,0,0],"check":"partial-repair probe (boundary) 2","expected":[50,0,0],"passed":true},{"actual":[100,0,0],"check":"partial-repair probe (boundary) 3","expected":[100,0,0],"passed":true},{"actual":[50,0,0],"check":"boundary control 4","expected":[50,0,0],"passed":true},{"actual":[0,0,70],"check":"boundary control 5","expected":[0,0,70],"passed":true},{"actual":[0,13035,0],"check":"normal control 6","expected":[0,13035,0],"passed":true},{"actual":[294,0,0],"check":"normal control 7","expected":[294,0,0],"passed":true},{"actual":[36738,0,0],"check":"normal control 8","expected":[36738,0,0],"passed":true},{"actual":[2985,0,0],"check":"normal control 9","expected":[2985,0,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 0, 0], \"expected\": [0, 2249, 0], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [0, 0, 0], \"expected\": [0, 15268, 0], \"passed\": false}, {\"check\": \"partial-repair probe (boundary) 2\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"partial-repair probe (boundary) 3\", \"actual\": [100, 0, 0], \"expected\": [100, 0, 0], \"passed\": true}, {\"check\": \"boundary control 4\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"boundary control 5\", \"actual\": [0, 0, 70], \"expected\": [0, 0, 70], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [0, 13035, 0], \"expected\": [0, 13035, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [294, 0, 0], \"expected\": [294, 0, 0], \"passed\": true}, {\"check\": \"normal control 8\", \"actual\": [36738, 0, 0], \"expected\": [36738, 0, 0], \"passed\": true}, {\"check\": \"normal control 9\", \"actual\": [2985, 0, 0], \"expected\": [2985, 0, 0], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.855,"exit_code":0,"observations":[{"actual":[0,2249,0],"check":"regression 0","expected":[0,2249,0],"passed":true},{"actual":[0,15268,0],"check":"regression 1","expected":[0,15268,0],"passed":true},{"actual":[50,0,0],"check":"partial-repair probe (boundary) 2","expected":[50,0,0],"passed":true},{"actual":[100,0,0],"check":"partial-repair probe (boundary) 3","expected":[100,0,0],"passed":true},{"actual":[50,0,0],"check":"boundary control 4","expected":[50,0,0],"passed":true},{"actual":[0,0,70],"check":"boundary control 5","expected":[0,0,70],"passed":true},{"actual":[0,13035,0],"check":"normal control 6","expected":[0,13035,0],"passed":true},{"actual":[294,0,0],"check":"normal control 7","expected":[294,0,0],"passed":true},{"actual":[36738,0,0],"check":"normal control 8","expected":[36738,0,0],"passed":true},{"actual":[2985,0,0],"check":"normal control 9","expected":[2985,0,0],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 2249, 0], \"expected\": [0, 2249, 0], \"passed\": true}, {\"check\": \"regression 1\", \"actual\": [0, 15268, 0], \"expected\": [0, 15268, 0], \"passed\": true}, {\"check\": \"partial-repair probe (boundary) 2\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"partial-repair probe (boundary) 3\", \"actual\": [100, 0, 0], \"expected\": [100, 0, 0], \"passed\": true}, {\"check\": \"boundary control 4\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"boundary control 5\", \"actual\": [0, 0, 70], \"expected\": [0, 0, 70], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [0, 13035, 0], \"expected\": [0, 13035, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [294, 0, 0], \"expected\": [294, 0, 0], \"passed\": true}, {\"check\": \"normal control 8\", \"actual\": [36738, 0, 0], \"expected\": [36738, 0, 0], \"passed\": true}, {\"check\": \"normal control 9\", \"actual\": [2985, 0, 0], \"expected\": [2985, 0, 0], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}