---
id: TST-ACC-TRX-093
title: Invoices queries 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.queries.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.queries.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/persistence/invoices.queries.integration.spec.js
    assertion_titles:
      - 'the invoices persistence: reads (integration)'
      - loadInvoice
      - generates UUIDv7 ids for the invoice and its lines
      - 'maps the header and both lines of an issued invoice, every column'
      - maps the same record when it locks the invoice for update
      - answers undefined for an invoice that does not exist
      - answers undefined for another tenant’s invoice
      - listInvoices
      - >-
        lists the tenant’s invoices newest first, the same date by id
        descending, without another tenant’s
      - maps each listed invoice as loadInvoice does
      - filters by status
      - filters by business unit
      - filters by customer
      - filters by pro forma
      - 'filters by an invoice date range, both ends inclusive'
      - combines a status and a customer filter
      - answers a first page of two and the keyset of its last invoice
      - answers the next page from the keyset
      - answers the exact-size last page without a keyset
      - answers an empty page for a filter nothing matches
      - listOpenInvoicesOf
      - >-
        lists the customer’s issued invoices with a balance, oldest first,
        leaving out the draft, the void, the settled and the pro forma invoice
        (FC-06: a pro forma takes no allocation)
      - maps each open invoice as loadInvoice does
      - answers at most the limit
      - answers nothing for a customer whose one invoice is a draft
      - listInvoicesInBatches
      - lists the batches’ invoices in batch then id order
      - maps each invoice as loadInvoice does
      - answers at most the limit
      - answers nothing for no batches
      - findInvoiceIdByIdempotencyKey
      - answers the id of the invoice created under the key
      - answers undefined for a key no invoice was created under
      - answers undefined for another tenant’s key
    imports:
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { createDraft } =
        require('../../../../services/invoices/invoice-drafts');
      - >-
        const { issueInvoice } =
        require('../../../../services/invoices/invoice-issue');
      - >-
        const { voidInvoice } =
        require('../../../../services/invoices/invoice-changes');
      - '} = require(''../../../../services/persistence/invoices'');'
      - '} = require(''../../invoices-fixtures'');'
      - "\t\t\tconst { ids } = fixture.require();"
      - "\t\t\tconst { ids } = fixture.require();"
      - "\t\t\tconst { ids } = fixture.require();"
      - "\t\t\tfixture.require();"
      - "\t\t\tconst { foreign } = fixture.require();"
      - "\t\t\tconst { a, b, c, d, e, f } = fixture.require();"
      - "\t\t\tconst { ids } = fixture.require();"
      - "\t\t\tconst { a, c, d } = fixture.require();"
      - "\t\t\tconst { d } = fixture.require();"
      - "\t\t\tconst { b } = fixture.require();"
      - "\t\t\tconst { c } = fixture.require();"
      - "\t\t\tconst { a, b, c } = fixture.require();"
      - "\t\t\tconst { a } = fixture.require();"
      - "\t\t\tconst { c, f } = fixture.require();"
      - "\t\t\tconst { a, b, c } = fixture.require();"
      - "\t\t\tconst { d, e } = fixture.require();"
      - "\t\t\tconst [, second] = [fixture.require().a.id, fixture.require().b.id].sort().reverse();"
      - "\t\t\tfixture.require();"
      - "\t\t\tconst { a, d } = fixture.require();"
      - "\t\t\tconst { ids } = fixture.require();"
      - "\t\t\tconst { d } = fixture.require();"
      - "\t\t\tconst { b } = fixture.require();"
      - "\t\t\tconst { a, d } = fixture.require();"
      - "\t\t\tconst { ids } = fixture.require();"
      - "\t\t\tconst { a } = fixture.require();"
      - "\t\t\tfixture.require();"
      - "\t\t\tconst { a } = fixture.require();"
      - "\t\t\tfixture.require();"
      - "\t\t\tconst { foreign } = fixture.require();"
    test_double_declarations: []
---

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