# FifoCost

## Description

FifoCost is FIFO's price state: the unit cost history of a [CostLayer](./CostLayer.md), append-only. Version 1 is written when the layer is created and carries the receipt's actual acquisition cost; later versions are appended when an invoice-driven [acquisition cost adjustment](./AcquisitionCostAdjustment.md) restates the layer. The layer's current cost is the greatest version.

Rows exist only under FIFO policies.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- Price rows are written internally by [postInventoryLedger](../command/PostInventoryLedger.md) when a FIFO receipt creates a layer and by [postAcquisitionCostAdjustment](../command/PostAcquisitionCostAdjustment.md) when an adjustment restates a layer; no direct command

### Query Definitions

- The current layer cost is resolved internally by costing as the greatest version; no read query yet

### Models

- FifoCost

### Invariants

- Rows are append-only with a unique 1-based version per layer; the greatest version is the layer's current unit cost
- Every FIFO layer has at least one row, written at receipt with the actual acquisition cost
- Versions beyond 1 are written by acquisition cost adjustments and carry the layer's restated unit cost — the adjusted value spread over the layer's remaining quantity
- Unit cost is zero or greater

### Relationships

- **References CostLayer**: Each price row belongs to exactly one cost layer
