---
id: ATS-COM-ORD-016
scope: CAP-COM-ORD-016
product_area: commerce
module: orders
revision: 2
status: proposed
approved_by: null
approved_at: null
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
scenarios:
  - id: ATS-COM-ORD-016-01
    title: Return access requires an accepted permitted purchase
    level: api
    proves:
      - BR-CAP-COM-ORD-016-01
    preconditions: 'The fixtures include a placed order, excessive requested quantity and unauthorized contexts.'
    steps:
      - do: Request returns for the cases.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#refuses a placed order 409
          order_not_returnable, more units than the line has (rejected), another member 403, a reader 403,
          another tenant 404
    expected: 'The placed order and unauthorized calls fail, and excessive quantity produces a rejected plan.'
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#refuses a placed order 409
        order_not_returnable, more units than the line has (rejected), another member 403, a reader 403,
        another tenant 404
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#refuses a placed order 409
      order_not_returnable, more units than the line has (rejected), another member 403, a reader 403, another
      tenant 404
    category: permission
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#refuses a placed order 409
      order_not_returnable, more units than the line has (rejected), another member 403, a reader 403, another
      tenant 404
  - id: ATS-COM-ORD-016-02
    title: Return terms choose specificity and preserve promises
    level: unit
    proves:
      - BR-CAP-COM-ORD-016-02
    preconditions: 'Product, store and default policies coexist with more generous frozen terms.'
    steps:
      - do: Resolve and merge the policy facts.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#defaults to 30 days from
          delivery, approval outside the window, refund on receipt, no fee, restock, quarantine and scrap
    expected: The applicable specific policy or built-in defaults apply without reducing the frozen promise.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#defaults to 30 days from
        delivery, approval outside the window, refund on receipt, no fee, restock, quarantine and scrap
      - >-
        services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#picks the most specific
        configured policy, else the built-in default, and loosens it by the frozen terms
      - TST-COM-ORD-142
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#defaults to 30 days from
      delivery, approval outside the window, refund on receipt, no fee, restock, quarantine and scrap
    category: rule
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#defaults to 30 days from
      delivery, approval outside the window, refund on receipt, no fee, restock, quarantine and scrap
  - id: ATS-COM-ORD-016-03
    title: In-window return supplies receiving authority
    level: api
    proves:
      - BR-CAP-COM-ORD-016-03
    preconditions: The accepted shirt purchase is inside the allowed window.
    steps:
      - do: Request its return.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
          policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
    expected: A numbered authorization records the deadline and permitted line with instructions to return it.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
        policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
      policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
      policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
  - id: ATS-COM-ORD-016-04
    title: Late returns wait for an authorized decision
    level: api
    proves:
      - BR-CAP-COM-ORD-016-04
    preconditions: The fixture purchase is outside the policy window.
    steps:
      - do: 'Request, authorize and reject the review cases and test unauthorized approval access.'
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s request for
          approval; the approver authorizes it and the RMA is issued
    expected: >-
      The request waits, an authorized decision issues an authorization or reasoned rejection and unauthorized
      calls fail.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s request for
        approval; the approver authorizes it and the RMA is issued
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the approver reject one with a
        reason; a member on the console route and a clerk are refused
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s request for approval;
      the approver authorizes it and the RMA is issued
    category: permission
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s request for approval;
      the approver authorizes it and the RMA is issued
  - id: ATS-COM-ORD-016-05
    title: Final-sale exceptions need an administrator
    level: api
    proves:
      - BR-CAP-COM-ORD-016-05
    preconditions: The product policy declares final sale.
    steps:
      - do: Request as a member and repeat with an administrator override.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#rejects the member with final_sale;
          the administrator’s override authorizes it
    expected: The ordinary plan rejects final_sale and the recorded override authorizes the return.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#rejects the member with final_sale; the
        administrator’s override authorizes it
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#rejects the member with final_sale; the
      administrator’s override authorizes it
    category: permission
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#rejects the member with final_sale; the
      administrator’s override authorizes it
  - id: ATS-COM-ORD-016-06
    title: Partial receipt keeps authorization open
    level: api
    proves:
      - BR-CAP-COM-ORD-016-06
    preconditions: Two returned units use receipt-based settlement.
    steps:
      - do: Receive one unit and then the second.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
          goods back on the line, the memo and the refund run, the document completed and the RMA closed
    expected: >-
      The first receipt remains partial; completed receipt and settlement close the document and
      authorization.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
        goods back on the line, the memo and the refund run, the document completed and the RMA closed
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#leaves the document partially received
        with the RMA open after one of two units, and completes it after the second
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the goods
      back on the line, the memo and the refund run, the document completed and the RMA closed
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the goods
      back on the line, the memo and the refund run, the document completed and the RMA closed
  - id: ATS-COM-ORD-016-07
    title: Restocking settlement deducts its fee
    level: api
    proves:
      - BR-CAP-COM-ORD-016-07
    preconditions: The return policy imposes a ten-percent restocking fee.
    steps:
      - do: Receive the goods and test staff and member financial-action selection.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking
          fee as an invoice paid from the freed money, and refunds the rest
    expected: The fee is invoiced from freed money and the remainder settles; only staff can choose credit treatment.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking fee
        as an invoice paid from the freed money, and refunds the rest
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets staff ask for a credit, and
        refuses a member the money action
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking fee
      as an invoice paid from the freed money, and refunds the rest
    category: rule
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking fee
      as an invoice paid from the freed money, and refunds the rest
  - id: ATS-COM-ORD-016-08
    title: Return-label deduction stays within refundable money
    level: api
    proves:
      - BR-CAP-COM-ORD-016-08
    preconditions: Customer-paid and organization-paid bought labels coexist with a no-purchase case.
    steps:
      - do: Settle the return and evaluate the fee cap.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#expects the deduction on the RMA and
          tells the customer the refund is less the return label (USD 8.40)
    expected: >-
      A bought customer label contributes 8.40 in the fixture, other cases deduct nothing and the cap leaves
      no negative refund.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#expects the deduction on the RMA and
        tells the customer the refund is less the return label (USD 8.40)
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#invoices the label on the return label
        fee product, pays it from the freed money and refunds the rest
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#deducts nothing when the tenant pays
        the label, though the carrier sold one
      - >-
        services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#never deducts more than the
        refund has left after the other fees: the refund’s floor is zero (D-P7-32)
      - TST-COM-ORD-084
      - TST-COM-ORD-142
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#expects the deduction on the RMA and
      tells the customer the refund is less the return label (USD 8.40)
    category: boundary
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#expects the deduction on the RMA and
      tells the customer the refund is less the return label (USD 8.40)
  - id: ATS-COM-ORD-016-09
    title: Policy scope prevents duplicate administration
    level: api
    proves:
      - BR-CAP-COM-ORD-016-09
    preconditions: A scoped policy already exists.
    steps:
      - do: 'Create a duplicate, create a malformed default, attempt portal listing and delete the original.'
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lists, reads and deletes the policy;
          refuses a member the policies, a second policy at the scope 400, a tenant default with a scope id
          400
    expected: The malformed creations and portal read fail while authorized deletion succeeds.
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lists, reads and deletes the policy;
        refuses a member the policies, a second policy at the scope 400, a tenant default with a scope id 400
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lists, reads and deletes the policy;
      refuses a member the policies, a second policy at the scope 400, a tenant default with a scope id 400
    category: validation
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lists, reads and deletes the policy;
      refuses a member the policies, a second policy at the scope 400, a tenant default with a scope id 400
  - id: ATS-COM-ORD-016-10
    title: Withdrawal closes return receiving authority
    category: transition
    level: api
    proves:
      - BR-CAP-COM-ORD-016-10
    preconditions: An authorized return occupies a purchased line.
    steps:
      - do: 'Attempt a duplicate, withdraw the first and inspect the receiving notification.'
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the member withdraw an
          authorized return: the RMA closed and the streams told; a line already under a return refused
          meanwhile
    expected: The duplicate is refused and the first authorization closes with receiving informed.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the member withdraw an authorized
        return: the RMA closed and the streams told; a line already under a return refused meanwhile
      - TST-COM-ORD-084
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the member withdraw an authorized
      return: the RMA closed and the streams told; a line already under a return refused meanwhile
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the member withdraw an authorized
      return: the RMA closed and the streams told; a line already under a return refused meanwhile
  - id: ATS-COM-ORD-016-11
    title: Later policy cannot charge a promised organization-paid label
    category: invariant
    level: unit
    proves:
      - BR-CAP-COM-ORD-016-11
    preconditions: Frozen terms promise an organization-paid label and the later policy charges the customer.
    steps:
      - do: Resolve the return label terms.
        provenance: test
        source: >-
          services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#keeps a label the frozen
          terms promised at the tenant’s cost from being charged to the customer later
    expected: The resulting label remains at the organization’s expense.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#keeps a label the frozen
        terms promised at the tenant’s cost from being charged to the customer later
      - TST-COM-ORD-142
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#keeps a label the frozen terms
      promised at the tenant’s cost from being charged to the customer later
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#keeps a label the frozen terms
      promised at the tenant’s cost from being charged to the customer later
  - id: ATS-COM-ORD-016-12
    title: Returned goods restore their original acquisition cost
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-016-06
      - BR-CAP-COM-ORD-018-08
    preconditions: A shipped line has identified layer relief and a receipt-based return authorization.
    steps:
      - do: Receive part of the goods and then the remainder; inspect cost restoration and settlement.
        provenance: proposed
        source:
          - >-
            services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
            goods back on the line, the memo and the refund run, the document completed and the RMA closed
          - >-
            services-commerce:modules/purchasing/tests/integration/services/receiving/purchasing-flow.integration.spec.js#restores
            5 returned units at the relieved cost and place: a restore row naming the relief it reverses, a
            layer at that cost dated with the original layer, a restore_cogs fact of 5 × that cost
    expected: >-
      Partial receiving leaves the authorization open and cost restoration reverses the original relief as the
      completed return settles.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
        goods back on the line, the memo and the refund run, the document completed and the RMA closed
      - >-
        services-commerce:modules/purchasing/tests/integration/services/receiving/purchasing-flow.integration.spec.js#restores
        5 returned units at the relieved cost and place: a restore row naming the relief it reverses, a layer
        at that cost dated with the original layer, a restore_cogs fact of 5 × that cost
    exercises:
      - CAP-COM-ORD-016
      - CAP-COM-ORD-018
    related_capabilities:
      - CAP-COM-ORD-018
    expected_provenance: proposed
    expected_source:
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
        goods back on the line, the memo and the refund run, the document completed and the RMA closed
      - >-
        services-commerce:modules/purchasing/tests/integration/services/receiving/purchasing-flow.integration.spec.js#restores
        5 returned units at the relieved cost and place: a restore row naming the relief it reverses, a layer
        at that cost dated with the original layer, a restore_cogs fact of 5 × that cost
  - id: ATS-COM-ORD-016-13
    title: Return receipt and original-cost restoration commit together
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-016-01
      - BR-CAP-COM-ORD-018-01
    preconditions: A delivered product has recorded shipment cost relief and a receipt-based return.
    steps:
      - do: 'Authorize and receive its goods, then inspect quantities, restored layers and settlement.'
        provenance: proposed
        source:
          - 'services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js'
          - >-
            services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the
            built-in policy: the RMA numbered with its deadline, the lines authorized, the customer told to
            send it back
          - >-
            services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the approver reject one with a
            reason; a member on the console route and a clerk are refused
          - >-
            services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
            goods back on the line, the memo and the refund run, the document completed and the RMA closed
          - >-
            services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking
            fee as an invoice paid from the freed money, and refunds the rest
          - 'services-commerce:modules/operations/services/reconciler/reconciler.ts'
    expected: >-
      Received quantities and original-cost restoration share the receiving outcome; settlement uses the
      authorized goods.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - 'services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js'
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
        policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the approver reject one with a
        reason; a member on the console route and a clerk are refused
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
        goods back on the line, the memo and the refund run, the document completed and the RMA closed
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking fee
        as an invoice paid from the freed money, and refunds the rest
      - 'services-commerce:modules/operations/services/reconciler/reconciler.ts'
    exercises:
      - CAP-COM-ORD-016
      - CAP-COM-ORD-018
    workflows:
      - WF-COM-ORD-013
    expected_provenance: proposed
    expected_source:
      - 'services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js'
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
        policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the approver reject one with a
        reason; a member on the console route and a clerk are refused
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
        goods back on the line, the memo and the refund run, the document completed and the RMA closed
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking fee
        as an invoice paid from the freed money, and refunds the rest
      - 'services-commerce:modules/operations/services/reconciler/reconciler.ts'
evidence:
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once
    under the built-in policy: the RMA numbered with its deadline, the lines authorized, the customer told to
    send it back
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s
    10% restocking fee as an invoice paid from the freed money, and refunds the rest
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#deducts nothing when
    the tenant pays the label, though the carrier sold one
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#expects the deduction
    on the RMA and tells the customer the refund is less the return label (USD 8.40)
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s
    request for approval; the approver authorizes it and the RMA is issued
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#invoices the label on
    the return label fee product, pays it from the freed money and refunds the rest
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#leaves the document
    partially received with the RMA open after one of two units, and completes it after the second
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets staff ask for a
    credit, and refuses a member the money action
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the approver
    reject one with a reason; a member on the console route and a clerk are refused
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lists, reads and
    deletes the policy; refuses a member the policies, a second policy at the scope 400, a tenant default with
    a scope id 400
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#refuses a placed order
    409 order_not_returnable, more units than the line has (rejected), another member 403, a reader 403,
    another tenant 404
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#rejects the member with
    final_sale; the administrator’s override authorizes it
  - >-
    Examined reference: services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s
    receipt: the goods back on the line, the memo and the refund run, the document completed and the RMA
    closed
  - >-
    Examined reference: services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#defaults to
    30 days from delivery, approval outside the window, refund on receipt, no fee, restock, quarantine and
    scrap
  - >-
    Examined reference: services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#never
    deducts more than the refund has left after the other fees: the refund’s floor is zero (D-P7-32)
  - >-
    Examined reference: services-commerce:modules/orders/tests/unit/returns/return-policy.spec.js#picks the
    most specific configured policy, else the built-in default, and loosens it by the frozen terms
coverage:
  rule: covered
  transition: 'gap: FND-COM-ORD-073'
  validation: covered
  permission: 'gap: FND-COM-ORD-073'
  edge: 'gap: FND-COM-ORD-073'
  failure: 'gap: FND-COM-ORD-073'
  boundary: covered
  concurrency: 'gap: FND-COM-ORD-073'
  invariant: 'gap: FND-COM-ORD-073'
  interaction: covered
coverage_definition: Covered means a design scenario exists; executable coverage and execution results are separate.
permission_coverage:
  - key: commerce.returns.read
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.returns.create
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.returns.update
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.returns.approve
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.returns.override
    where_checked: service
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.return-policies.read
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.return-policies.create
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.return-policies.delete
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.return-policies.update
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
  - key: commerce.return-policies.bulk
    where_checked: api
    scenarios: []
    gap: FND-COM-ORD-073
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-073
transition_coverage:
  - state_model: STATE-COM-ORD-011
    from: evaluating
    to: authorized
    trigger: Evaluation finds authorized line quantities within the resolved terms.
    scenarios:
      - ATS-COM-ORD-016-03
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
      policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-011
    from: evaluating
    to: awaiting_approval
    trigger: Evaluation identifies exceptional terms needing approval.
    scenarios:
      - ATS-COM-ORD-016-04
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s request for approval;
      the approver authorizes it and the RMA is issued
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-011
    from: evaluating
    to: rejected
    trigger: Evaluation refuses all requested quantities.
    scenarios:
      - ATS-COM-ORD-016-05
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#rejects the member with final_sale; the
      administrator’s override authorizes it
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-011
    from: awaiting_approval
    to: authorized
    trigger: An approver permits the exceptional return with an explanation.
    scenarios:
      - ATS-COM-ORD-016-04
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#holds the member’s request for approval;
      the approver authorizes it and the RMA is issued
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-011
    from: authorized
    to: financially_settled
    trigger: The configured policy settles at authorization.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/returns/return-workflow.ts'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-011
    from: awaiting_receipt
    to: received
    trigger: Receiving reports the complete authorized quantity.
    scenarios:
      - ATS-COM-ORD-016-06
    provenance: test
    source: >-
      services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the goods
      back on the line, the memo and the refund run, the document completed and the RMA closed
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-011
    from: dispositioned
    to: completed
    trigger: Disposition and settlement have both finished.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/returns/return-workflow.ts'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-011
    from: awaiting_receipt
    to: withdrawn
    trigger: The requester ends the return before goods arrive.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/returns/return-workflow.ts:withdrawReturn'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-011
    from: awaiting_receipt
    to: expired
    trigger: The map declares elapsed-deadline expiry.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/operations/services/reconciler/reconciler.ts:returns_overdue'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-012
    from: open
    to: partially_received
    trigger: Receiving reports a portion of the authorized quantity.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/returns/return-workflow.ts'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-012
    from: open
    to: closed
    trigger: Full receipt or a non-expiry return end closes authorization.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/returns.ts:transitionReturn'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-012
    from: partially_received
    to: closed
    trigger: The remaining goods arrive or the return otherwise ends.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/returns.ts:transitionReturn'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-012
    from: open
    to: expired
    trigger: An expired return propagates its outcome.
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/returns.ts:transitionReturn'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
invariant_coverage:
  - invariant: INV-DOM-COM-ORD-002-01
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/orders.table.ts:orders_total_check, orders_amounts_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-02
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/checkout/tests/e2e/idempotency.e2e.spec.js#answers the stored status and body,
      marked Idempotent-Replayed, and runs the placement once: one order row;
      services-commerce:modules/orders/db/orders.table.ts:orders_checkout_uq
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-03
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/orders.table.ts:orders_number_uq, orders_number_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-04
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/orders.ts:ORDER_TRANSITIONS'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-05
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-lines.table.ts:order_lines_quantity_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-06
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/order-line-purchases.table.ts:order_line_purchases_write_once_trigger
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-07
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#resumes the same attempt on a
      retry, whatever card the retry names, and moves nothing while the intent is processing
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-08
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-invoices.table.ts:order_invoices_idempotency_key_uq'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-09
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-events.table.ts'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-10
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/order-lines.table.ts:order_lines_order_fk'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-11
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/orders.table.ts:orders_installment_schedule_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-12
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/billing-and-tender.e2e.spec.js#never stores the card: the
      attempt keeps a reference of the merchant account and the token’s last four only
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-002-13
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/reservations.table.ts:reservations_subject_check;
      modules/orders/services/persistence/reservations.ts:RESERVATION_TRANSITIONS
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-01
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#holds staff’s request for approval
      (participant_requires_approval) and refuses a second request on the line 409 line_already_cancelling
      (B38); services-commerce:modules/orders/db/cancellation-lines.table.ts:cancellation_lines_active_uidx;
      services-commerce:modules/orders/db/amendment-lines.table.ts:amendment_lines_active_uidx;
      services-commerce:modules/orders/db/return-lines.table.ts:return_lines_active_uidx
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-02
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/cancellations.table.ts:cancellations_override_reason_check;
      modules/orders/db/amendments.table.ts:amendments_override_reason_check;
      modules/orders/db/returns.table.ts:returns_override_reason_check
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-03
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts:requestCancellation;
      services-commerce:modules/orders/services/amendments/amendment-workflow.ts:requestAmendment;
      services-commerce:modules/orders/services/returns/return-workflow.ts:requestReturn;
      services-commerce:modules/orders/services/amendments/promotion-amendment.ts
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-04
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/services/persistence/cancellations.ts:CANCELLATION_TRANSITIONS;
      modules/orders/services/persistence/amendments.ts:AMENDMENT_TRANSITIONS;
      modules/orders/services/persistence/returns.ts:RETURN_TRANSITIONS
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-05
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#credits no more than the invoice
      line still owes, so Accounting does not refuse the memo as an over-application
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-06
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/db/return-policies.table.ts:return_policies_scope_uq,
      return_policies_scope_check
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-07
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/db/return-authorizations.table.ts:return_authorizations_open_uidx'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-08
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/services/returns/return-workflow.ts;
      services-commerce:modules/orders/services/persistence/returns.ts:recordReturnEvaluation
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-09
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: >-
      services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
      participant’s cancel, which settles the document completed and runs the refund after the domain (ADR-13)
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-005-10
    scenarios: []
    gap: FND-COM-ORD-073
    provenance: unknown
    source: 'services-commerce:modules/orders/services/persistence/cancellations.ts'
    note: Broader invariant coverage remains open beyond the concrete examples.
workflow_coverage:
  - workflow: WF-COM-ORD-013
    scenarios:
      - ATS-COM-ORD-016-13
    gap: FND-COM-ORD-073
    provenance: proposed
    source:
      - 'services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js'
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#authorizes at once under the built-in
        policy: the RMA numbered with its deadline, the lines authorized, the customer told to send it back
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#lets the approver reject one with a
        reason; a member on the console route and a clerk are refused
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#takes the warehouse’s receipt: the
        goods back on the line, the memo and the refund run, the document completed and the RMA closed
      - >-
        services-commerce:modules/orders/tests/e2e/returns.e2e.spec.js#charges the policy’s 10% restocking fee
        as an invoice paid from the freed money, and refunds the rest
      - 'services-commerce:modules/operations/services/reconciler/reconciler.ts'
interaction_coverage:
  - with: CAP-COM-ORD-018
    scenarios:
      - ATS-COM-ORD-016-12
unproved_rules: []
---

# Authorize returns and settle received goods: Capability Test Specification

## Coverage

| Rule | Scenario or finding |
|---|---|
| `BR-CAP-COM-ORD-016-01` | `ATS-COM-ORD-016-01`, `ATS-COM-ORD-016-13` |
| `BR-CAP-COM-ORD-016-02` | `ATS-COM-ORD-016-02` |
| `BR-CAP-COM-ORD-016-03` | `ATS-COM-ORD-016-03` |
| `BR-CAP-COM-ORD-016-04` | `ATS-COM-ORD-016-04` |
| `BR-CAP-COM-ORD-016-05` | `ATS-COM-ORD-016-05` |
| `BR-CAP-COM-ORD-016-06` | `ATS-COM-ORD-016-06`, `ATS-COM-ORD-016-12` |
| `BR-CAP-COM-ORD-016-07` | `ATS-COM-ORD-016-07` |
| `BR-CAP-COM-ORD-016-08` | `ATS-COM-ORD-016-08` |
| `BR-CAP-COM-ORD-016-09` | `ATS-COM-ORD-016-09` |
| `BR-CAP-COM-ORD-016-10` | `ATS-COM-ORD-016-10` |
| `BR-CAP-COM-ORD-016-11` | `ATS-COM-ORD-016-11` |

## Interactions With Related Capabilities

Returned goods restore their original acquisition cost. A shipped line has identified layer relief and a receipt-based return authorization. Receive part of the goods and then the remainder; inspect cost restoration and settlement.

Crossing workflow examples also cover preparation, commitment and recovery at their service handoffs. Their structured bindings distinguish specified outcomes from executable evidence.
