Pranav GudiseCode on GitHub

Margin bridge tie-out

Rebuild a quarter's gross-profit bridge from ERP invoice lines, tie it to the ledger, and find the driver a favorable total hides.

Ties to the ledger

Both quarters, revenue and gross profit, within $1 of the general ledger

Go-live gate GO 25 of 25
-$80KGross profit, $6.72M to $6.64M, while revenue rose from $29.05M to $31.44M

The real driver is a -$540K drag from lower-margin installer (DIFM) business at the two largest retailers, hidden under a +$453K gain from richer product mix.

Surcharges recovered 80% of the -$1.07M tariff hit (+$856K price). The lever is the installer program's margin, not list price.

The product-line bridge says the opposite: surcharges barely stuck (price +$359K against a -$1.07M tariff hit) and mix helped (+$453K). It booked the installer shift as a price cut.

The bridge

Prior quarter gross profit to current quarter, one step per effect. Both grains end at the same -$80K; they disagree on why.

Prior quarterGross profit
$6.72M
PriceNet of rebates, incl. tariff surcharges
+$856K
Tariff cost
-$1.07M
Volume
+$215K
Product mix
+$453K
Channel mixWithin product lines
-$540K
Customer mixWithin product line and channel
+$52K
SKU mixWithin the rest
-$2K
Ledger-only itemsVariances, reserves, freight
-$45K
Current quarterGross profit
$6.64M

Item-level mix is split into four nested levels, each the mix it adds on top of the coarser one. Channel mix is the driver.

Scale starts at $5.75M, not zero; the break in each total bar marks it. Every step is drawn to the same scale.

Both grains, line by line

Effect on gross profitProduct lineItem level
Price (net of rebates, incl. tariff surcharges)+$359K+$856K
Tariff cost-$1.07M-$1.07M
Material and other cost+$6K$0
Volume+$215K+$215K
Mix+$453K-$38K
Ledger-only items (variances, reserves, freight)-$45K-$45K
Change in gross profit-$80K-$80K

Marked rows read differently at the two grains: when installer business grows inside a product line, the product-line bridge books the lower program price as a price cut.

Mix, split so the parts add up

Mix levelEffect
Product mix+$453K
Channel mix within product lines-$540K
Customer mix within product line and channel+$52K
SKU mix within the rest-$2K
Item-level mix-$38K

Each level is the mix it adds on top of the coarser one, so the four rows sum to the item-level mix.

Tie-out

Nothing is decomposed until the extract ties to the general ledger, each quarter: revenue within $1, and gross profit within $1 after named, sized items that post only at the ledger. Anything left unexplained stops the bridge.

ExtractLedgerDifferenceStatus
Prior quarter
Revenue$29.05M$29.05M$0Ties
Gross profit from invoice lines$7.13M
less purchase price and manufacturing variances($189K)
less inventory and obsolescence reserve change($87K)
less inbound freight not in standard cost($135K)
Gross profit after named items$6.72M$6.72M$0Ties
Current quarter
Revenue$31.44M$31.44M$0Ties
Gross profit from invoice lines$7.10M
less purchase price and manufacturing variances($210K)
less inventory and obsolescence reserve change($97K)
less inbound freight not in standard cost($149K)
Gross profit after named items$6.64M$6.64M$0Ties
The same check on a planted cut-off extract (separate test data)
Current quarter gross profit after named items-$178,158Break

Rebates post as separate customer-level memos, so they are allocated to invoice lines by gross sales within each customer and month before any price is calculated. Order types map to channels, and units convert to eaches, from one definitions file finance owns.

What the driver finder flags

-$540K

Channel mix masked

Installer (DIFM) share grew inside product lines at Retailers A and B, hidden under a favorable product mix of +$453K.

+$856K

Price reattributed

Like-for-like price held up better than the product-line bridge shows (+$359K): it books the installer shift inside its lines as a price cut. Surcharges held.

-$1.07M

Tariff cost

All of it on China-origin parts; surcharges recovered 80%.

Bad extracts stop the bridge

Five planted problems, each on its own test extract. Every one stops the bridge before a number is published.

Planted problemWhat the check saysResult
A new order type, XFR, that nobody added to the channel maporder type XFR on 40 lines ($484,024) has no channelStopped
Wipers sold in cases of twelve, a unit with no conversionunit of measure CS12 on 240 lines ($1,501,878) has no conversion to eachesStopped
A rebate memo keyed to RETAILER B INC instead of Retailer Brebate memo CM-RET-2026-07 ($191,448) names RETAILER B INC, not in the customer masterStopped
An extract cut off in September while the ledger has the full monthextract does not tie to the ledger: current quarter gross profit off by -$178,158Stopped
An export that repeated a page of invoices30 invoice lines appear more than onceStopped

Go-live gate

25 planted scenarios (8 routine drivers, 8 hidden drivers, 6 bad extracts, 3 clean controls), scored with golive-gate. The gate: 24 of 25 overall, every hidden driver, every bad extract stopped, no false alarms, and zero critical failures (publishing on bad data, missing a planted data problem, or a bridge that does not tie).

Tie-out, item-level bridge and driver finderWhat this page shows
25of 25 cases
GO Every case and check
Product-line workbookTies to the ledger and stops if it does not; product line only, so it cannot see customer, channel, or origin; no data checks
7of 25 cases
NO-GO Every case and check

The workbook's misses are mostly structural: a product-line view cannot name a customer or a channel, and without data checks it cannot name a bad extract. The cases were written on fixed data seeds; on seven seeds they were not written with, the tie-out passes 172 of 175 cases. CI runs the tests, this gate, and that sweep on every push.