# Cost models

**Stance:** **FIFO** is the **primary** costing method for stock layers. **Moving average** is an **optional** tenant/item-class policy where legally and operationally acceptable. All models honor **append-only** movements and **deterministic** consumption rules.

## FIFO (primary)

**Definition:** Outbound movements consume inventory in **oldest layer first** order within the valuation scope (typically item + warehouse + cost dimension; lot-tracked items may be scoped per lot).

**Properties:**

- Natural alignment with **physical** first-in-first-out in many businesses.
- Ending inventory approximates **recent** purchase costs on the balance sheet.
- Outbound cost is **exact** per consumed layer slice (subject to **rounding policy** on splits).

**Ordering tie-breakers** (must be fixed and documented in code): same timestamp → stable sort by `layer_id` or `receipt_movement_id` ascending—no random or DB-order ambiguity.

## Moving average (optional)

**Definition:** After each **inbound**, unit cost is recomputed as:

\[
\text{new average} = \frac{\text{prior value on hand} + \text{inbound value}}{\text{prior quantity} + \text{inbound quantity}}
\]

**Outbound** uses the **average valid at time of issue** (per policy: pre-move or post-move snapshot).

**Constraints:**

- Enable only where **regulatory and audit** requirements allow (differs by jurisdiction and industry).
- Negative inventory (if ever allowed) requires **explicit** policy; otherwise block issue.
- Must remain **replayable**: store **sufficient snapshots** (average after each movement) or derive deterministically from inbound sequence—no hand-edited average.

**Trade-off:** Simpler mental model per SKU-site; **less** natural trace from shipment back to specific vendor invoices than FIFO—document for auditors.

## Future extensibility

| Method | Intent |
| --- | --- |
| **Standard cost** | Planned cost with variance posting (purchase/production variance accounts) |
| **Specific identification** | Serialized or high-value items with explicit cost per unit |
| **LIFO** | Jurisdiction-specific; requires separate policy module |

Extension rules:

1. New methods implement the same **movement → layers / snapshots → outbound cost** contract (`valuation-pipeline.md`).
2. **Migration** between methods uses **cutover date** + optional opening layer snapshot—never in-place rewrite of old movements.
3. **Tenant/item** selects **one** active method per valuation scope at a time unless parallel **valuation views** (e.g., statutory vs management) are explicitly modeled as separate **cost books**.

## Related documents

- `cost-layers.md` — FIFO layers vs average snapshots  
- `inventory-valuation-principles.md` — no direct value edits  
