Back to blog

Apr 08, 2026 · 6 min read

Landed cost in 200 lines of SQL

Landed cost is the real cost of a product after shipping, customs, insurance and handling. If your unit cost spreadsheet doesn't include it, your margin is a fiction.

The allocation is a weighted split: take the shipment's ancillary costs, distribute across linked PO lines by their share of value (or weight, if goods are physically heavy vs light).

We store landed cost at the line level, not the SKU level. Same SKU across two shipments will have two landed costs. Current stock value uses weighted average; sales margin uses FIFO from the line allocations.

This is simpler than it sounds. 200 lines of parameterized SQL and a nightly reconciler.