---
id: TST-COM-ORD-074
title: 'A promotion code applied to a placed order, as an amendment'
kind: api-lifecycle
product_area: commerce
module: orders
revision: 1
status: draft
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
repository: services-commerce
files:
  - modules/orders/tests/e2e/apply-promotion-amendment.e2e.spec.js
implements:
  - ATS-COM-ORD-015-07
  - ATS-COM-ORD-015-09
  - ATS-COM-ORD-015-12
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 2
isolation: The suite creates its own test workspace records and removes them using the fixture cleanup.
evidence:
  - provenance: test
    source: 'services-commerce:modules/orders/tests/e2e/apply-promotion-amendment.e2e.spec.js'
    test_cases:
      - >-
        answers 200 with the apply_promotion amendment completed, its plan on the document, its net owed to
        the buyer
      - >-
        records the redemption applied, one allocation per line, and counts the use on the promotion and the
        code
      - >-
        moves only the discount and the net of the lines and the order: the prices, the purchase and the
        snapshot as placed
      - >-
        sends the memo to the fixture Accounting per invoice line, then the refund of what it freed, under the
        amendment’s keys
      - settles the adjustment completed and links it to the document
      - >-
        writes the history: requested, the intervention, the promotion applied, executed, the adjustment,
        completed
      - writes the apply_promotion intervention on the amendment with the reason and the administrator
      - >-
        refuses the same code again 409 promotion_refused, already_applied, the second document rejected and
        nothing moved
      - >-
        credits the line’s net after the code when the T-shirt is cancelled later: the memo and the refund are
        2250
      - 'completes the amendment with the memo alone: the balance reduced by 250, nothing refunded or credited'
      - lowers the order’s total to 2250
      - 'releases the amendment’s redemption order_voided, as the void releases a placement’s'
      - >-
        refuses an exhausted code code_exhausted, after its one use on another order, with nothing written but
        the rejected document
      - 'refuses a code that applies to none of the lines nothing_qualifies, with the staff message'
      - refuses a code the tenant does not have code_not_found
      - >-
        refuses a missing reason 400, a clerk without the key 403 permission_missing, a portal member 403,
        another tenant 404
scenario_coverage:
  - scenario: ATS-COM-ORD-015-07
    test_cases:
      - >-
        answers 200 with the apply_promotion amendment completed, its plan on the document, its net owed to
        the buyer
      - >-
        sends the memo to the fixture Accounting per invoice line, then the refund of what it freed, under the
        amendment’s keys
      - 'completes the amendment with the memo alone: the balance reduced by 250, nothing refunded or credited'
      - >-
        refuses a missing reason 400, a clerk without the key 403 permission_missing, a portal member 403,
        another tenant 404
    scope: >-
      The cited cases exercise the scenario’s listed fixture outcomes; this register makes no verified
      conformance claim.
  - scenario: ATS-COM-ORD-015-09
    test_cases:
      - >-
        refuses the same code again 409 promotion_refused, already_applied, the second document rejected and
        nothing moved
      - >-
        refuses an exhausted code code_exhausted, after its one use on another order, with nothing written but
        the rejected document
      - 'refuses a code that applies to none of the lines nothing_qualifies, with the staff message'
      - refuses a code the tenant does not have code_not_found
    scope: >-
      The cited cases exercise the scenario’s listed fixture outcomes; this register makes no verified
      conformance claim.
  - scenario: ATS-COM-ORD-015-12
    test_cases:
      - 'releases the amendment’s redemption order_voided, as the void releases a placement’s'
    scope: >-
      The cited cases exercise the scenario’s listed fixture outcomes; this register makes no verified
      conformance claim.
dependency_evidence:
  provenance: test
  source: 'services-commerce:modules/orders/tests/e2e/apply-promotion-amendment.e2e.spec.js'
  declared_by_test: >-
    the composed handler, the route, the amendment, the pricing library, the promotions persistence
    (`recordRedemption`), the adjustment worker, the cancellation and the void, PostgreSQL. Doubled: the
    signing key pair, the other services' tables (local stand-ins), Accounting (the fixture transport and the
    fixture adjustment commands), the facts port.
---

# A promotion code applied to a placed order, as an amendment

## Verification Boundary

The suite drives the composed local API dispatcher and its registered routes.

## What This Suite Proves

The registered cases check a promotion code applied to a placed order, as an amendment with their fixture records and assertions. Scenario bindings name only the examples those cases exercise.

## What It Does Not Prove

A registered file supplies no run result or verified conformance by itself. Local fixtures do not establish deployed cross-service behavior or complete browser journeys.

## Real Dependencies and Test Doubles

PostgreSQL and the exercised Commerce persistence or workflow code are real. Remote service records, clocks and transports follow the suite’s fixtures.

## Must Not Be Doubled

The database constraints, role restrictions, locks and transactions exercised by this suite must use PostgreSQL.
