# CostLayer

## Description

CostLayer represents an append-only record of inventory cost for FIFO (First In, First Out) valuation. Each cost layer is created when a goods receipt is executed for an item under a FIFO valuation policy, capturing the quantity received and its unit cost. When goods are issued, cost layers are consumed in oldest-first order, with the remainingQuantity field tracking the unconsumed portion.

Cost layers are never modified after creation — only the remainingQuantity is decremented as stock is consumed.

## Domain Model Definitions

### Model type

AppendOnly

### Command Definitions

- Cost layers are created internally by goods receipt execution under a FIFO valuation policy and consumed by goods issue execution

### Query Definitions

- [listCostLayers](../queries/ListCostLayers.md) - List cost layers by item or valuation policy for FIFO auditing

### Models

- CostLayer

### Invariants

- Created on goods receipt for items under a FIFO valuation policy
- Consumed in oldest-first order on goods issue
- Remaining quantity tracks the unconsumed portion of the original layer

### Relationships

- **References Item**: Each cost layer belongs to an Item from the item-management module
- **References ValuationPolicy**: Each cost layer is associated with a FIFO valuation policy
- **References StockMovement**: Each cost layer is linked to the stock movement that created it
