---
id: TST-ACC-TRX-022
title: Invoices table 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/db/invoices.table.integration.spec.js
implements:
  - ATS-ACC-TRX-001-10
  - ATS-ACC-TRX-003-03
implements_parts:
  - scenario: ATS-ACC-TRX-001-10
    assertion: it refuses a change of an issued line’s product (RHA04)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js#it
      refuses a change of an issued line’s product (RHA04)
  - scenario: ATS-ACC-TRX-001-10
    assertion: it refuses a change of an issued line’s amounts (RHA04)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js#it
      refuses a change of an issued line’s amounts (RHA04)
  - scenario: ATS-ACC-TRX-001-10
    assertion: it refuses the delete of an issued invoice (RHA04)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js#it
      refuses the delete of an issued invoice (RHA04)
  - scenario: ATS-ACC-TRX-001-10
    assertion: it refuses a change of an issued line’s tax class (RHA04)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js#it
      refuses a change of an issued line’s tax class (RHA04)
  - scenario: ATS-ACC-TRX-001-10
    assertion: it refuses the delete of an issued line (RHA04)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js#it
      refuses the delete of an issued line (RHA04)
  - scenario: ATS-ACC-TRX-003-03
    assertion: >-
      it refuses a credit memo line that credits more than the line owes,
      through the ledger trigger (invoice_lines_balance_due_check)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js#it
      refuses a credit memo line that credits more than the line owes, through
      the ledger trigger (invoice_lines_balance_due_check)
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/db/invoices.table.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/db/invoices.table.integration.spec.js
    assertion_titles:
      - accounting.invoices and the receivables tables (integration)
      - 'row-level security: another tenant’s receivables are not seen'
      - >-
        shows the foreign invoice to its own tenant (the premise of the cases
        below)
      - hides another tenant’s invoice
      - hides another tenant’s invoice lines
      - hides another tenant’s credit memo
      - hides another tenant’s credit memo line
      - hides another tenant’s write-off
      - hides another tenant’s write-off line
      - hides another tenant’s receivable facts
      - hides another tenant’s document events
      - text normalization
      - stores a memo trimmed
      - stores a blank purchase order number as null
      - 'refuses a blank line description, which is required (23502)'
      - the maintained amounts
      - refuses the application role an update of a line’s amount_paid (42501)
      - >-
        refuses the application role an update of a line’s amount_credited
        (42501)
      - >-
        refuses the application role an update of a header’s amount_written_off
        (42501)
      - >-
        leaves the line’s balance as the ledgers made it after the refused
        updates
      - >-
        refuses even the owner a line amount that makes the balance negative
        (invoice_lines_balance_due_check)
      - >-
        refuses even the owner a header amount that makes the balance negative
        (invoices_balance_due_check)
      - >-
        refuses a credit memo line that credits more than the line owes, through
        the ledger trigger (invoice_lines_balance_due_check)
      - refuses a credit memo line naming a draft’s line (RHA03)
      - crediting exactly what a line owes
      - moves the line to cancelled
      - moves the header to cancelled with it
      - moves the line to paid when the memo is a retroactive coupon’s (RB-5114)
      - >-
        moves the header to paid with it when the memo is a retroactive coupon’s
        (RB-5114)
      - the freeze of an issued invoice
      - refuses a change of an issued line’s product (RHA04)
      - refuses a change of an issued line’s amounts (RHA04)
      - refuses a change of an issued line’s tax class (RHA04)
      - >-
        admits the posting’s write of an issued line’s accounts (the posting’s
        snapshot, gl-at-posting)
      - refuses the delete of an issued line (RHA04)
      - refuses the delete of an issued invoice (RHA04)
      - refuses a change of an issued header’s total (RHA04)
      - lets a draft line’s product and amounts change
      - lets a draft line be deleted
      - the insert-only credit memo ledger
      - refuses the application role an update of a memo line (42501)
      - refuses the application role the delete of a memo line (42501)
      - refuses even the owner an update of a memo line (RHA01)
      - refuses even the owner the delete of a memo line (RHA01)
      - >-
        refuses the purge while Platform does not have the tenant in deleting
        (RHA02)
      - >-
        lets the purge remove the tenant’s memo lines with the tenant in
        deleting
      - the append-only event logs
      - refuses the application role an update of a receivable fact (42501)
      - refuses even the owner an update of a receivable fact (RHT01)
      - >-
        refuses the delete of a receivable fact while the tenant is not in
        deleting (RHT02)
      - >-
        lets the owner delete the tenant’s receivable facts with the tenant in
        deleting
      - refuses the application role an update of a document event (42501)
      - refuses even the owner an update of a document event (RHT01)
      - >-
        refuses the delete of a document event while the tenant is not in
        deleting (RHT02)
      - >-
        lets the owner delete the tenant’s document events with the tenant in
        deleting
      - the header CHECKs
      - refuses a pro forma with a batch (invoices_pro_forma_batch_check)
      - refuses a draft with a number (invoices_draft_check)
      - refuses an issued invoice without a number (invoices_draft_check)
    imports:
      - 'const { sql } = require(''drizzle-orm'');'
      - >-
        const { expectConstraintViolation, expectDatabaseRefusal } =
        require('@rhythmsoftware/macroservice-testing/refusals');
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { createDraft } =
        require('../../../services/invoices/invoice-drafts');
      - >-
        const { issueInvoice } =
        require('../../../services/invoices/invoice-issue');
      - '} = require(''../invoices-fixtures'');'
      - "\t\tworld.require();"
      - "\t\t\tconst { foreign } = documents.require();"
      - "\t\t\tconst { foreign } = documents.require();"
      - "\t\t\tconst lineIds = documents.require().foreign.lines.map((line) => line.id);"
      - "\t\t\tconst { memo_id } = documents.require().foreignMemo;"
      - "\t\t\tconst { memo_line_id } = documents.require().foreignMemo;"
      - "\t\t\tconst { write_off_id } = documents.require().foreignWriteOff;"
      - "\t\t\tconst { write_off_line_id } = documents.require().foreignWriteOff;"
      - "\t\t\tconst { foreign } = documents.require();"
      - "\t\t\tconst { foreign } = documents.require();"
      - "\t\t\tconst { draft } = documents.require();"
      - "\t\t\tconst { draft } = documents.require();"
      - "\t\t\tconst { draft } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { draft } = documents.require();"
      - "\t\t\t\tworld.require();"
      - "\t\t\tconst { credited } = crediting.require();"
      - "\t\t\tconst { credited } = crediting.require();"
      - "\t\t\tconst { coupon } = crediting.require();"
      - "\t\t\tconst { coupon } = crediting.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { draft } = documents.require();"
      - "\t\t\tconst { deletableDraft } = documents.require();"
      - "\t\t\tconst { memo } = documents.require();"
      - "\t\t\tconst { memo } = documents.require();"
      - "\t\t\tconst { memo } = documents.require();"
      - "\t\t\tconst { memo } = documents.require();"
      - "\t\t\tdocuments.require();"
      - "\t\t\tdocuments.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { open } = documents.require();"
      - "\t\t\tconst { proFormaDraft } = documents.require();"
      - "\t\t\tconst { draft } = documents.require();"
      - "\t\t\tconst { proForma } = documents.require();"
    test_double_declarations: []
---

# Invoices table 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 direct mutation cannot alter issued content; excessive credit leaves no financial footprint. 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.
