Warehouse management (WMS) · Supporting domain · EventStorming board
returns-processing
Handles returned goods: authorizes a return for a shipped line, receives and grades the parcel, decides its fate and hands restockable units to stock.
- events published
- 7
- commands
- 11
- policies
- 8
- read models
- 4
- hot spots
- 4
The story in 5 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventReturn
Authorized - Pivotal eventReturn
Receipt Opened - Pivotal eventReturn
Line Inspected - Pivotal eventDisposition
Decided - Pivotal eventReturn
Line Staged
Listens to (3): contexts whose events this one reacts to
Tells (2): contexts that react to its events
The board, row by row
11 rows, in the order the business story happens: the main path first, then how this context reacts to the others, then the clock. Rows are small stories; read each one left to right.
- Event
- Command
- Actor
- Aggregate
- Policy
- Read model
- External system
- Hot spot
- Opportunity
-
Keep the product classes
product-master classifies each product (for example hazmat or temperature class). Returns keeps the latest version as a local copy, so grading never needs a live call.
Systemproduct-master EventProductClassified PolicyWhenever a product is classified, keep it if its version is newer than the copyCommandApplyProduct started by the policyClassification Read model · kept up to dateProduct classesSource: application/usecases/consume_classifications.go · adapters/inbound/kafka/product_classes.go
-
Keep the allocated order lines
order-management announces which order lines were allocated and with which product. Returns keeps them, so a return request never has to name the product itself.
Systemorder-management EventOrderAllocated PolicyWhenever order lines are allocated, store each line with its productCommandApplyAllocations started by the policyRead model · kept up to dateAllocated linesSource: application/usecases/consume_allocations.go · adapters/inbound/kafka/allocated_lines.go
-
Keep the manifested packages
fulfillment-execution reports each manifested package. A line with a manifested package is proof that it shipped, which a return needs.
Systemfulfillment-execution EventPackageManifested PolicyWhenever a package is manifested, record which order line it carriedCommandApplyManifest started by the policyRead model · kept up to dateManifested packagesSource: application/usecases/consume_manifests.go · adapters/inbound/kafka/manifests.go
-
Set the return rules
An operator declares a version of the disposition policy: return window, unit cap per line and which outcome each grade and product class gets. The newest version becomes current.
ActorOperatorCommandDeclareDisposition PUT /disposition-policies/{version}Policy AggregateDispositionPolicy Source: application/usecases/declare_disposition_policy.go · domain/disposition/policy.go
-
Authorize a return
An operator asks to take back units of a shipped order line. It is authorized only if the line shipped, the window is open, no other return is open for it and the quantity is within the cap.
ActorOperatorRead modelAllocated linesRead modelManifested packagesRead modelCurrent return rulesCommandAuthorizeReturn POST /returnsAggregateRMAEventReturnAuthorized Source: application/usecases/authorize_return.go · domain/returnauthorization/rma.go
-
Refuse a return request (event not raised yet)
A refused request is answered with an error and nothing is saved or published. The refusal event and the reject step exist in the domain, but no use case raises them yet.
ActorOperatorCommandRejectReturn started by the policyAggregateRMAEventReturnAuthorization Rejected Source: application/usecases/authorize_return.go · domain/returnauthorization/rma.go · domain/returnauthorization/events.go
-
Open a receipt for the arrived parcel
A parcel arrives. Every line is either matched to a return authorization or recorded as unexpected, never silently accepted.
ActorOperatorCommandOpenReturn POST /returns/{rmaId}/receiptsReceipt AggregateReceiptEventReturnReceipt Opened EventUnexpectedReturn Received Systemexception-management PolicyOpens a case for each unexpected lineSource: application/usecases/open_return_receipt.go · domain/returnreceipt/receipt.go
-
Grade a returned line
An inspector grades one received line A, B, C or SCRAP, with reason codes. Each line is graded exactly once, for no more units than were received.
ActorInspectorCommandInspectReturn POST /receipts/{receiptId}/lines/{lineNo}/inspectionsLine AggregateReceiptEventReturnLine Inspected Source: application/usecases/inspect_return_line.go · domain/returnreceipt/receipt.go
-
Decide what happens to the line
In the same step as the grading, the rules turn grade, product class and current policy into an outcome. A RESTOCK below grade B, or of hazmat with no hazard rating, is swapped for the policy's fallback outcome.
Event · earlierReturnLine Inspected PolicyWhenever a line is graded, decide its outcome from the grade, product class and policyRead modelProduct classesRead modelCurrent return rulesCommandDecideDisposition started by the policyAggregateDispositionEventDispositionDecided Source: application/usecases/inspect_return_line.go · domain/disposition/disposition.go · domain/disposition/policy.go
-
Hand restockable units to stock
When the outcome is RESTOCK, the line is staged exactly once so the warehouse stock can take the units back. No other outcome touches another context.
Event · earlierDispositionDecided PolicyWhenever the outcome is RESTOCK, stage the line once for inventory-storageCommandStageReturn started by the policyLine AggregateDispositionEventReturnLine Staged Systeminventory-storage PolicyBooks the returned units as staged stockSource: application/usecases/inspect_return_line.go · domain/disposition/disposition.go · domain/disposition/events.go
-
Override a decision
An operator replaces an outcome and must give a reason. The original is kept; a new decision points back to it. An override to RESTOCK stages the line like any other.
ActorOperatorCommandOverrideDisposition POST /dispositions/{dispositionId}/overridesAggregateDispositionEventDispositionDecided EventReturnLine Staged Systeminventory-storage PolicyBooks the returned units as staged stockSource: application/usecases/override_disposition.go · domain/disposition/disposition.go
Hot spots and opportunities
Open questions and known gaps, each taken from a decision record or a document in the repository, never invented. Opportunities are improvements the documentation already names.
- Hot spotThe shipped quantity is unknown: allocated lines carry no quantity, so a return is capped by the policy only.
- Hot spotThe refusal event is declared but no use case raises it. A refused request answers with an error and leaves no trace.
Source: apis/asyncapi.yaml
- Hot spotA staged line's stow is invisible here, so nothing shows that restocked units reached a bin.
- Hot spotNo use case moves a return authorization past AUTHORIZED. The receipt alone carries the arrival.
Source: docs/ddd/eventstorming.md
Opportunities
- OpportunityA shipped-quantity check per line is planned once order-management adds a quantity to its allocated lines.
- OpportunityConsuming the stowed-item fact from inventory-storage could close the loop from a staged line to a bin.
This board is a reconstruction from the code and documentation of returns-processing at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.