---
id: TST-ACC-TRX-035
title: Debit memos suite
kind: integration
product_area: accounting
module: transactions
revision: 1
status: draft
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
repository: services-accounting
files:
  - >-
    modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js
implements:
  - ATS-ACC-TRX-003-02
  - ATS-ACC-TRX-003-06
  - ATS-ACC-TRX-003-09
implements_parts:
  - scenario: ATS-ACC-TRX-003-02
    assertion: >-
      it answers the memo whole: issued, numbered from 1,000,000, its line
      naming the line it added
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js#it
      answers the memo whole: issued, numbered from 1,000,000, its line naming
      the line it added
  - scenario: ATS-ACC-TRX-003-06
    assertion: >-
      it adds a third line of origin debit_memo, priced zero, its accounting
      frozen from the unit’s defaults
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js#it
      adds a third line of origin debit_memo, priced zero, its accounting frozen
      from the unit’s defaults
  - scenario: ATS-ACC-TRX-003-06
    assertion: 'it raises the header’s balance by the memo, its totals its own'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js#it
      raises the header’s balance by the memo, its totals its own
  - scenario: ATS-ACC-TRX-003-09
    assertion: it is refused 400 over_application
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js#it
      is refused 400 over_application
  - scenario: ATS-ACC-TRX-003-09
    assertion: it leaves the added line owing the 5.00 the credit left
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js#it
      leaves the added line owing the 5.00 the credit left
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 3
isolation: >-
  Suite-marked records in the prepared local test database; fixture teardown
  removes owned records.
provenance: test
source: >-
  services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/change-memos/debit-memos.integration.spec.js
    assertion_titles:
      - debit memos (integration)
      - on a draft invoice
      - is refused 409 invoice_not_draft
      - raising an invoice
      - >-
        answers the memo whole: issued, numbered from 1,000,000, its line naming
        the line it added
      - >-
        adds a third line of origin debit_memo, priced zero, its accounting
        frozen from the unit’s defaults
      - 'raises the header’s balance by the memo, its totals its own'
      - writes one debit_memo fact of plus the amount on the added line
      - records the create as the memo’s document event
      - leaves the as-of read of the facts equal to the live balance
      - voiding a debit memo
      - answers the memo void with its negating line
      - 'returns the balances, the added line owing nothing and void'
      - writes a debit_memo_voided fact of minus the amount
      - leaves the as-of read of the facts equal to the live balance
      - voiding a debit memo whose added line was credited since
      - is refused 400 over_application
      - writes nothing
      - leaves the added line owing the 5.00 the credit left
      - a product of another unit
      - is refused 400 business_unit_mismatch
      - a replay
      - answers the first memo
      - 'writes nothing again: no memo, no added line, no fact, no event'
    imports:
      - 'const { expect } = require(''chai'');'
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { ready, testId } =
        require('../../../../../books/tests/integration/support');
      - >-
        const { createCreditMemo, createDebitMemo, voidDebitMemo } =
        require('../../../../services/change-memos/memo-commands');
      - '} = require(''../../memos-fixtures'');'
      - "\t\t\tworld.require();"
      - "\t\t\tconst refusal = await refusalOf(debit(debitRequest(draft.require(), 'dm-draft-1', 1500)));"
      - "\t\t\tworld.require();"
      - "\t\t\tconst { invoice, memo, after } = raised.require();"
      - "\t\t\tconst { after } = raised.require();"
      - "\t\t\tconst { after } = raised.require();"
      - "\t\t\tconst { memo, after } = raised.require();"
      - "\t\t\t\t(await eventsOf(TENANT, raised.require().memo.id)).map((event) => [event.document_kind, event.command, event.status_after]),"
      - "\t\t\texpect(await asOfAndLive(TENANT, raised.require().invoice.id)).to.deep.equal({ as_of: 21500, live: 21500 });"
      - "\t\t\tworld.require();"
      - "\t\t\tconst { memo, answer } = voided.require();"
      - "\t\t\texpect(await balancesOf(TENANT, voided.require().invoice.id)).to.deep.equal({"
      - "\t\t\tconst { memo, answer } = voided.require();"
      - "\t\t\texpect(await asOfAndLive(TENANT, voided.require().invoice.id)).to.deep.equal({ as_of: 20000, live: 20000 });"
      - "\t\t\tworld.require();"
      - "\t\t\texpect(refusalShapeOf(attempt.require().refusal)).to.include({ name: 'InvalidRequestError', code: 'over_application' });"
      - "\t\t\tconst { before, after } = attempt.require();"
      - "\t\t\tconst balances = await balancesOf(TENANT, attempt.require().invoice.id);"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tconst { first, again } = replay.require();"
      - "\t\t\tconst { before, after } = replay.require();"
    test_double_declarations: []
---

# Debit memos suite

## Verification Boundary

The suite exercises transaction commands and database protections in the local prepared test environment. Registration records the existing executable file; it does not report a run or establish product approval.

## What This Suite Proves

Its cited assertions contribute evidence for saving memos issues them immediately; added debit remains distinct from original totals; later credit blocks an excessive debit void. The structured assertion bindings identify which parts of combined scenarios it executes.

## What It Does Not Prove

Local commands and route invocations do not establish deployed routing, live processor guarantees or the complete staff browser experience. An unbound feature chain remains proposed, and this registration carries no execution result.

## Real Dependencies and Test Doubles

The suite uses the imported commands, route handlers or persistence code against the local test database. Fixture helpers supply accounting context; any stepped clock, dummy processor or substituted external client is retained in the evidence declarations.

## Must Not Be Doubled

The command or persistence behavior under assertion and its relevant database protections must remain real. Substituting the final financial result removes evidence of transactional effects.
