mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 15:59:35 +01:00
68 lines
2 KiB
Markdown
68 lines
2 KiB
Markdown
# Inventory BC - Detailliertes Domain Model
|
|
|
|
**Bounded Context:** Inventory
|
|
**Domain Type:** CORE
|
|
**Verantwortung:** Chargen-basierte Bestandsführung, Rückverfolgbarkeit, MHD-Tracking
|
|
|
|
## Aggregates
|
|
|
|
### Stock (Aggregate Root)
|
|
|
|
```
|
|
Stock
|
|
├── StockId
|
|
├── ArticleId - Reference to Master Data
|
|
├── StorageLocationId
|
|
├── BranchId
|
|
├── StockLevel (Quantity) - Current total
|
|
├── Batches[] (Entity) - Batch-level inventory (CRITICAL!)
|
|
│ ├── BatchId - ProductionBatchId OR SupplierBatchId
|
|
│ ├── BatchType (PRODUCED | PURCHASED)
|
|
│ ├── Quantity
|
|
│ ├── ExpiryDate (MHD)
|
|
│ ├── ReceivedAt
|
|
│ └── Status (AVAILABLE | RESERVED | EXPIRED | SOLD)
|
|
├── MinimumStockLevel
|
|
└── ReorderPoint
|
|
|
|
Invariants:
|
|
- StockLevel = SUM(Batches.Quantity where Status = AVAILABLE)
|
|
- Cannot withdraw more than available
|
|
- FEFO enforced: oldest expiry first
|
|
- Negative stock not allowed
|
|
- Expired batches must have Status = EXPIRED
|
|
```
|
|
|
|
### StockMovement (Aggregate Root) - Event Sourcing candidate!
|
|
|
|
```
|
|
StockMovement
|
|
├── StockMovementId
|
|
├── ArticleId
|
|
├── BatchId - CRITICAL for traceability
|
|
├── MovementType (GOODS_RECEIPT | PRODUCTION_OUTPUT | SALE |
|
|
│ INTER_BRANCH_TRANSFER | WASTE | ADJUSTMENT)
|
|
├── FromLocation, ToLocation
|
|
├── FromBranch, ToBranch
|
|
├── Quantity
|
|
├── MovementDate
|
|
├── PerformedBy (UserId)
|
|
├── Reason (for WASTE/ADJUSTMENT)
|
|
├── ReferenceDocument (GoodsReceiptId, ProductionOrderId, InvoiceId)
|
|
└── TraceabilityChain - Link to upstream/downstream
|
|
|
|
Invariants:
|
|
- Quantity must be positive
|
|
- GOODS_RECEIPT: FromLocation = null
|
|
- SALE/WASTE: ToLocation = null
|
|
- INTER_BRANCH_TRANSFER: FromBranch != ToBranch
|
|
- All movements must reference a Batch
|
|
```
|
|
|
|
## Domain Events
|
|
|
|
```java
|
|
StockLevelBelowMinimum(ArticleId, BranchId, Quantity)
|
|
BatchExpiringSoon(BatchId, ArticleId, ExpiryDate)
|
|
StockMovementRecorded(StockMovementId, BatchId, MovementType)
|
|
```
|