FAILURE MAP
← Case archive

FA-59691 / Subscription proration billing / Open access

Volume discount tiers on quantity changes: tier threshold inclusion · case 01

Buying exactly the tier minimum does not unlock the discount.

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

ROOT CAUSE

The tier test is exclusive of the minimum quantity.

THE FAILURE

The tier test is exclusive of the minimum quantity.

Unsuccessful approach: The attempt unlocks tiers one unit early.

Case contract

Input {unit, old, new quantities, tiers: ascending [[min_qty, pct_off]], left, period}. A quantity's discount is the pct of the last tier with qty >= min_qty and applies to all units: total(q) = q*unit*(100-pct) in cent-percent. Proration of q = total(q)*left/(100*period) half-up. Return [-proration(old), proration(new)].

Why this case matters

Crossing a volume tier on a mid-cycle quantity change re-prices every unit for the rest of the period.

1 / The failure

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

N = 1
observations = []
def solve(x):
    def tier_pct(q):
        pct = 0
        for mn, off in x['tiers']:
            if q > mn:
                pct = off
        return pct
    def total(q):
        return q * x['unit'] * (100 - tier_pct(q))
    def pr(q):
        return (total(q) * x['left'] * 2 + 100 * x['period']) // (200 * x['period'])
    return [-pr(x['old']), pr(x['new'])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'unit': 999, 'old': 32, 'new': 8, 'tiers': [[1, 0], [8, 10], [33, 15]], 'left': 8, 'period': 31}, [-7425, 1856]), ('regression', {'unit': 1000, 'old': 9, 'new': 22, 'tiers': [[1, 0], [8, 5], [22, 20]], 'left': 24, 'period': 31}, [-6619, 13626]), ('partial-repair probe', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('partial-repair probe', {'unit': 1000, 'old': 7, 'new': 29, 'tiers': [[1, 0], [8, 5], [20, 15]], 'left': 22, 'period': 31}, [-4968, 17494]), ('normal control', {'unit': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('normal control', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('normal control', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('normal control', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424])], [('regression', {'unit': 1500, 'old': 31, 'new': 32, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 17, 'period': 31}, [-24225, 22374]), ('regression', {'unit': 1500, 'old': 26, 'new': 40, 'tiers': [[1, 0], [7, 10], [26, 20]], 'left': 20, 'period': 31}, [-20129, 30968]), ('partial-repair probe', {'unit': 1500, 'old': 4, 'new': 14, 'tiers': [[1, 0], [5, 5], [21, 20]], 'left': 13, 'period': 31}, [-2516, 8366]), ('partial-repair probe', {'unit': 1000, 'old': 4, 'new': 45, 'tiers': [[1, 0], [5, 10], [20, 20]], 'left': 3, 'period': 31}, [-387, 3484]), ('normal control', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('normal control', {'unit': 999, 'old': 1, 'new': 19, 'tiers': [[1, 0], [10, 5], [31, 25]], 'left': 1, 'period': 31}, [-32, 582]), ('normal control', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('normal control', {'unit': 1500, 'old': 22, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 25]], 'left': 9, 'period': 31}, [-9102, 13239])], [('regression', {'unit': 999, 'old': 32, 'new': 8, 'tiers': [[1, 0], [8, 10], [33, 15]], 'left': 8, 'period': 31}, [-7425, 1856]), ('regression', {'unit': 1000, 'old': 5, 'new': 17, 'tiers': [[1, 0], [5, 5], [37, 25]], 'left': 10, 'period': 31}, [-1532, 5210]), ('partial-repair probe', {'unit': 1000, 'old': 8, 'new': 11, 'tiers': [[1, 0], [9, 10], [34, 25]], 'left': 4, 'period': 31}, [-1032, 1277]), ('partial-repair probe', {'unit': 999, 'old': 7, 'new': 29, 'tiers': [[1, 0], [8, 5], [36, 15]], 'left': 18, 'period': 31}, [-4060, 15981]), ('normal control', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('normal control', {'unit': 1500, 'old': 6, 'new': 44, 'tiers': [[1, 0], [10, 10], [22, 15]], 'left': 22, 'period': 31}, [-6387, 39813]), ('normal control', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010]), ('normal control', {'unit': 1000, 'old': 27, 'new': 46, 'tiers': [[1, 0], [9, 5], [20, 15]], 'left': 4, 'period': 31}, [-2961, 5045])], [('regression', {'unit': 1500, 'old': 31, 'new': 32, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 17, 'period': 31}, [-24225, 22374]), ('regression', {'unit': 999, 'old': 13, 'new': 26, 'tiers': [[1, 0], [9, 5], [26, 15]], 'left': 30, 'period': 31}, [-11940, 21366]), ('partial-repair probe', {'unit': 4612, 'old': 7, 'new': 1, 'tiers': [[1, 0], [8, 10], [35, 25]], 'left': 30, 'period': 31}, [-31243, 4463]), ('partial-repair probe', {'unit': 1000, 'old': 37, 'new': 12, 'tiers': [[1, 0], [8, 10], [38, 15]], 'left': 7, 'period': 31}, [-7519, 2439]), ('normal control', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845]), ('normal control', {'unit': 1000, 'old': 41, 'new': 30, 'tiers': [[1, 0], [5, 5], [20, 15]], 'left': 23, 'period': 31}, [-25856, 18919]), ('normal control', {'unit': 1000, 'old': 1, 'new': 2, 'tiers': [[1, 0], [10, 5], [21, 20]], 'left': 30, 'period': 31}, [-968, 1935])], [('regression', {'unit': 999, 'old': 32, 'new': 8, 'tiers': [[1, 0], [8, 10], [33, 15]], 'left': 8, 'period': 31}, [-7425, 1856]), ('regression', {'unit': 1500, 'old': 5, 'new': 29, 'tiers': [[1, 0], [5, 5], [38, 15]], 'left': 16, 'period': 31}, [-3677, 21329]), ('partial-repair probe', {'unit': 1098, 'old': 48, 'new': 8, 'tiers': [[1, 0], [9, 5], [38, 15]], 'left': 13, 'period': 31}, [-18786, 3684]), ('partial-repair probe', {'unit': 1500, 'old': 30, 'new': 6, 'tiers': [[1, 0], [8, 5], [31, 20]], 'left': 21, 'period': 31}, [-28960, 6097]), ('normal control', {'unit': 999, 'old': 9, 'new': 38, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 27, 'period': 31}, [-7439, 28104]), ('normal control', {'unit': 1500, 'old': 42, 'new': 42, 'tiers': [[1, 0], [9, 10], [33, 25]], 'left': 30, 'period': 31}, [-45726, 45726]), ('normal control', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024])]]
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[-7425, 2062][-7425, 1856]Failed
regression 1[-6619, 16181][-6619, 13626]Failed
partial-repair probe 2[-9745, 5414][-9745, 5414]Passed
partial-repair probe 3[-4968, 17494][-4968, 17494]Passed
normal control 4[-15320, 27661][-15320, 27661]Passed
normal control 5[-13051, 806][-13051, 806]Passed
normal control 6[-19783, 11354][-19783, 11354]Passed
normal control 7[-38646, 28424][-38646, 28424]Passed

SHA-256 / d572809b1d12d41bfc10ce069d33046982cef641c16d4818a34a12b19783e3a2

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    def tier_pct(q):
        pct = 0
        for mn, off in x['tiers']:
            if q + 1 >= mn:
                pct = off
        return pct
    def total(q):
        return q * x['unit'] * (100 - tier_pct(q))
    def pr(q):
        return (total(q) * x['left'] * 2 + 100 * x['period']) // (200 * x['period'])
    return [-pr(x['old']), pr(x['new'])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'unit': 999, 'old': 32, 'new': 8, 'tiers': [[1, 0], [8, 10], [33, 15]], 'left': 8, 'period': 31}, [-7425, 1856]), ('regression', {'unit': 1000, 'old': 9, 'new': 22, 'tiers': [[1, 0], [8, 5], [22, 20]], 'left': 24, 'period': 31}, [-6619, 13626]), ('partial-repair probe', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('partial-repair probe', {'unit': 1000, 'old': 7, 'new': 29, 'tiers': [[1, 0], [8, 5], [20, 15]], 'left': 22, 'period': 31}, [-4968, 17494]), ('normal control', {'unit': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('normal control', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('normal control', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('normal control', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424])], [('regression', {'unit': 1500, 'old': 31, 'new': 32, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 17, 'period': 31}, [-24225, 22374]), ('regression', {'unit': 1500, 'old': 26, 'new': 40, 'tiers': [[1, 0], [7, 10], [26, 20]], 'left': 20, 'period': 31}, [-20129, 30968]), ('partial-repair probe', {'unit': 1500, 'old': 4, 'new': 14, 'tiers': [[1, 0], [5, 5], [21, 20]], 'left': 13, 'period': 31}, [-2516, 8366]), ('partial-repair probe', {'unit': 1000, 'old': 4, 'new': 45, 'tiers': [[1, 0], [5, 10], [20, 20]], 'left': 3, 'period': 31}, [-387, 3484]), ('normal control', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('normal control', {'unit': 999, 'old': 1, 'new': 19, 'tiers': [[1, 0], [10, 5], [31, 25]], 'left': 1, 'period': 31}, [-32, 582]), ('normal control', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('normal control', {'unit': 1500, 'old': 22, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 25]], 'left': 9, 'period': 31}, [-9102, 13239])], [('regression', {'unit': 999, 'old': 32, 'new': 8, 'tiers': [[1, 0], [8, 10], [33, 15]], 'left': 8, 'period': 31}, [-7425, 1856]), ('regression', {'unit': 1000, 'old': 5, 'new': 17, 'tiers': [[1, 0], [5, 5], [37, 25]], 'left': 10, 'period': 31}, [-1532, 5210]), ('partial-repair probe', {'unit': 1000, 'old': 8, 'new': 11, 'tiers': [[1, 0], [9, 10], [34, 25]], 'left': 4, 'period': 31}, [-1032, 1277]), ('partial-repair probe', {'unit': 999, 'old': 7, 'new': 29, 'tiers': [[1, 0], [8, 5], [36, 15]], 'left': 18, 'period': 31}, [-4060, 15981]), ('normal control', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('normal control', {'unit': 1500, 'old': 6, 'new': 44, 'tiers': [[1, 0], [10, 10], [22, 15]], 'left': 22, 'period': 31}, [-6387, 39813]), ('normal control', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010]), ('normal control', {'unit': 1000, 'old': 27, 'new': 46, 'tiers': [[1, 0], [9, 5], [20, 15]], 'left': 4, 'period': 31}, [-2961, 5045])], [('regression', {'unit': 1500, 'old': 31, 'new': 32, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 17, 'period': 31}, [-24225, 22374]), ('regression', {'unit': 999, 'old': 13, 'new': 26, 'tiers': [[1, 0], [9, 5], [26, 15]], 'left': 30, 'period': 31}, [-11940, 21366]), ('partial-repair probe', {'unit': 4612, 'old': 7, 'new': 1, 'tiers': [[1, 0], [8, 10], [35, 25]], 'left': 30, 'period': 31}, [-31243, 4463]), ('partial-repair probe', {'unit': 1000, 'old': 37, 'new': 12, 'tiers': [[1, 0], [8, 10], [38, 15]], 'left': 7, 'period': 31}, [-7519, 2439]), ('normal control', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845]), ('normal control', {'unit': 1000, 'old': 41, 'new': 30, 'tiers': [[1, 0], [5, 5], [20, 15]], 'left': 23, 'period': 31}, [-25856, 18919]), ('normal control', {'unit': 1000, 'old': 1, 'new': 2, 'tiers': [[1, 0], [10, 5], [21, 20]], 'left': 30, 'period': 31}, [-968, 1935])], [('regression', {'unit': 999, 'old': 32, 'new': 8, 'tiers': [[1, 0], [8, 10], [33, 15]], 'left': 8, 'period': 31}, [-7425, 1856]), ('regression', {'unit': 1500, 'old': 5, 'new': 29, 'tiers': [[1, 0], [5, 5], [38, 15]], 'left': 16, 'period': 31}, [-3677, 21329]), ('partial-repair probe', {'unit': 1098, 'old': 48, 'new': 8, 'tiers': [[1, 0], [9, 5], [38, 15]], 'left': 13, 'period': 31}, [-18786, 3684]), ('partial-repair probe', {'unit': 1500, 'old': 30, 'new': 6, 'tiers': [[1, 0], [8, 5], [31, 20]], 'left': 21, 'period': 31}, [-28960, 6097]), ('normal control', {'unit': 999, 'old': 9, 'new': 38, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 27, 'period': 31}, [-7439, 28104]), ('normal control', {'unit': 1500, 'old': 42, 'new': 42, 'tiers': [[1, 0], [9, 10], [33, 25]], 'left': 30, 'period': 31}, [-45726, 45726]), ('normal control', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024])]]
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[-7012, 1856][-7425, 1856]Failed
regression 1[-6619, 13626][-6619, 13626]Passed
partial-repair probe 2[-9745, 4873][-9745, 5414]Failed
partial-repair probe 3[-4719, 17494][-4968, 17494]Failed
normal control 4[-15320, 27661][-15320, 27661]Passed
normal control 5[-13051, 806][-13051, 806]Passed
normal control 6[-19783, 11354][-19783, 11354]Passed
normal control 7[-38646, 28424][-38646, 28424]Passed

SHA-256 / 1bf420b41267b1caa9b662e3f72baebc223f29c2ca9a21945ecf3022558ccf24

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / c401bb66263e35c1a97693724cf66f8b72802c73f4b6fceae01c551fd3c2c159