---
id: TST-ACC-TRX-092
title: Invoices 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/persistence/invoices.integration.spec.js
implements: []
implements_parts: []
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/persistence/invoices.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/persistence/invoices.integration.spec.js
    assertion_titles:
      - 'the invoices persistence: writes (integration)'
      - insertInvoice
      - 'answers the header as stored, every column mapped'
      - >-
        answers the lines as stored in position order, the generated amounts
        computed by the database
      - reads back what it answered
      - replaceDraftLines
      - leaves the draft only the new line
      - removes the replaced lines from the table
      - updateInvoice
      - answers the row with the changes and the version bumped to 2
      - refuses an update at the stale version 1 (StaleObjectError)
      - >-
        leaves the row as the first update made it after the stale update is
        refused
      - updateLines
      - writes the changes to the named line and bumps its version
      - leaves the other line as it was
      - numberInvoice
      - 'numbers the tenant’s first invoice 1,000,000'
      - 'numbers the next one 1,000,001'
      - 'leaves the seed answering 1,000,002 next'
      - replaces a number already taken by the next free one
      - stores each number on its invoice
      - another tenant
      - writes the row under the execution’s tenant
      - does not load the row in another tenant
      - 'does not delete the row from another tenant, which answers false'
      - deleteInvoice
      - answers true for the draft it deleted
      - removes the draft
      - removes the draft’s lines with it
      - answers false for an invoice that does not exist
    imports:
      - 'const { sql } = require(''drizzle-orm'');'
      - >-
        const { fixtureId } =
        require('../../../../../../db/test-support/fixture-ids');
      - >-
        const { StaleObjectError } =
        require('@rhythmsoftware/macroservice-errors/errors');
      - >-
        const { expectRefusal } =
        require('@rhythmsoftware/macroservice-testing/refusals');
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - '} = require(''../../../../services/persistence/invoices'');'
      - >-
        const { recordDocumentEvent } =
        require('../../../../services/persistence/document-events');
      - >-
        const { ADA, createInvoiceWorld, expect, fixedIn, ownerQuery, ready,
        removeTenantInvoices, testId } = require('../../invoices-fixtures');
      - "\t\t\tworld.require();"
      - "\t\t\texpect(inserting.require().header).to.deep.equal({"
      - "\t\t\texpect(inserting.require().lines).to.deep.equal(["
      - "\t\t\texpect(read).to.deep.equal(inserting.require());"
      - "\t\t\tworld.require();"
      - "\t\t\texpect(replacing.require().lines.map((line) => [line.id, line.position, line.product_id, line.total_amount])).to.deep.equal(["
      - "\t\t\treplacing.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tconst row = updating.require();"
      - "\t\t\tupdating.require();"
      - "\t\t\tupdating.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tconst [first] = updating.require().lines;"
      - "\t\t\tconst [, second] = updating.require().lines;"
      - "\t\t\t\tworld.require();"
      - "\t\t\texpect(numbering.require().first).to.equal(1000000);"
      - "\t\t\texpect(numbering.require().second).to.equal(1000001);"
      - "\t\t\texpect(numbering.require().seedAfterSecond).to.equal('1000002');"
      - "\t\t\texpect(numbering.require().third).to.equal(1000002);"
      - "\t\t\tnumbering.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tisolating.require();"
      - "\t\t\texpect(isolating.require().loaded).to.equal(undefined);"
      - "\t\t\texpect(isolating.require().deleted).to.equal(false);"
      - "\t\t\tworld.require();"
      - "\t\t\texpect(deleting.require().deleted).to.equal(true);"
      - "\t\t\tdeleting.require();"
      - "\t\t\texpect(deleting.require().linesBefore.map((row) => row.id)).to.deep.equal([fixtureId('del-1-l1'), fixtureId('del-1-l2')].sort());"
      - "\t\t\texpect(deleting.require().absent).to.equal(false);"
    test_double_declarations: []
---

# Invoices 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

The executable assertions exercise this module, but no capability or feature scenario binding is established for this file. Its individual assertion titles remain in the evidence register for subsequent mapping.

## 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.
