# PurchaseRequisitionLineAllocation

## Description

PurchaseRequisitionLineAllocation is the audit-trail record that links a source PurchaseRequisitionLine to the PurchaseOrderLine created during the requisition-to-PO conversion process. Each allocation captures the quantity that was allocated from a specific requisition line to a specific purchase order line, providing full traceability from the original internal request through to the commercial commitment.

Allocation records are created automatically by the convertPurchaseRequisitionToPurchaseOrder command and are immutable once written. They allow procurement to answer "which requisition lines fed this PO line?" and "how much of this requisition line has been converted?" without scanning order-line back-references.

## Domain Model Definitions

### Model type

Standard

### Command Definitions

None — allocation records are created as a side effect of [convertPurchaseRequisitionToPurchaseOrder](../command/ConvertPurchaseRequisitionToPurchaseOrder.md) and have no dedicated commands.

### Query Definitions

None — no dedicated query exists.

### Models

- PurchaseRequisitionLineAllocation

### Invariants

- Each allocation record links exactly one PurchaseRequisitionLine to one PurchaseOrderLine
- `allocatedQuantity` must be greater than zero
- Allocation records are immutable once created; they serve as an audit trail
- The sum of `allocatedQuantity` across all allocations for a given requisition line must not exceed the requisition line's requested quantity
- Each allocation must reference a valid PurchaseRequisition, PurchaseRequisitionLine, PurchaseOrder, and PurchaseOrderLine

### Relationships

- **Belongs To PurchaseRequisition**: `purchaseRequisitionId` references the source [PurchaseRequisition](./PurchaseRequisition.md)
- **Belongs To PurchaseRequisitionLine**: `purchaseRequisitionLineId` references the source requisition line
- **Belongs To PurchaseOrder**: `purchaseOrderId` references the generated [PurchaseOrder](./PurchaseOrder.md)
- **Belongs To PurchaseOrderLine**: `purchaseOrderLineId` references the generated purchase order line
