# Procurement BC - Detailliertes Domain Model

**Bounded Context:** Procurement
**Domain Type:** CORE
**Verantwortung:** Bedarfsplanung, Bestellwesen, Wareneingangskontrolle, Lieferanten-QM

## Aggregates

### PurchaseOrder (Aggregate Root)

```
PurchaseOrder
├── PurchaseOrderId
├── SupplierId
├── OrderDate
├── RequestedDeliveryDate
├── Status (DRAFT | ORDERED | CONFIRMED | PARTIALLY_RECEIVED | FULLY_RECEIVED | CANCELLED)
├── OrderedBy (UserId)
├── BranchId
├── Items[] (Entity)
│   ├── ArticleId
│   ├── OrderedQuantity
│   ├── ReceivedQuantity - Updated on goods receipt
│   └── UnitPrice
├── TotalAmount - Calculated
└── PaymentTerms

Invariants:
- Status cannot skip states
- TotalAmount = SUM(Items.Quantity * Items.UnitPrice)
- ReceivedQuantity <= OrderedQuantity per item
- FULLY_RECEIVED when all items received
```

### GoodsReceipt (Aggregate Root)

```
GoodsReceipt
├── GoodsReceiptId
├── PurchaseOrderId
├── SupplierId
├── SupplierDeliveryNote
├── ReceivedAt
├── ReceivedBy (UserId)
├── Items[] (Entity)
│   ├── ArticleId
│   ├── OrderedQuantity
│   ├── ReceivedQuantity
│   ├── SupplierBatchNumber - CRITICAL for traceability!
│   ├── ExpiryDate (MHD)
│   └── QualityStatus (ACCEPTED | REJECTED | PENDING_INSPECTION)
├── QualityInspectionId - Reference to Quality BC
├── Documents[] (Entity) - Photos/PDFs
└── Status (PENDING_INSPECTION | ACCEPTED | REJECTED)

Invariants:
- Cannot accept without completed quality inspection
- All items must have SupplierBatchNumber
- Veterinary certificate required for meat
- Triggers StockMovement when accepted
```

### DemandPlan (Aggregate Root)

```
DemandPlan
├── DemandPlanId
├── PlanningPeriod (Week or Month)
├── BranchId
├── GeneratedAt
├── Items[] (Entity)
│   ├── ArticleId
│   ├── CurrentStock - Snapshot from Inventory
│   ├── PlannedConsumption - From ProductionOrders
│   ├── AverageConsumption - Historical
│   ├── SuggestedOrderQuantity - Calculated
│   └── MinimumOrderQuantity - Supplier constraint
└── Status (DRAFT | APPROVED | ORDERED)

Invariants:
- SuggestedOrderQuantity = PlannedConsumption - CurrentStock + SafetyStock
- If < MinimumOrderQuantity, use MinimumOrderQuantity
```
