---
id: ATS-MBR-MEM-010
scope: CAP-MBR-MEM-010
product_area: membership
module: memberships
revision: 2
status: proposed
approved_by: null
approved_at: null
source_sha:
  services-membership: 5994c270e8a37a30f848e99ba5b5ee6b87c08893
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
scenarios:
  - id: ATS-MBR-MEM-010-01
    title: Preparing a cancellation says what it would do and writes nothing
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-01
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: Prepare the cancellation of a pending line and of a started one.
        expect: >-
          The pending line is wholly refundable; the started one is a
          termination with the program's fraction; nothing is written.
        provenance: test
        source:
          - >-
            services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#allows
            the cancellation of the pending term, the whole line refundable
          - >-
            services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#plans
            the termination with the program’s prorated fraction
    expected: >-
      The pending line is wholly refundable; the started one is a termination
      with the program's fraction; nothing is written.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-240
    provenance: test
    source: >-
      services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#allows the
      cancellation of the pending term, the whole line refundable
    category: invariant
    binding_evidence:
      - suite: TST-MBR-MEM-240
        source: >-
          services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#allows
          the cancellation of the pending term, the whole line refundable
      - suite: TST-MBR-MEM-240
        source: >-
          services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#plans
          the termination with the program’s prorated fraction
  - id: ATS-MBR-MEM-010-02
    title: What a cancelled line's term becomes
    level: unit
    proves:
      - BR-CAP-MBR-MEM-010-02
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: >-
          Decide the action for a pending term, an unstarted committed term, a
          started term and a closed term.
        expect: 'Cancel, cancel, terminate and nothing.'
        provenance: test
        source:
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#cancels
            a pending term
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#cancels
            a committed term that has not started by the effective date
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#terminates
            a committed term that has started
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#does
            nothing to a term already closed
    expected: 'Cancel, cancel, terminate and nothing.'
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-011
    provenance: test
    source: >-
      services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#cancels
      a pending term
    category: transition
    binding_evidence:
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#cancels
          a pending term
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#cancels
          a committed term that has not started by the effective date
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#terminates
          a committed term that has started
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#does
          nothing to a term already closed
  - id: ATS-MBR-MEM-010-03
    title: The refundable fraction follows the program's policy
    level: unit
    proves:
      - BR-CAP-MBR-MEM-010-03
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: >-
          Compute the fraction before the start, by days, by whole months, under
          no refund, after the end and for a never-ending term.
        expect: >-
          All, the unused days, the unused whole months, nothing, nothing and
          nothing.
        provenance: test
        source:
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
            everything before the term starts
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
            the unused days by prorated_days
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
            the unused whole months by prorated_months
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
            nothing under no_refund once the term has started
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
            nothing after the term ended
          - >-
            services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
            nothing of a term that never ends
    expected: >-
      All, the unused days, the unused whole months, nothing, nothing and
      nothing.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-011
    provenance: test
    source: >-
      services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
      everything before the term starts
    category: boundary
    binding_evidence:
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
          everything before the term starts
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
          the unused days by prorated_days
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
          the unused whole months by prorated_months
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
          nothing under no_refund once the term has started
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
          nothing after the term ended
      - suite: TST-MBR-MEM-011
        source: >-
          services-membership:modules/commerce-participant/tests/unit/refund-policy.spec.ts#refunds
          nothing of a term that never ends
  - id: ATS-MBR-MEM-010-04
    title: A member cancels only what has not started
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-04
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: The member asks to cancel a started term; staff ask too.
        expect: The member's request needs approval; staff's proceeds.
        provenance: test
        source:
          - >-
            services-membership:tests/acceptance/commerce/MBR-ACC-0335.acceptance.ts#MBR-ACC-0335
          - >-
            services-membership:tests/acceptance/commerce/MBR-ACC-0334.acceptance.ts#MBR-ACC-0334
    expected: The member's request needs approval; staff's proceeds.
    negative: true
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-099
      - TST-MBR-MEM-098
    provenance: test
    source: >-
      services-membership:tests/acceptance/commerce/MBR-ACC-0335.acceptance.ts#MBR-ACC-0335
    category: permission
    binding_evidence:
      - suite: TST-MBR-MEM-099
        source: >-
          services-membership:tests/acceptance/commerce/MBR-ACC-0335.acceptance.ts#MBR-ACC-0335
      - suite: TST-MBR-MEM-098
        source: >-
          services-membership:tests/acceptance/commerce/MBR-ACC-0334.acceptance.ts#MBR-ACC-0334
  - id: ATS-MBR-MEM-010-05
    title: A pending cancellation fences the membership
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-05
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: >-
          Fence a membership for cancellation, attempt a renewal purchase, then
          complete the cancellation.
        expect: >-
          The renewal is unavailable: fence; the fence clears when the
          cancellation completes.
        provenance: test
        source:
          - >-
            services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#fences
            the membership in TX-K, refusing a competing purchase meanwhile
          - >-
            services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#refuses
            a renewal of a membership a cancellation fences, with unavailable:
            fence
    expected: >-
      The renewal is unavailable: fence; the fence clears when the cancellation
      completes.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-240
      - TST-MBR-MEM-007
    provenance: test
    source: >-
      services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#fences the
      membership in TX-K, refusing a competing purchase meanwhile
    category: interaction
    binding_evidence:
      - suite: TST-MBR-MEM-240
        source: >-
          services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#fences
          the membership in TX-K, refusing a competing purchase meanwhile
      - suite: TST-MBR-MEM-007
        source: >-
          services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#refuses
          a renewal of a membership a cancellation fences, with unavailable:
          fence
  - id: ATS-MBR-MEM-010-06
    title: A cancellation runs once per obligation
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-06
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: Deliver the same cancel obligation twice.
        expect: The same records are answered and nothing more changes.
        provenance: test
        source:
          - >-
            services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#answers
            a redelivered cancel obligation with the same records
    expected: The same records are answered and nothing more changes.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-240
    provenance: test
    source: >-
      services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#answers a
      redelivered cancel obligation with the same records
    category: invariant
    binding_evidence:
      - suite: TST-MBR-MEM-240
        source: >-
          services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#answers
          a redelivered cancel obligation with the same records
  - id: ATS-MBR-MEM-010-07
    title: A void of an unfulfilled first purchase leaves nothing
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-07
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: 'Void a placed, unpaid first purchase; void an unfulfilled renewal.'
        expect: >-
          The first purchase's pending term and membership are gone; the
          renewal's membership is kept.
        provenance: proposed
        source: >-
          services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#releases
          a voided order: the pending term and the membership the claim created
          are deleted
    expected: >-
      The first purchase's pending term and membership are gone; the renewal's
      membership is kept.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to: []
    provenance: proposed
    source: >-
      services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#releases
      a voided order: the pending term and the membership the claim created are
      deleted
    category: transition
    binding_gap: FND-MBR-MEM-103
  - id: ATS-MBR-MEM-010-08
    title: A reversed payment suspends once and its resolution restores
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-09
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: >-
          Enforce suspend twice for a reversed payment and a dispute, restore
          one, then the other; also enforce on a staff-suspended member.
        expect: >-
          Suspended once; restored only when no Commerce suspension stands; the
          staff suspension is never lifted.
        provenance: test
        source:
          - >-
            services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#suspends
            on a reversed payment, idempotently, and restores on resolution
          - >-
            services-membership:tests/acceptance/commerce/MBR-ACC-0355.acceptance.ts#MBR-ACC-0355
    expected: >-
      Suspended once; restored only when no Commerce suspension stands; the
      staff suspension is never lifted.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to:
      - TST-MBR-MEM-007
      - TST-MBR-MEM-114
    provenance: test
    source: >-
      services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#suspends
      on a reversed payment, idempotently, and restores on resolution
    category: transition
    binding_evidence:
      - suite: TST-MBR-MEM-007
        source: >-
          services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#suspends
          on a reversed payment, idempotently, and restores on resolution
      - suite: TST-MBR-MEM-114
        source: >-
          services-membership:tests/acceptance/commerce/MBR-ACC-0355.acceptance.ts#MBR-ACC-0355
  - id: ATS-MBR-MEM-010-09
    title: A cancelled term's chapters end and its grants follow
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-10
    preconditions: >-
      The well-known FAA workspace fixtures, or a workspace the test builds from
      them.
    steps:
      - do: Cancel a started term holding a chapter and a grant.
        expect: >-
          The term ends the day before, its chapter ends with it, its granted
          term follows, and the fence clears.
        provenance: proposed
        source: >-
          services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#terminates
          the term the day before the effective date, ends its chapter, clears
          the fence
    expected: >-
      The term ends the day before, its chapter ends with it, its granted term
      follows, and the fence clears.
    negative: false
    data_needs: 'FAA programs, packages, units and members from the integration seed.'
    bound_to: []
    provenance: proposed
    source: >-
      services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#terminates
      the term the day before the effective date, ends its chapter, clears the
      fence
    category: interaction
    binding_gap: FND-MBR-MEM-103
  - id: ATS-MBR-MEM-010-10
    title: Refuse staff correction after purchase cancellation
    category: interaction
    level: api
    proves:
      - BR-CAP-MBR-MEM-003-01
      - BR-CAP-MBR-MEM-010-10
    interacts_with:
      - CAP-MBR-MEM-003
    workflows: []
    relies_on:
      - ATS-MBR-MEM-003-01
      - ATS-MBR-MEM-010-09
    preconditions: A purchased period is committed and staff have read its version.
    steps:
      - do: >-
          Cancel the purchase, then submit a correction using the earlier
          version.
        expect: >-
          The closed period remains closed and the correction cannot overwrite
          the cancellation.
        provenance: proposed
        source: &ref_0
          - >-
            services-membership:modules/memberships/services/operations/staff-operations.ts:lockTerm,
            correctTerm, terminateTerm
          - >-
            services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#terminates
            the term the day before the effective date, ends its chapter, clears
            the fence
    expected: >-
      The closed period remains closed and the correction cannot overwrite the
      cancellation.
    negative: true
    data_needs: >-
      An isolated workspace with the specified membership, package, chapter and
      partner-port fixtures.
    bound_to: []
    provenance: proposed
    source: *ref_0
  - id: ATS-MBR-MEM-010-11
    title: Keep staff suspension after payment restoration
    category: interaction
    level: api
    proves:
      - BR-CAP-MBR-MEM-004-02
      - BR-CAP-MBR-MEM-004-03
      - BR-CAP-MBR-MEM-010-09
    interacts_with:
      - CAP-MBR-MEM-004
    workflows:
      - WF-MBR-MEM-015
    relies_on:
      - ATS-MBR-MEM-004-02
      - ATS-MBR-MEM-010-08
    preconditions: Staff have suspended a purchased membership with a reason.
    steps:
      - do: >-
          Apply a Commerce suspension enforcement, then restore that
          enforcement.
        expect: >-
          The enforcement is restored while the staff suspension and its reason
          remain.
        provenance: proposed
        source: &ref_1
          - >-
            services-membership:tests/acceptance/memberships/MBR-ACC-0174.acceptance.ts#MBR-ACC-0174:
            A membership is suspended over its terms and restored to whatever
            the terms give, once each way, with no detections while suspended
            and the history showing the suspension
          - >-
            services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#suspends
            on a reversed payment, idempotently, and restores on resolution
    expected: >-
      The enforcement is restored while the staff suspension and its reason
      remain.
    negative: false
    data_needs: >-
      An isolated workspace with the specified membership, package, chapter and
      partner-port fixtures.
    bound_to: []
    provenance: proposed
    source: *ref_1
  - id: ATS-MBR-MEM-010-12
    title: Resolve attention when a purchased term closes
    category: interaction
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-10
      - BR-CAP-MBR-MEM-014-07
    interacts_with:
      - CAP-MBR-MEM-014
    workflows:
      - WF-MBR-MEM-014
    relies_on:
      - ATS-MBR-MEM-010-09
      - ATS-MBR-MEM-014-07
    preconditions: Publication is enabled for an expiring purchased term.
    steps:
      - do: >-
          Cancel the started purchase and inspect the closure and the original
          expiry item.
        expect: >-
          The term and chapter coverage close and the enabled item resolves in
          the closing write.
        provenance: proposed
        source: &ref_2
          - >-
            services-membership:tests/e2e/commerce-cancellation.e2e.spec.ts#terminates
            the term the day before the effective date, ends its chapter, clears
            the fence
          - >-
            services-membership:modules/memberships/tests/integration/services/expiring-memberships.integration.spec.ts#resolves
            the item renewed in the staff renewal’s transaction
    expected: >-
      The term and chapter coverage close and the enabled item resolves in the
      closing write.
    negative: false
    data_needs: >-
      An isolated workspace with the specified membership, package, chapter and
      partner-port fixtures.
    bound_to: []
    provenance: proposed
    source: *ref_2
  - id: ATS-MBR-MEM-010-13
    title: Describe first-purchase removal in its cancellation event
    category: interaction
    level: api
    proves:
      - BR-CAP-MBR-MEM-010-07
      - BR-CAP-MBR-MEM-020-04
    interacts_with:
      - CAP-MBR-MEM-020
    workflows:
      - WF-MBR-MEM-014
    relies_on:
      - ATS-MBR-MEM-010-07
      - ATS-MBR-MEM-020-04
    preconditions: A first purchase has a pending term and no other coverage.
    steps:
      - do: >-
          Cancel its obligation and inspect the committed cancellation event
          before and after redelivery.
        expect: >-
          The event records that the holding is removed and redelivery creates
          no second event.
        provenance: proposed
        source: &ref_3
          - >-
            services-membership:modules/commerce-participant/tests/integration/participant.integration.spec.ts#releases
            a voided order: the pending term and the membership the claim
            created are deleted
          - >-
            services-membership:modules/memberships/tests/unit/membership-business-events.spec.ts#says
            whether a cancellation removed the membership
    expected: >-
      The event records that the holding is removed and redelivery creates no
      second event.
    negative: true
    data_needs: >-
      An isolated workspace with the specified membership, package, chapter and
      partner-port fixtures.
    bound_to: []
    provenance: proposed
    source: *ref_3
evidence:
  - >-
    services-membership at 5994c270e8a37a30f848e99ba5b5ee6b87c08893: the
    capability sources and the bound test files.
  - >-
    rhythm-v2-docs:specs/membership/memberships/design/: domain objects, state
    models and workflows reviewed for coverage.
coverage:
  rule: 'gap: FND-MBR-MEM-092'
  transition: 'gap: FND-MBR-MEM-092'
  validation: 'gap: FND-MBR-MEM-092'
  permission: 'gap: FND-MBR-MEM-092'
  edge: 'gap: FND-MBR-MEM-092'
  failure: 'gap: FND-MBR-MEM-092'
  boundary: covered
  concurrency: 'gap: FND-MBR-MEM-092'
  invariant: 'gap: FND-MBR-MEM-092'
  interaction: covered
coverage_notes:
  transition: >-
    The scenarios do not enumerate every applicable object transition; the
    finding preserves the remaining transition matrix.
  permission: >-
    The finding records named permissions without a complete positive and
    negative proof.
  invariant: >-
    Existing invariant examples do not cover every applicable domain-object
    constraint.
  interaction: >-
    Every related capability and each cross-capability workflow has an explicit
    composite scenario. Unbound composites remain proposed.
---

# Undo a purchase or respond to a payment problem: Capability Test Specification

## Coverage

| Rule | Scenario or Finding |
|---|---|
| `BR-CAP-MBR-MEM-010-01` | `ATS-MBR-MEM-010-01` |
| `BR-CAP-MBR-MEM-010-02` | `ATS-MBR-MEM-010-02` |
| `BR-CAP-MBR-MEM-010-03` | `ATS-MBR-MEM-010-03` |
| `BR-CAP-MBR-MEM-010-04` | `ATS-MBR-MEM-010-04` |
| `BR-CAP-MBR-MEM-010-05` | `ATS-MBR-MEM-010-05` |
| `BR-CAP-MBR-MEM-010-06` | `ATS-MBR-MEM-010-06` |
| `BR-CAP-MBR-MEM-010-07` | `ATS-MBR-MEM-010-07`, `ATS-MBR-MEM-010-13` |
| `BR-CAP-MBR-MEM-010-08` | no scenario: `FND-MBR-MEM-034` |
| `BR-CAP-MBR-MEM-010-09` | `ATS-MBR-MEM-010-08`, `ATS-MBR-MEM-010-11` |
| `BR-CAP-MBR-MEM-010-10` | `ATS-MBR-MEM-010-09`, `ATS-MBR-MEM-010-10`, `ATS-MBR-MEM-010-12` |

## Interactions With Related Capabilities

The interaction cases test how a shared holding, period, chapter connection or recorded change affects related work. Each case names its related capabilities and workflows in frontmatter. A composite case remains proposed until executable assertions establish every part of its expected outcome.
