Use Cases
Derived from network/model/model.yaml. This context's service is built (IQVO/seller-inbound, designed by ADR 0009); the model carries its as-built contracts, and identifiers (Err... names, routes, CloudEvents types) are the names the service uses. Where the model left a choice open, the service's own ADRs 0002 to 0005 record what it does.
One application service per command in
contexts[seller-inbound].aggregates[*].commands, under
internal/application/usecases. Runtime views of the key ones are on
Sequence Diagrams.
Reads (GetInboundPlan, GetInboundShipment, GetLabels) go straight to the repository;
GetSellerScorecard (GET /sellers/{sellerId}/scorecard, service ADR 0005) computes an
informational scorecard from this service's own facts and changes nothing.
GetSellerCapacityAllocations
(GET /sellers/{sellerId}/capacity-allocations?month=, service ADR 0015) reads
the seller's inbound capacity reservations of one calendar month (month is a
YYYY-MM key and defaults to the current month), ordered by nodeId; it
publishes no event, an unknown seller answers 404 and a malformed month 422.
Conventions for every use case
- Errors are RFC 9457
application/problem+json: validation422, conflict or state409, not found404, stale version409. - Idempotency-Key on every
POST. A repeat with the same key returns the first response. - One transaction per use case: the aggregate change, its outbox rows, and (for consumers) the inbox row commit together.
- Read models are local.
NodeInboundViewandCatalogPackagingVieware read inside the use case; no synchronous call leaves the context.
| Model error | HTTP | Problem type |
|---|---|---|
ErrSellerExists | 409 | seller-exists |
ErrSellerSuspended | 409 | seller-suspended |
ErrNodeCannotReceive | 409 | node-cannot-receive |
ErrCasePackNotUniform | 422 | case-pack-not-uniform |
ErrCaseQtyMismatchesGtin | 422 | case-qty-mismatches-gtin |
ErrCartonOverweight | 422 | carton-overweight |
ErrCartonOversize | 422 | carton-oversize |
ErrSsccNotUnique | 409 | sscc-not-unique |
ErrInvalidSscc | 422 | invalid-sscc |
ErrCartonContentsMismatchPlan | 422 | carton-contents-mismatch-plan |
ErrShipmentNotLabelled | 409 | shipment-not-labelled |
ErrInboundCapacityExceeded | 422 | inbound-capacity-exceeded |
ErrNetworkSplitDestination | 422 | network-split-destination |
ErrNetworkSplitUnavailable | 422 | network-split-unavailable |
ErrInvalidWindow (scorecard read) | 400 | invalid-window |
ErrValidation, ErrNotFound, ErrIllegalTransition, ErrConcurrentUpdate | 422, 404, 409, 409 | the shared slugs from conventions.errors |
OnboardSeller
- Actor / trigger: a seller or its portal. REST
POST /sellers. - Flow: validate
sellerId(anownerRef: at most 64 characters of letters, digits,.,_,-; a:is refused, unlike the opaque plan, shipment and node ids) andname; saveACTIVE; writeSellerOnboardedto the outbox. - Errors:
ErrSellerExists,ErrValidation. - Events:
SellerOnboarded.
SuspendSeller / ReinstateSeller
- Actor: network partner manager. REST
POST /sellers/{sellerId}/suspensionsandPOST /sellers/{sellerId}/reinstatements. - Flow:
ACTIVE↔SUSPENDED. A suspended seller's laterCreateInboundPlan,ConfirmInboundPlan,CreateInboundShipment,AddCarton,LabelShipmentandShipInboundShipmentare refused. Shipments alreadySHIPPEDstill close. - Repeat: suspending a
SUSPENDEDseller, or reinstating anACTIVEone, is a no-op:200with the account unchanged and no event (service ADR 0002 A3). It is not anErrIllegalTransition. The seller account is the only aggregate that is idempotent by state; every other command is strict. - Errors:
ErrNotFound. - Events:
SellerSuspended,SellerReinstated(a repeat raises none).
CreateInboundPlan
- Actor: seller. REST
POST /inbound-plans. - Preconditions: seller
ACTIVE; destination nodeACTIVEwithINBOUNDinNodeInboundView. - Flow: validate each line (1 to 500 lines, one per catalogue item; whether
the item is live is not checked, since no
CatalogItemCreatedorCatalogItemDiscontinuedis consumed; GTIN of 8, 12, 13 or 14 digits with a valid check digit, normalised to 14 digits,qtyEaches > 0, an optionalunitVolumeDm3of 1 to 100000). Run the monthly capacity gate (service ADR 0015): when the node declaresmonthlyVolumeDm3and every line declaresunitVolumeDm3, the seller's reserved volume for the (month, node) plus the plan's volume must stay within the node's monthly volume times the seller's tier factor (GOOD100%,WATCH80%,AT_RISK50%); when either side is unknown the plan is allowed and recordscapacityEnforced: false. ANETWORK_SPLITplan must destination anACTIVEINBOUND_CROSS_DOCKwhose region holds at least oneACTIVEFULFILLMENT_CENTER, and records its redistribution (capacity-split-v1) and fee basis. Reserve the plan's volume and saveDRAFT. The plan is not checked againstCatalogPackagingView: whether aCASE_PACKEDitem has an active CASE level is enforced onAddCarton, not here (service use-cases page,CreateInboundPlan). - Errors:
ErrSellerSuspended,ErrNodeCannotReceive,ErrValidation,ErrInboundCapacityExceeded,ErrNetworkSplitDestination,ErrNetworkSplitUnavailable. - Events: none (
DRAFTis private to the seller).
ConfirmInboundPlan / CancelInboundPlan
- REST:
POST /inbound-plans/{planId}/confirmationsandPOST /inbound-plans/{planId}/cancellations. - Flow:
DRAFT → CONFIRMEDre-checks seller and node and keeps the capacity reservation;DRAFT → CANCELLEDreleases it (service ADR 0015).CONFIRMEDandCANCELLEDare terminal: a second confirm or cancel isErrIllegalTransition(service ADR 0002 A3). - Errors:
ErrSellerSuspended,ErrNodeCannotReceive,ErrIllegalTransition. - Events:
InboundPlanConfirmed(confirm only).
CreateInboundShipment
- REST:
POST /inbound-plans/{planId}/shipments. - Preconditions: plan
CONFIRMED; sellerACTIVE; node still receivable. - Flow: create an empty
DRAFTshipment for the plan's destination node. - Errors:
ErrIllegalTransition,ErrSellerSuspended,ErrNodeCannotReceive.
AddCarton
- REST:
POST /inbound-shipments/{shipmentId}/cartons. - Preconditions: shipment
DRAFT. - Flow:
- Validate contents (GTINs,
qtyEaches > 0, optionallotup to 20 characters andexpirydate). HOMOGENEOUS_CASE(every carton of aCASE_PACKEDplan): one item,gtinis the CASE-level GTIN,qtyEachesequals theunitsPerPackof the item's active CASE level, checked here and not at plan creation (ErrCaseQtyMismatchesGtin); the carton holds exactly one item, one GTIN and one quantity (ErrCasePackNotUniform).MIXED: contents are each-level GTINs and the carton gets no pack GTIN.- Check weight and dimensions against the node's
inboundlimits. - SSCC: a supplied one must be valid and unique (
SsccIssuance); otherwise issue one from the network's company prefix. - Save the carton; return it with its label reference.
- Validate contents (GTINs,
- Errors:
ErrCasePackNotUniform,ErrCaseQtyMismatchesGtin,ErrCartonOverweight,ErrCartonOversize,ErrInvalidSscc,ErrSsccNotUnique,ErrSellerSuspended,ErrIllegalTransition. - Idempotency: the SSCC itself is a natural key: re-adding the same SSCC
to the same shipment with the same key returns the first response; with a
new key it is
ErrSsccNotUnique.
LabelShipment
- REST:
POST /inbound-shipments/{shipmentId}/labels. - Flow:
DRAFT → LABELLED. A plan may be filled by several shipments over time. When this is the plan's only shipment, the eaches per item and GTIN over its cartons must equal the confirmed plan's lines, every line exactly (Shipment.LabelwithSingleShipment). When the plan has several shipments no exact match is required at labelling:AddCartonhas already kept every item on the plan and the total over this shipment and the plan's other shipments within each plan line (service use-cases page). After this,GET .../labelsreturns one printable label per carton. - Errors:
ErrCartonContentsMismatchPlan,ErrSellerSuspended,ErrIllegalTransition. - Events:
InboundShipmentLabelled(the carton manifest, with contents, weights and sizes).
ShipInboundShipment
- REST:
POST /inbound-shipments/{shipmentId}/dispatches. - Flow:
LABELLED → SHIPPED, re-checks the node and the seller. - Errors:
ErrShipmentNotLabelled,ErrNodeCannotReceive,ErrSellerSuspended. - Events:
InboundShipmentShipped(shippedAt; the manifest was published onInboundShipmentLabelled).
RecordInboundReceipt
- Trigger: consumer of
InboundReceiptSubmitted(no HTTP). - Flow: for each carton in the receipt, store its status and the received
eaches per GTIN. Raise
InboundDiscrepancyRecordedfor eachMISSING,UNEXPECTEDorDAMAGEDcarton and each quantity difference, andSellerComplianceViolationRecordedonce per distinct compliance code on a carton; an unexpected carton also raises the codeUNMANIFESTED_CARTON(service ADR 0002 A8). When every carton of the manifest has a final status the shipment closes:CLOSEDif nothing differs, otherwiseCLOSED_WITH_DISCREPANCY, andInboundShipmentReceivedis raised. Otherwise it staysRECEIVING. - Errors: none returned. A receipt for a shipment that does not exist is
dead-lettered at once to
<topic>.dlq(service ADR 0003); the Vendor API normally refuses it first with 404not-found. - Idempotency: the CloudEvents
idin the inbox; a repeated carton status is not recounted.