# Commitment

## Description

Commitment represents an outstanding purchase order amount that reduces available budget before the actual expense is incurred. Each commitment carries a cost element reference, cost object type and id (polymorphic reference to cost center, profit center, or internal order), accounting period reference, amount, purchase order reference, company scope, and status. Commitments are recorded when the purchase module confirms a purchase order, consumed when goods are received or invoices are matched (reducing the commitment and increasing actuals), and released when a purchase order is cancelled. Commitments are a key component of the budgetary control formula: Available = Budget - (Actual + Commitments + Encumbrances).

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [recordCommitment](../commands/RecordCommitment.md) - Record a commitment amount when a purchase order confirmation event is received
- [consumeCommitment](../commands/ConsumeCommitment.md) - Reduce commitment and increase actual when goods receipt or invoice match event is received
- [releaseCommitment](../commands/ReleaseCommitment.md) - Release commitment amount back to available budget when a purchase order is cancelled

### Query Definitions

- [GetBudget](../queries/GetBudget.md) - Commitment amounts are included in budget availability calculations

### Models

- Commitment

### Invariants

- Commitment must reference a valid cost element via costElementId
- Commitment must reference a valid cost object via costObjectType and costObjectId (cost center, profit center, or internal order)
- Commitment must reference a valid accounting period from finance-ledger
- Commitment amount must be a positive value when recorded
- Commitment must reference a valid purchase order via purchaseOrderId
- Commitment must reference a valid companyId; the company must be in ACTIVE status
- Commitment amounts are reduced and actual amounts are increased when a goods receipt or invoice match event is received
- Commitment amounts are fully released when a purchase order cancellation event is received
- Commitments reduce available budget in the budgetary control formula

### Relationships

- **References CostElement**: Each commitment references a CostElement via costElementId
- **Polymorphic Cost Object**: Each commitment references a cost object via costObjectType and costObjectId, which can be a CostCenter, ProfitCenter, or InternalOrder
- **References AccountingPeriod**: Each commitment references an AccountingPeriod via accountingPeriodId (finance-ledger module)
- **References PurchaseOrder**: Each commitment references a PurchaseOrder via purchaseOrderId (purchase module)
- **References Company**: Each commitment is scoped to a Company via companyId (organization module)
