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.

GitHub ↗ · Documentation ↗ · Architecture check · Briefings

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.

  1. Pivotal eventReturnAuthorized
  2. Pivotal eventReturnReceiptOpened
  3. Pivotal eventReturnLineInspected
  4. Pivotal eventDispositionDecided
  5. Pivotal eventReturnLineStaged

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
  1. 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 copy
    CommandApplyProductClassificationstarted by the policy
    Read model · kept up to dateProduct classes

    Source: application/usecases/consume_classifications.go · adapters/inbound/kafka/product_classes.go

  2. 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 product
    CommandApplyAllocationsstarted by the policy
    Read model · kept up to dateAllocated lines

    Source: application/usecases/consume_allocations.go · adapters/inbound/kafka/allocated_lines.go

  3. 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 carried
    CommandApplyManifeststarted by the policy
    Read model · kept up to dateManifested packages

    Source: application/usecases/consume_manifests.go · adapters/inbound/kafka/manifests.go

  4. 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.

    ActorOperator
    CommandDeclareDispositionPolicyPUT /disposition-policies/{version}
    AggregateDispositionPolicy

    Source: application/usecases/declare_disposition_policy.go · domain/disposition/policy.go

  5. 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.

    ActorOperator
    Read modelAllocated lines
    Read modelManifested packages
    Read modelCurrent return rules
    CommandAuthorizeReturnPOST /returns
    AggregateRMA
    EventReturnAuthorized

    Source: application/usecases/authorize_return.go · domain/returnauthorization/rma.go

  6. 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.

    ActorOperator
    CommandRejectReturnstarted by the policy
    AggregateRMA
    EventReturnAuthorizationRejected

    Source: application/usecases/authorize_return.go · domain/returnauthorization/rma.go · domain/returnauthorization/events.go

  7. 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.

    ActorOperator
    CommandOpenReturnReceiptPOST /returns/{rmaId}/receipts
    AggregateReceipt
    EventReturnReceiptOpened
    EventUnexpectedReturnReceived
    Systemexception-management
    PolicyOpens a case for each unexpected line

    Source: application/usecases/open_return_receipt.go · domain/returnreceipt/receipt.go

  8. 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.

    ActorInspector
    CommandInspectReturnLinePOST /receipts/{receiptId}/lines/{lineNo}/inspections
    AggregateReceipt
    EventReturnLineInspected

    Source: application/usecases/inspect_return_line.go · domain/returnreceipt/receipt.go

  9. 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 · earlierReturnLineInspected
    PolicyWhenever a line is graded, decide its outcome from the grade, product class and policy
    Read modelProduct classes
    Read modelCurrent return rules
    CommandDecideDispositionstarted by the policy
    AggregateDisposition
    EventDispositionDecided

    Source: application/usecases/inspect_return_line.go · domain/disposition/disposition.go · domain/disposition/policy.go

  10. 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-storage
    CommandStageReturnLinestarted by the policy
    AggregateDisposition
    EventReturnLineStaged
    Systeminventory-storage
    PolicyBooks the returned units as staged stock

    Source: application/usecases/inspect_return_line.go · domain/disposition/disposition.go · domain/disposition/events.go

  11. 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.

    ActorOperator
    CommandOverrideDispositionPOST /dispositions/{dispositionId}/overrides
    AggregateDisposition
    EventDispositionDecided
    EventReturnLineStaged
    Systeminventory-storage
    PolicyBooks the returned units as staged stock

    Source: 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.

Opportunities

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.