# AllocationRule

## Description

AllocationRule defines a single sender-receiver-percentage mapping within an allocation cycle, specifying which cost center sends costs, which cost object receives them, and the allocation percentage. Each rule carries an allocation cycle reference, sender cost center reference, receiver type, receiver id, and percentage. Receivers can be cost centers, profit centers, or internal orders (polymorphic reference). Multiple rules within a cycle define how a sender's costs are split across multiple receivers, with the constraint that percentages for a given sender must sum to exactly 100%.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createAllocationRule](../commands/CreateAllocationRule.md) - Add an allocation rule to a DRAFT allocation cycle
- [deleteAllocationRule](../commands/DeleteAllocationRule.md) - Remove an allocation rule from a DRAFT allocation cycle

### Query Definitions

- [GetAllocationCycle](../queries/GetAllocationCycle.md) - Retrieve allocation rules as part of the parent allocation cycle

### Models

- AllocationRule

### Invariants

- Allocation rule must reference a valid allocation cycle via allocationCycleId
- Allocation rule can only be added to or removed from a DRAFT allocation cycle
- Allocation rule must reference a valid sender cost center
- Allocation rule must reference a valid receiver cost object (cost center, profit center, or internal order)
- A sender cost center cannot also appear as a receiver within the same allocation rule set
- Allocation rule percentage must be a positive value (greater than zero)
- Allocation rule percentages for a given sender must sum to exactly 100% across all rules in the cycle
- Allocation rules cannot be modified after the cycle leaves DRAFT status

### Relationships

- **Belongs to AllocationCycle**: Each allocation rule belongs to an AllocationCycle via allocationCycleId
- **References CostCenter (sender)**: Each allocation rule references a sender CostCenter via senderCostCenterId
- **Polymorphic Receiver**: Each allocation rule references a receiver via receiverType and receiverId, which can be a CostCenter, ProfitCenter, or InternalOrder
