Historical Margin Backfill Pilot · sample output
The five outputs, using the five fictional rows of the published data contract
This is a static sample: the same numbers you get from contracts/receipts_template.csv
and contracts/order_lines_template.csv. It shows the format and the reconciliation, not
a real store's margin. Your files, your store, your numbers.
Fictional data. SKUs, dates and amounts come from the published template. Nothing here is a customer result, and no figure has been adjusted to look better.
Method declared: weighted average cost (WAC) by SKU and date. A sale takes the cost true on its date; nothing that happens later rewrites it. Currency USD · Timezone UTC.
1. cost_timeline.csv
| sku | received_at | qty | landed_unit_cost | wac_after |
|---|---|---|---|---|
| APP-TEE-BLK-M | 2025-01-15 | 120 | 9.700000 | 9.700000 |
| APP-TEE-BLK-L | 2025-01-15 | 80 | 9.700000 | 9.700000 |
| APP-HOOD-GRY-M | 2025-02-03 | 60 | 16.408333 | 16.408333 |
| APP-HOOD-GRY-L | 2025-02-03 | 40 | 16.575000 | 16.575000 |
| APP-CAP-OS | 2025-02-20 | 200 | 3.750000 | 3.750000 |
landed_unit_cost = unit_product_cost + (inbound_shipping_total + duties_total + other_landed_total) / quantity_received
2. margin_by_order.csv
| order_ref | processed_at | sku | qty_net | net_sales | cogs | margin | margin_pct | coverage |
|---|---|---|---|---|---|---|---|---|
| SO-1001 | 2025-03-02 | APP-TEE-BLK-M | 2 | 58.00 | 19.400000 | 38.600000 | 66.55 % | full |
| SO-1002 | 2025-03-02 | APP-HOOD-GRY-L | 1 | 57.60 | 16.575000 | 41.025000 | 71.22 % | full |
| SO-1003 | 2025-03-05 | APP-CAP-OS | 1 | 24.00 | 3.750000 | 20.250000 | 84.38 % | full |
| SO-1004 | 2025-03-11 | APP-TEE-BLK-L | 2 | 58.00 | 19.400000 | 38.600000 | 66.55 % | full |
| SO-1005 | 2025-03-14 | APP-HOOD-GRY-M | 1 | 64.00 | 16.408333 | 47.591667 | 74.36 % | full |
net_sales = gross_sales − discounts − refund_amount · qty_net = quantity_sold − returned_quantity
3. margin_by_sku_month.csv
| sku | month | units_net | net_sales | cogs | margin | margin_pct |
|---|---|---|---|---|---|---|
| APP-CAP-OS | 2025-03 | 1 | 24.00 | 3.750000 | 20.250000 | 84.38 % |
| APP-HOOD-GRY-L | 2025-03 | 1 | 57.60 | 16.575000 | 41.025000 | 71.22 % |
| APP-HOOD-GRY-M | 2025-03 | 1 | 64.00 | 16.408333 | 47.591667 | 74.36 % |
| APP-TEE-BLK-L | 2025-03 | 2 | 58.00 | 19.400000 | 38.600000 | 66.55 % |
| APP-TEE-BLK-M | 2025-03 | 2 | 58.00 | 19.400000 | 38.600000 | 66.55 % |
4. exceptions.csv
| row_source | row_ref | sku | reason |
|---|---|---|---|
| — | — | — | no exceptions in this sample |
Reasons that appear in real files: sale before the first receipt, negative inventory, duplicate or ambiguous SKU, a different currency, an unlinked refund. An exception is listed, never dropped.
5. reconciliation.md
Method : WAC by SKU and date · Currency: USD · Timezone: UTC (declared) Inputs : 5 order rows, 5 receipts Outputs : 5 processed, 0 exceptions (100 % accounted, 0 silent drops) Totals : gross 297.00 · discounts 6.40 · refunds 29.00 · net 261.60 COGS : 75.533333 · Margin 186.066667 (71.13 %) Auto-mapping: 100 % of rows (contractual threshold to count as an app signal: ≥90 %) Declared exclusions: none