# Filiales BC - Detailliertes Domain Model **Bounded Context:** Filiales **Domain Type:** CORE **Verantwortung:** Mehrfilialen-Management, Interfilial-Transfers, zentrale Produktion ## Aggregates ### Branch (Aggregate Root) ``` Branch ├── BranchId ├── BranchName ├── BranchType (PRODUCTION_AND_SALES | SALES_ONLY | PRODUCTION_ONLY) ├── Address ├── OpeningHours ├── Status (ACTIVE | INACTIVE | CLOSED) ├── Manager (UserId) ├── ContactInfo ├── Capabilities │ ├── CanProduce (boolean) │ ├── CanSell (boolean) │ └── CanReceiveGoods (boolean) └── AssignedEmployees[] (UserId) Invariants: - BranchType must match Capabilities - Manager must be in AssignedEmployees - Cannot close with pending production orders ``` ### InterBranchTransfer (Aggregate Root) ``` InterBranchTransfer ├── TransferId ├── FromBranch (BranchId) ├── ToBranch (BranchId) ├── TransferDate ├── RequestedBy (UserId) ├── Status (REQUESTED | APPROVED | IN_TRANSIT | RECEIVED | CANCELLED) ├── Items[] (Entity) │ ├── ArticleId │ ├── BatchId - CRITICAL for traceability! │ ├── Quantity │ ├── ExpiryDate │ └── ReceivedQuantity ├── ShippedAt ├── ReceivedAt └── TransportDocumentId Invariants: - FromBranch != ToBranch - Status: REQUESTED → APPROVED → IN_TRANSIT → RECEIVED - ShippedAt < ReceivedAt - Triggers two StockMovements (out + in) ``` ### DistributionPlan (Aggregate Root) ``` DistributionPlan ├── DistributionPlanId ├── ProductionBatchId - From Production BC ├── ProducingBranch (BranchId) ├── PlannedFor (Date) ├── Status (PLANNED | IN_DISTRIBUTION | COMPLETED) ├── Distributions[] (Entity) │ ├── TargetBranch (BranchId) │ ├── AllocatedQuantity │ ├── TransferId - Link to InterBranchTransfer │ └── DeliveryStatus (PENDING | SHIPPED | DELIVERED) ├── TotalQuantityProduced └── RemainingAtCentral Invariants: - SUM(AllocatedQuantity) + RemainingAtCentral = TotalQuantityProduced - ProducingBranch must be PRODUCTION_ONLY or PRODUCTION_AND_SALES ```