# BudgetLineItem

## Description

BudgetLineItem is a child record of a Budget that specifies the planned spending amount for a specific cost element within a specific accounting period. Each line item carries a budget reference, cost element reference, accounting period reference, and planned amount. The corresponding GL account for each line item is derived automatically from the referenced primary cost element's one-to-one GL account mapping defined in cost-element-management, ensuring a single authoritative planning axis while preserving traceability to the general ledger. Budget line items provide the granular cost-element-level detail needed for funds checking, budget-vs-actual comparison, and variance analysis.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createBudgetLineItem](../commands/CreateBudgetLineItem.md) - Add a budget line item to a DRAFT budget specifying cost element, period, and planned amount
- [deleteBudgetLineItem](../commands/DeleteBudgetLineItem.md) - Remove a budget line item from a DRAFT budget

### Query Definitions

- [GetBudget](../queries/GetBudget.md) - Retrieve budget line items as part of the parent budget

### Models

- BudgetLineItem

### Invariants

- Budget line item must reference a valid budget via budgetId
- Budget line item can only be added to or removed from a DRAFT budget
- Budget line item requires a valid cost element reference; the cost element must be a PRIMARY type in ACTIVE status
- Budget line item derives its GL account automatically from the referenced primary cost element's GL account mapping
- Budget line item requires a valid accounting period reference from finance-ledger
- Budget line item planned amount must be a positive value
- Duplicate line items (same cost element and period) within a single budget are rejected

### Relationships

- **Belongs to Budget**: Each budget line item belongs to a Budget via budgetId
- **References CostElement**: Each budget line item references a CostElement via costElementId
- **References AccountingPeriod**: Each budget line item references an AccountingPeriod via accountingPeriodId (finance-ledger module)
