---
id: WF-ACC-TRX-010
title: Reverse billing in one operation
trigger: >-
  Staff or Commerce cancel selected billed value and may preview the coordinated
  financial result.
product_area: accounting
module: transactions
revision: 1
status: draft
design_intent: confirmed
origin: >-
  Andrew’s D-06 (Accounting owns the reversal operation),
  services-accounting:docs/architecture/accounting-2.0/02-decisions.md#D-06
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-ACC-TRX-014
  - CAP-ACC-TRX-003
  - CAP-ACC-TRX-011
  - CAP-ACC-TRX-012
moves:
  - STATE-ACC-TRX-004
  - STATE-ACC-TRX-002
  - STATE-ACC-TRX-011
  - STATE-ACC-TRX-012
  - STATE-ACC-TRX-010
crosses:
  - SVC-ACC-TRX-transactions
hops:
  - 'n': 1
    actor_or_service: Billing reversal
    action: >-
      Validate remaining invoice value and accounting period, then issue the
      reduction and applicable fee credit while releasing contributing receipt
      money.
    anchor: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:reverseBilling
    seam: sync
    on_failure: Reject preparation and undo every component step.
    left_inconsistent: The complete transaction is undone.
    observer: The API response reports the outcome and applicable refusal code.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:reverseBilling;
      services-accounting:modules/transactions/tests/integration/services/reversals/reversals.integration.spec.js#it
      wrote the credit memo of 4000 on the line, which freed the line’s 4000
      back onto the check (W-05)
  - 'n': 2
    actor_or_service: Billing reversal
    action: >-
      Where requested, issue a cancellation fee bill and settle its eligible
      value using payment-backed credit.
    anchor: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:reverseBilling
    seam: sync
    on_failure: Undo all work in the transaction.
    left_inconsistent: The complete transaction is undone.
    observer: The API response reports the outcome and applicable refusal code.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:reverseBilling;
      services-accounting:modules/transactions/tests/integration/services/reversals/reversals.integration.spec.js#it
      issued the fee invoice of 500 and settled it with a credit of 500 made
      from the check’s freed money
  - 'n': 3
    actor_or_service: Billing reversal
    action: >-
      Create each contributing receipt's refund request or remainder credit
      before committing preparation.
    anchor: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:reverseBilling
    seam: sync
    on_failure: Undo all work in the transaction.
    left_inconsistent: The complete transaction is undone.
    observer: The API response reports the outcome and applicable refusal code.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:reverseBilling;
      services-accounting:modules/transactions/tests/integration/services/reversals/reversal-two-payments.integration.spec.js#it
      requests one refund per payment, 7000 and 3000, each from its own payment
  - 'n': 4
    actor_or_service: Refund execution
    action: >-
      After commit, execute electronic returns and retain manual returns for
      staff payment.
    anchor: >-
      services-accounting:modules/transactions/services/refunds/refund-commands.ts:executeRefund
    seam: sync
    on_failure: >-
      Retain preparation and track the unsuccessful or unresolved outcome on its
      refund.
    left_inconsistent: >-
      Billing reductions and credits remain effective while money return is
      outstanding.
    observer: Cancellation status and exception show the outstanding refund.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/refunds/refund-commands.ts:executeRefund;
      services-accounting:modules/transactions/tests/integration/services/reversals/reversal-refund-status.integration.spec.js#it
      turns succeeded and completed when the signed event settles the refund
  - 'n': 5
    actor_or_service: Reversal settlement
    action: >-
      Update operation completion from refund outcomes, recording exceptions for
      failed or staff-payable returns.
    anchor: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:settleReversalOfRefund
    seam: event
    on_failure: Keep the cancellation operation unresolved pending recovery.
    left_inconsistent: Cancellation remains unresolved with return money held.
    observer: 'Commerce can read the operation, and staff can inspect its console record.'
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/reversals/reversal-commands.ts:settleReversalOfRefund;
      services-accounting:modules/transactions/tests/integration/services/reversals/reversal-refund-status.integration.spec.js#it
      turns succeeded and completed when the signed event settles the refund
idempotency: >-
  Parent and derived keys protect preparation. Preview executes the same
  preparation and rolls back document effects, while independent number
  allocation can still consume sequence values.
concurrency: >-
  Preparation holds ordered locks on the invoice, lines and contributing
  receipts through a single transaction.
branches:
  - >-
    Unpaid cancellation can finish with its memo alone, without fee funding or
    remainder documents.
  - >-
    Posting uses the memo effective date to truncate the remaining deferred
    recognition schedule.
waits:
  - Electronic return outcomes may arrive after preparation has completed.
evidence:
  - >-
    services-accounting at f47cb263: services/reversals/reversal-commands.ts;
    services/refunds/refund-commands.ts; services/change-memos/memo-commands.ts;
    docs/architecture/accounting-2.0/05-lifecycles.md §6.
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-CRY-001, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-AVL-001, TC-AVL-004, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-VEN-001, TC-VEN-002, TC-VEN-003, TC-PRV-001, TC-PRV-002]
---
# Reverse billing in one operation

## What It Does

Billing cancellation retains its financial preparation even when a later money return fails. The operation record explains the outstanding return instead of automatically undoing billing.

## The Flow

```mermaid
flowchart TD
  h0["Billing reversal"]
  h1["Billing reversal"]
  h0 --> h1
  h2["Billing reversal"]
  h1 --> h2
  h3["Refund execution"]
  h2 --> h3
  h4["Reversal settlement"]
  h3 --> h4
```

The numbered hops identify the participating services, synchronization boundary and evidence. Branch conditions in the frontmatter explain where preparation, completion and recovery diverge.

## When Something Fails

Each hop records its rollback, retry or compensation boundary and the result visible to callers or operators. External outcomes can remain unresolved after local preparation commits; the listed recovery behavior defines what remains pending.

## Open Design Questions

The unresolved matters are recorded in the module findings; this workflow does not establish additional product approval.
