---
id: varejo/margem-contribuicao-pedido-sku
industry: Retail and e-commerce
usage: widely used
effort: high
grain: Order line item x day
---

# Contribution margin by order and SKU

What is left of each order and each SKU after COGS, shipping, commission, installment fees, media and taxes, without deducting anything twice.

## Executive summary

**For:** Retailers and e-commerce businesses that sell across several channels and want to know the real profit per product.

**What it solves**

- The margin of each SKU and each marketplace accounts for all variable costs, not just COGS.
- No cost goes in twice: commission, shipping, payment fees and media each appear once.
- It becomes clear how much the installment card fee and each channel's commission eat into margin.

**Why it matters:** Gross revenue is misleading: a best-selling SKU can lose money after commission, free shipping and media. Without margin per item, price, channel mix and ad budget are decided in the dark. It is also the foundation for Break CPA and for any AI assistant that answers questions about profit.

**Business questions it answers**

- What is the contribution margin by marketplace and by SKU this month?
- What are the 10 SKUs with the worst margin, and what is weighing on each one?
- How much is the 12-installment card fee taking out of our margin?
- What is the maximum CPA that still breaks even for product X?
- How much do we pay in commissions and fees relative to revenue on each marketplace?
- Is it worth continuing to sell this product on this channel?

**What you need**

- Marketplaces, own store and hub or ERP connected to Nekt
- Cost per SKU with an effective date (spreadsheet or ERP product record)
- The fees of each channel and of the card acquirer, per installment

**What you get**

- A table by order line item and day with revenue, each cost and the margin
- Margin dashboard by SKU, channel and period, with a ranking of the worst margins
- A cost coverage indicator, to know how much of revenue has reliable COGS
- An AI agent that answers questions about profit with each channel's rules

## Detailed

### The problem

Each channel delivers revenue and cost its own way: a unit commission in one, commission plus service fee in another, values in cents in a third, and the same shipment repeated under two statuses. Product cost lives in a spreadsheet that changes over time, and a SKU without a cost silently becomes zero cost. Whoever calculates on the order total and stacks everything on top ends up deducting the same fee twice or forgetting the installment card fee.

### Business rules

1. **Calculate at the item and aggregate afterwards.** The lowest reliable level is the order's line item (SKU). Allocate the order's shipping, coupon discount and service fee to the item (by item value or by quantity, with the criterion declared). Kits and bundles are exploded into their components, allocated by each component's value. Order, SKU, channel and month are sums of items. (Avoid: Calculating margin on the order total and then trying to break it down by product.)
2. **No value goes in twice.** Before deducting a component, check whether it is already inside another line. A per-order fulfillment fee that already includes payment processing does not get a card fee on top. Revenue already net of tax does not get tax deducted again. A marketplace's net payout already comes without commission. (Avoid: Deducting commission, shipping and card fee from a value that is already the net payout.)
3. **COGS at the cost effective on the sale date.** Use the unit cost that applied on the order date, from a dated table per SKU. The current product record cost only serves as an estimate, flagged as such. For own production, the factory-to-store transfer cost goes in without the ICMS (state VAT) credit; for resale, invoice cost x (1 minus the supplier's ICMS rate). Packs multiply the quantity (x2, x3, x6) when the line represents the pack. (Avoid: Applying today's cost to sales from six months ago.)
4. **A SKU without cost never becomes zero cost.** When the SKU is not in the cost table, COGS stays null and the item gets a coverage flag. Report coverage: the percentage of revenue with a known cost. Margin for an item without cost does not enter the best-margin ranking. (Avoid: COALESCE of cost to zero and a 100% margin on the new SKU.)
5. **Commission by each channel's rule.** On Mercado Livre, sale_fee is per unit: multiply by quantity. On Shopee, commission is commission_fee plus service_fee, and the subtotal received is escrow_amount. On Magalu, values come in cents and are divided by 100. On Amazon, the same shipment appears as DEFERRED_RELEASED and as RELEASED with the same value: count it once per shipment. (Avoid: Adding up the fee column of every channel as if it were the same concept.)
6. **Shipping is what the seller paid.** On Mercado Livre, the seller's real shipping cost is in orders.payments[].shipping_cost, at the payment level, not in orders.shipping. Free shipping for the buyer is a seller cost. In your own store, use the real shipping cost or the effective rate by product and destination, never the shipping charged to the customer. (Avoid: Using the shipping charged to the buyer as the shipping cost.)
7. **Deduct the installment card fee.** When customers mostly pay by card in installments, the acquirer fee varies with the number of installments (around 14% for 12 installments). Apply the installment fee of each sale. If the mix shifts from single payment to 12 installments, real margin falls even at the same price and the same COGS. (Avoid: Margin = (price minus COGS) / price, and that is it.)
8. **Rates with an effective period.** Fulfillment fees, shipping tables and commissions change over time. Store each rate by product, channel or country and effective period, and apply the one in effect on the order date. A lifetime average rate distorts both past and present. (Avoid: A single rate per product, calculated as a historical average.)
9. **Order status defines what goes in.** Cancelled, failed, pending or draft orders are excluded entirely: no revenue, no cost, no count. A refunded order keeps zero revenue but retains COGS and shipping cost and counts as an order. An internal or test order zeroes everything. The margin reference date is the order confirmation date. (Avoid: Treating a refund as a nonexistent order and wiping out cost that was already spent.)
10. **Media allocated and estimates labeled.** Media goes in by product and day, from the spend of the campaign tied to the product. In marketplace Ads, shared groups (catalog, family) attribute to a sibling item: a SKU with zero Ads may still have received media. Estimated tax is labeled as estimated. Contribution margin measures profitability; expected net and actual payout measure reconciliation and are not mixed. (Avoid: Concluding the SKU sells without media because its Ads figure is zero.)

### Where each cost comes from, by channel

Normalize each channel before adding up.

- **Mercado Livre · commission** → Unit fee x quantity (`sale_fee * quantity`)
- **Mercado Livre · shipping** → Shipping paid by the seller (`orders.payments[].shipping_cost`)
- **Mercado Livre · pack** → Several orders in one shipment (`pack_id`)
- **Shopee · commission** → Commission plus service fee (`commission_fee + service_fee`)
- **Shopee · received** → Subtotal after fees (`escrow_amount`)
- **Magalu · values** → Cents to reais (`value / 100`)
- **Amazon · settlement** → One shipment, once (`DEFERRED_RELEASED or RELEASED, never both`)
- **Own store · revenue** → Total minus itemized tax (`total_price - total_tax`)
- **Installment card payment** → Acquirer fee by installment count (`taxa_parcela(n_parcelas)`)
- **Refunded order** → Zero revenue, cost retained

### Definitions

| Metric | Definition |
|---|---|
| Item revenue | price x quantity minus allocated discount, excluding itemized tax, per order line item, on the order confirmation date |
| Item COGS | unit cost effective on the order date x quantity x pack multiplier; null, with a flag, if the SKU has no cost |
| Item variable costs | channel commission and fees + shipping paid by the seller + acquirer fee by installment count + fulfillment, allocated per item |
| Margin before media | revenue minus COGS minus variable costs, summed over the period |
| Contribution margin R$ | margin before media minus allocated media minus sales taxes (including DIFAL, the interstate ICMS differential) when revenue is not net of tax |
| Contribution margin % | sum of contribution margin / sum of revenue in the period, dividing only once |
| Break CPA | (revenue minus COGS minus variable costs) / orders in the period: the maximum acquisition cost that still breaks even |
| Commission and fees over revenue | (commission + channel fees) / channel revenue in the month |
| Cost coverage | revenue from items with known cost / total revenue in the period |

### Pitfalls

- **Silent zero cost.** SKUs missing from the cost table went in with zero COGS and showed up as the most profitable products in the operation. How to avoid: Null cost with a flag, coverage indicator and an alert for SKUs sold without cost.
- **Commission and shipping doubled.** Amazon returns the same shipment as DEFERRED_RELEASED and RELEASED. Adding both doubled commission and shipping on the vast majority of shipments. How to avoid: One row per shipment, from the most recent settlement.
- **Shipping in the wrong field.** Shipping read from orders.shipping on Mercado Livre was not the seller's cost, and margin per listing came out wrong until it was fixed. How to avoid: Seller shipping in orders.payments[].shipping_cost.
- **Lifetime average rate.** A single fulfillment fee per product, averaged over the whole history, was off by 14% to 30% in the months before a rate revision. How to avoid: Rates by effective period, applied by order date.
- **Pack counted as a unit.** In one of the stores, the line quantity represented a pack of 2, 3 or 6 units. Without the multiplier, COGS was underestimated. How to avoid: Multiplier table per pack SKU, per store; a new pack SKU with no row triggers an alert.
- **Average of margins.** The average of each day's or SKU's percentage margins does not match the month's margin and overweights low-volume items. How to avoid: Sum the components and divide once.

### Acceptance test

- [ ] For one marketplace and one closed month, total commission and fees match the marketplace's own sales or payout report (difference below 1%).
- [ ] The sum of contribution margin by SKU equals the sum by order and the channel total for the same period (zero difference).
- [ ] No sold item has zero cost without a flag, and the month's cost coverage is reported alongside the margin.
- [ ] On Amazon, each shipment appears only once in the costs table.
- [ ] The month's margin % is recomputed from the components and does not diverge from the item table.

### Context document

```text
Contribution margin by order and SKU
- Grain: one row per order line item, per day (order confirmation date). Order, SKU, channel and month are sums of items.
- No financial value is added or deducted twice. If a line already contains commission, shipping, media, discount or fee, that component is not applied again.
- COGS = unit cost effective on the order date x quantity x pack multiplier. A SKU without cost has null COGS and a coverage flag; never zero.
- Mercado Livre: commission = sale_fee x quantity; seller shipping = orders.payments[].shipping_cost.
- Shopee: commission = commission_fee + service_fee; received = escrow_amount.
- Magalu: values / 100.
- Amazon: a shipment counts once (do not add DEFERRED_RELEASED to RELEASED).
- Acquirer fee applied by each sale's number of installments.
- Cancelled, failed and pending orders are excluded. Refunded: zero revenue, costs retained, order counted. Internal or test: everything zero.
- Margin % = sum of margin / sum of revenue. Never an average of percentages.
- Estimated tax is always reported as estimated.
- Contribution margin measures profitability. Expected net and actual payout measure reconciliation. Do not treat them as equivalent.
- Transfers between companies in the same group are not revenue.
Client exceptions:
- <client>: own production COGS = transfer price x <factor> (without ICMS credit).
- <client>: per-order fulfillment fee already includes the payment fee; do not add a card fee.
- <client>: pack SKUs <list> with multiplier <n>.
```

### Variations

- **Marketplace reconciliation:** The same order in the marketplace, the hub and the ERP: reconcile by pack_id and store order number, with a confidence level.
- **Physical store with installments:** No marketplace: COGS, acquirer fee per installment and single-payment vs. installment mix by store.
- **International DTC:** Revenue excluding VAT or sales tax by country, fulfillment rate by product and country, and Break CPA by product.
