---
id: TST-ACC-TRX-020
title: Write offs suite
kind: api-lifecycle
product_area: accounting
module: transactions
revision: 1
status: draft
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
repository: services-accounting
files:
  - modules/transactions/tests/e2e/write-offs.e2e.spec.js
implements:
  - ATS-ACC-TRX-004-04
  - ATS-ACC-TRX-004-06
implements_parts:
  - scenario: ATS-ACC-TRX-004-04
    assertion: >-
      it reverses it through the reverse action, answering the reversal and
      restoring the invoice
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/write-offs.e2e.spec.js#it
      reverses it through the reverse action, answering the reversal and
      restoring the invoice
  - scenario: ATS-ACC-TRX-004-06
    assertion: it is refused the create and the reverse 403 permission_missing
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/write-offs.e2e.spec.js#it
      is refused the create and the reverse 403 permission_missing
  - scenario: ATS-ACC-TRX-004-06
    assertion: it reads the write-off and lists no action
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/write-offs.e2e.spec.js#it
      reads the write-off and lists no action
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/e2e/write-offs.e2e.spec.js'
evidence:
  - provenance: test
    source: 'services-accounting:modules/transactions/tests/e2e/write-offs.e2e.spec.js'
    assertion_titles:
      - write-offs (end to end)
      - an administrator’s write-off
      - 'answers 200 with the write-off issued, the line written off'
      - reads the write-off as the create answered it
      - lists the invoice’s write-offs
      - lists the reverse and reassign-batch actions
      - >-
        reverses it through the reverse action, answering the reversal and
        restoring the invoice
      - reverses another write-off through the reverse route
      - a body the boundary refuses
      - >-
        accepts an allowance write-off naming no account (gl-at-posting: the
        unit’s allowance default serves at posting)
      - is 400 for a direct write-off naming an allowance account
      - is 400 for a method the vocabulary does not have
      - >-
        is 400 over_application writing off more than the line owes, the invoice
        untouched
      - a principal holding only accounting.application.access
      - is refused every write-off route 403 permission_missing
      - a principal holding only accounting.write-offs.read
      - reads the write-off and lists no action
      - is refused the create and the reverse 403 permission_missing
      - tenant isolation
      - >-
        answers A’s write-off in tenant B exactly as an id no write-off has, but
        for the id
      - reads A’s write-off 404 not_found in tenant B
      - refuses B’s reversal of A’s write-off 404 and leaves it issued
      - refuses B’s write-off on A’s invoice 404
    imports:
      - 'const { expect } = require(''chai'');'
      - 'const { integrationDatabaseUrl } = require(''../../../../db/config'');'
      - >-
        const { registerLocalTenant, unregisterLocalTenant } =
        require('../../../../db/test-support/platform-tables');
      - >-
        const { testId } =
        require('@rhythmsoftware/macroservice-testing/integration-database');
      - >-
        const { uuidV7 } =
        require('@rhythmsoftware/macroservice-records/uuid-v7');
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { accountingApi, accountingGrant } =
        require('../../../books/tests/e2e/e2e-security');
      - >-
        const { PERMISSION_MISSING, accessRefusalOf, configurationCaller } =
        require('../../../books/tests/e2e/configuration-e2e-support');
      - 'const { ready } = require(''../../../books/tests/integration/support'');'
      - >-
        const { balancesOf, createMemoWorld, issuedInvoice, removeMemoWorld } =
        require('../integration/memos-fixtures');
      - "\tconst call = configurationCaller(handler, { tenant_id: () => TENANT_A, ctx: () => session.require().administrator });"
      - "\tconst world = () => session.require();"
      - "\t\t\tconst answer = written.require();"
      - "\t\t\tconst answer = await call('GET', ROUTES.write_off, { id: written.require().body.id });"
      - "\t\t\texpect([answer.status, answer.body]).to.deep.equal([200, written.require().body]);"
      - "\t\t\t\t[written.require().body.id],"
      - "\t\t\tconst answer = await call('GET', ROUTES.write_off_actions, { id: written.require().body.id });"
      - "\t\t\tconst original = written.require().body;"
      - "\t\t\tconst read = await call('GET', ROUTES.write_off, { ctx: world().reader, id: writeOff.require().id });"
      - "\t\t\tconst actions = await call('GET', ROUTES.write_off_actions, { ctx: world().reader, id: writeOff.require().id });"
      - "\t\t\texpect([read.status, read.body.id, actions.status, actions.body]).to.deep.equal([200, writeOff.require().id, 200, []]);"
      - "\t\t\t\t\tid: writeOff.require().id,"
      - "\t\t\tconst foreign = await call('GET', ROUTES.write_off, { tenant_id: TENANT_B, id: writeOff.require().id });"
      - "\t\t\texpect(shape(foreign, writeOff.require().id)).to.deep.equal(shape(missing, absent));"
      - "\t\t\tconst answer = await call('GET', ROUTES.write_off, { tenant_id: TENANT_B, id: writeOff.require().id });"
      - "\t\t\t\tid: writeOff.require().id,"
      - "\t\t\texpect([codedRefusalOf(answer), (await call('GET', ROUTES.write_off, { id: writeOff.require().id })).body.status]).to.deep.equal(["
    test_double_declarations: []
---

# Write offs 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 an opposing write-off restores debt once; write-off inspection does not grant mutation. 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.
