FAILURE MAP
← Case archive

FA-60331 / Inventory cost layering / Open access

Period-end ownership cutoff adjustments: consigned-out direction · case 01

Goods held by consignees are deducted from inventory instead of added.

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

ROOT CAUSE

Consigned-out goods fall into the subtraction branch with consigned-in goods.

VERIFIED REPAIR

Add consigned-out goods; only consigned-in and bill-and-hold goods are subtracted.

Unsuccessful approach: Ignoring consigned-out goods still omits inventory the company owns.

Case contract

Input {count_value, period_end, items:[{type, terms, value, shipped_day, arrived_day|None}]}. Goods "arrived" when arrived_day is set and <= period_end. Inbound in transit is added when FOB_shipping, shipped by period end and not arrived. Outbound in transit is added back when FOB_destination, shipped by period end and not arrived. Goods consigned out are added; consigned-in and bill-and-hold goods (counted but not owned) are subtracted regardless of terms. Return {adjusted, adds, subtracts}.

Why this case matters

Inventory valuation and cost-of-goods decisions depend on this rule.

1 / The failure

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

N = 1
observations = []
def solve(x):
    end = x['period_end']
    add = 0
    sub = 0
    for it in x['items']:
        k = it['type']
        v = it['value']
        arrived = it['arrived_day'] is not None and it['arrived_day'] <= end
        if k == 'in_transit_in':
            if it['terms'] == 'FOB_shipping' and it['shipped_day'] <= end and not arrived:
                add += v
        elif k == 'in_transit_out':
            if it['terms'] == 'FOB_destination' and it['shipped_day'] <= end and not arrived:
                add += v
        elif k in ('consigned_in', 'bill_and_hold', 'consigned_out'):
            sub += v
    return {'adjusted': x['count_value'] + add - sub, 'adds': add, 'subtracts': sub}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 501, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10501, 'adds': 501, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 201, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5501, 'adds': 501, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 26}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 801, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 451, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9749, 'adds': 1200, 'subtracts': 451}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 351, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5549, 'adds': 0, 'subtracts': 451}], ['undelivered none', {'count_value': 100, 'period_end': 32, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 502, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10502, 'adds': 502, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 202, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5502, 'adds': 502, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 27}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 802, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 452, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9748, 'adds': 1200, 'subtracts': 452}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 352, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5548, 'adds': 0, 'subtracts': 452}], ['undelivered none', {'count_value': 100, 'period_end': 33, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 503, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10503, 'adds': 503, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 203, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5503, 'adds': 503, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 28}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 803, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 453, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9747, 'adds': 1200, 'subtracts': 453}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 353, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5547, 'adds': 0, 'subtracts': 453}], ['undelivered none', {'count_value': 100, 'period_end': 34, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 504, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10504, 'adds': 504, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 204, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5504, 'adds': 504, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 29}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 804, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 454, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9746, 'adds': 1200, 'subtracts': 454}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 354, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5546, 'adds': 0, 'subtracts': 454}], ['undelivered none', {'count_value': 100, 'period_end': 35, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 505, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10505, 'adds': 505, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 205, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5505, 'adds': 505, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 30}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 805, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 455, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9745, 'adds': 1200, 'subtracts': 455}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 355, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5545, 'adds': 0, 'subtracts': 455}], ['undelivered none', {'count_value': 100, 'period_end': 36, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
inbound shipping terms{'adds': 501, 'adjusted': 10501, 'subtracts': 0}{'adds': 501, 'adjusted': 10501, 'subtracts': 0}Passed
shipped on period end{'adds': 501, 'adjusted': 5501, 'subtracts': 0}{'adds': 501, 'adjusted': 5501, 'subtracts': 0}Passed
shipped after period{'adds': 0, 'adjusted': 5000, 'subtracts': 0}{'adds': 0, 'adjusted': 5000, 'subtracts': 0}Passed
arrived before end{'adds': 0, 'adjusted': 8000, 'subtracts': 0}{'adds': 0, 'adjusted': 8000, 'subtracts': 0}Passed
outbound terms{'adds': 600, 'adjusted': 7600, 'subtracts': 0}{'adds': 600, 'adjusted': 7600, 'subtracts': 0}Passed
consignment{'adds': 0, 'adjusted': 7349, 'subtracts': 1651}{'adds': 1200, 'adjusted': 9749, 'subtracts': 451}Failed
bill and hold{'adds': 0, 'adjusted': 5549, 'subtracts': 451}{'adds': 0, 'adjusted': 5549, 'subtracts': 451}Passed
undelivered none{'adds': 55, 'adjusted': 155, 'subtracts': 0}{'adds': 55, 'adjusted': 155, 'subtracts': 0}Passed

SHA-256 / 4c4a6c822582efc36e942a1dc56bfad3d4322a9ec2867bab7a33b02da48d9930

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    end = x['period_end']
    add = 0
    sub = 0
    for it in x['items']:
        k = it['type']
        v = it['value']
        arrived = it['arrived_day'] is not None and it['arrived_day'] <= end
        if k == 'in_transit_in':
            if it['terms'] == 'FOB_shipping' and it['shipped_day'] <= end and not arrived:
                add += v
        elif k == 'in_transit_out':
            if it['terms'] == 'FOB_destination' and it['shipped_day'] <= end and not arrived:
                add += v
        elif k in ('consigned_in', 'bill_and_hold'):
            sub += v
    return {'adjusted': x['count_value'] + add - sub, 'adds': add, 'subtracts': sub}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 501, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10501, 'adds': 501, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 201, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5501, 'adds': 501, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 26}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 801, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 451, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9749, 'adds': 1200, 'subtracts': 451}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 351, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5549, 'adds': 0, 'subtracts': 451}], ['undelivered none', {'count_value': 100, 'period_end': 32, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 502, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10502, 'adds': 502, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 202, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5502, 'adds': 502, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 27}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 802, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 452, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9748, 'adds': 1200, 'subtracts': 452}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 352, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5548, 'adds': 0, 'subtracts': 452}], ['undelivered none', {'count_value': 100, 'period_end': 33, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 503, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10503, 'adds': 503, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 203, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5503, 'adds': 503, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 28}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 803, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 453, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9747, 'adds': 1200, 'subtracts': 453}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 353, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5547, 'adds': 0, 'subtracts': 453}], ['undelivered none', {'count_value': 100, 'period_end': 34, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 504, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10504, 'adds': 504, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 204, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5504, 'adds': 504, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 29}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 804, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 454, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9746, 'adds': 1200, 'subtracts': 454}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 354, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5546, 'adds': 0, 'subtracts': 454}], ['undelivered none', {'count_value': 100, 'period_end': 35, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 505, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10505, 'adds': 505, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 205, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5505, 'adds': 505, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 30}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 805, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 455, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9745, 'adds': 1200, 'subtracts': 455}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 355, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5545, 'adds': 0, 'subtracts': 455}], ['undelivered none', {'count_value': 100, 'period_end': 36, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
inbound shipping terms{'adds': 501, 'adjusted': 10501, 'subtracts': 0}{'adds': 501, 'adjusted': 10501, 'subtracts': 0}Passed
shipped on period end{'adds': 501, 'adjusted': 5501, 'subtracts': 0}{'adds': 501, 'adjusted': 5501, 'subtracts': 0}Passed
shipped after period{'adds': 0, 'adjusted': 5000, 'subtracts': 0}{'adds': 0, 'adjusted': 5000, 'subtracts': 0}Passed
arrived before end{'adds': 0, 'adjusted': 8000, 'subtracts': 0}{'adds': 0, 'adjusted': 8000, 'subtracts': 0}Passed
outbound terms{'adds': 600, 'adjusted': 7600, 'subtracts': 0}{'adds': 600, 'adjusted': 7600, 'subtracts': 0}Passed
consignment{'adds': 0, 'adjusted': 8549, 'subtracts': 451}{'adds': 1200, 'adjusted': 9749, 'subtracts': 451}Failed
bill and hold{'adds': 0, 'adjusted': 5549, 'subtracts': 451}{'adds': 0, 'adjusted': 5549, 'subtracts': 451}Passed
undelivered none{'adds': 55, 'adjusted': 155, 'subtracts': 0}{'adds': 55, 'adjusted': 155, 'subtracts': 0}Passed

SHA-256 / e93046e9a0d03055d3f9dc5ed5358b460fc86ce1749485be7bd30dfc4ab4084f

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    end = x['period_end']
    add = 0
    sub = 0
    for it in x['items']:
        k = it['type']
        v = it['value']
        arrived = it['arrived_day'] is not None and it['arrived_day'] <= end
        if k == 'in_transit_in':
            if it['terms'] == 'FOB_shipping' and it['shipped_day'] <= end and not arrived:
                add += v
        elif k == 'in_transit_out':
            if it['terms'] == 'FOB_destination' and it['shipped_day'] <= end and not arrived:
                add += v
        elif k == 'consigned_out':
            add += v
        elif k in ('consigned_in', 'bill_and_hold'):
            sub += v
    return {'adjusted': x['count_value'] + add - sub, 'adds': add, 'subtracts': sub}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 501, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10501, 'adds': 501, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 201, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5501, 'adds': 501, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 26}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 801, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 451, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9749, 'adds': 1200, 'subtracts': 451}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 351, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5549, 'adds': 0, 'subtracts': 451}], ['undelivered none', {'count_value': 100, 'period_end': 32, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 502, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10502, 'adds': 502, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 202, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5502, 'adds': 502, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 27}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 802, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 452, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9748, 'adds': 1200, 'subtracts': 452}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 352, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5548, 'adds': 0, 'subtracts': 452}], ['undelivered none', {'count_value': 100, 'period_end': 33, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 503, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10503, 'adds': 503, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 203, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5503, 'adds': 503, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 28}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 803, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 453, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9747, 'adds': 1200, 'subtracts': 453}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 353, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5547, 'adds': 0, 'subtracts': 453}], ['undelivered none', {'count_value': 100, 'period_end': 34, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 504, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10504, 'adds': 504, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 204, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5504, 'adds': 504, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 29}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 804, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 454, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9746, 'adds': 1200, 'subtracts': 454}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 354, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5546, 'adds': 0, 'subtracts': 454}], ['undelivered none', {'count_value': 100, 'period_end': 35, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]], [['inbound shipping terms', {'count_value': 10000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 505, 'shipped_day': 30, 'arrived_day': None}, {'type': 'in_transit_in', 'terms': 'FOB_destination', 'value': 700, 'shipped_day': 29, 'arrived_day': 33}]}, {'adjusted': 10505, 'adds': 505, 'subtracts': 0}], ['shipped on period end', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 31, 'arrived_day': 34}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 205, 'shipped_day': 31, 'arrived_day': None}]}, {'adjusted': 5505, 'adds': 505, 'subtracts': 0}], ['shipped after period', {'count_value': 5000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 300, 'shipped_day': 32, 'arrived_day': 35}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 250, 'shipped_day': 32, 'arrived_day': None}]}, {'adjusted': 5000, 'adds': 0, 'subtracts': 0}], ['arrived before end', {'count_value': 8000, 'period_end': 31, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 400, 'shipped_day': 20, 'arrived_day': 30}, {'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 90, 'shipped_day': 28, 'arrived_day': 31}]}, {'adjusted': 8000, 'adds': 0, 'subtracts': 0}], ['outbound terms', {'count_value': 7000, 'period_end': 31, 'items': [{'type': 'in_transit_out', 'terms': 'FOB_destination', 'value': 600, 'shipped_day': 30, 'arrived_day': 32}, {'type': 'in_transit_out', 'terms': 'FOB_shipping', 'value': 805, 'shipped_day': 30, 'arrived_day': 33}]}, {'adjusted': 7600, 'adds': 600, 'subtracts': 0}], ['consignment', {'count_value': 9000, 'period_end': 31, 'items': [{'type': 'consigned_out', 'terms': 'none', 'value': 1200, 'shipped_day': 10, 'arrived_day': None}, {'type': 'consigned_in', 'terms': 'none', 'value': 455, 'shipped_day': 5, 'arrived_day': 6}]}, {'adjusted': 9745, 'adds': 1200, 'subtracts': 455}], ['bill and hold', {'count_value': 6000, 'period_end': 31, 'items': [{'type': 'bill_and_hold', 'terms': 'FOB_destination', 'value': 355, 'shipped_day': 0, 'arrived_day': None}, {'type': 'bill_and_hold', 'terms': 'FOB_shipping', 'value': 100, 'shipped_day': 0, 'arrived_day': None}]}, {'adjusted': 5545, 'adds': 0, 'subtracts': 455}], ['undelivered none', {'count_value': 100, 'period_end': 36, 'items': [{'type': 'in_transit_in', 'terms': 'FOB_shipping', 'value': 55, 'shipped_day': 12, 'arrived_day': None}]}, {'adjusted': 155, 'adds': 55, 'subtracts': 0}]]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
inbound shipping terms{'adds': 501, 'adjusted': 10501, 'subtracts': 0}{'adds': 501, 'adjusted': 10501, 'subtracts': 0}Passed
shipped on period end{'adds': 501, 'adjusted': 5501, 'subtracts': 0}{'adds': 501, 'adjusted': 5501, 'subtracts': 0}Passed
shipped after period{'adds': 0, 'adjusted': 5000, 'subtracts': 0}{'adds': 0, 'adjusted': 5000, 'subtracts': 0}Passed
arrived before end{'adds': 0, 'adjusted': 8000, 'subtracts': 0}{'adds': 0, 'adjusted': 8000, 'subtracts': 0}Passed
outbound terms{'adds': 600, 'adjusted': 7600, 'subtracts': 0}{'adds': 600, 'adjusted': 7600, 'subtracts': 0}Passed
consignment{'adds': 1200, 'adjusted': 9749, 'subtracts': 451}{'adds': 1200, 'adjusted': 9749, 'subtracts': 451}Passed
bill and hold{'adds': 0, 'adjusted': 5549, 'subtracts': 451}{'adds': 0, 'adjusted': 5549, 'subtracts': 451}Passed
undelivered none{'adds': 55, 'adjusted': 155, 'subtracts': 0}{'adds': 55, 'adjusted': 155, 'subtracts': 0}Passed

SHA-256 / 5d6f1561633d2b6c2c46cc6bbe4f768d45ebf8472717fc759746140e1c8aeb06

Verification & scope

Stipulated bounded teaching model with explicit toy rules; not an accounting-standard implementation. 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:44.703690+00:00.

Case digest / e287f06d266d5e14087580315d06eb51840a6e7d4794daed5a355fb8977e0f4d