mirror of
https://github.com/s-frick/effigenix.git
synced 2026-03-28 12:19:35 +01:00
init
This commit is contained in:
commit
4e448afa57
19 changed files with 4391 additions and 0 deletions
68
docs/mvp/ddd/07-inventory-bc.md
Normal file
68
docs/mvp/ddd/07-inventory-bc.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# 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)
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue