---
id: TST-ACC-TRX-010
title: Invoices 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/invoices.e2e.spec.js
implements:
  - ATS-ACC-TRX-001-04
  - ATS-ACC-TRX-002-01
  - ATS-ACC-TRX-002-07
  - ATS-ACC-TRX-002-10
  - ATS-ACC-TRX-016-01
  - ATS-ACC-TRX-016-02
  - ATS-ACC-TRX-016-04
implements_parts:
  - scenario: ATS-ACC-TRX-001-04
    assertion: it answers 400 to an amount that is not a whole number of minor units
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      answers 400 to an amount that is not a whole number of minor units
  - scenario: ATS-ACC-TRX-002-01
    assertion: >-
      it amends an issued, unposted invoice (POST .../amend): a line added, the
      revision 2, the e-mail subject saying so
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      amends an issued, unposted invoice (POST .../amend): a line added, the
      revision 2, the e-mail subject saying so
  - scenario: ATS-ACC-TRX-002-07
    assertion: >-
      it moves the invoice date of an issued, unposted invoice (PUT
      .../details), the due date staying after it
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      moves the invoice date of an issued, unposted invoice (PUT .../details),
      the due date staying after it
  - scenario: ATS-ACC-TRX-002-10
    assertion: >-
      it is refused POST /invoices/{tenantId}/{id}/amend without
      accounting.invoices.adjust (403)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      is refused POST /invoices/{tenantId}/{id}/amend without
      accounting.invoices.adjust (403)
  - scenario: ATS-ACC-TRX-002-10
    assertion: >-
      it is refused PUT /invoices/{tenantId}/{id}/terms without
      accounting.invoices.update (403)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      is refused PUT /invoices/{tenantId}/{id}/terms without
      accounting.invoices.update (403)
  - scenario: ATS-ACC-TRX-002-10
    assertion: >-
      it is refused PUT /invoices/{tenantId}/{id}/details without
      accounting.invoices.update (403)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      is refused PUT /invoices/{tenantId}/{id}/details without
      accounting.invoices.update (403)
  - scenario: ATS-ACC-TRX-002-10
    assertion: >-
      it is refused POST /invoices/{tenantId}/{id}/void without
      accounting.invoices.void (403)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      is refused POST /invoices/{tenantId}/{id}/void without
      accounting.invoices.void (403)
  - scenario: ATS-ACC-TRX-016-01
    assertion: it lists no action to a reader who may perform none
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      lists no action to a reader who may perform none
  - scenario: ATS-ACC-TRX-016-02
    assertion: >-
      it is refused the issue action by a reader without
      accounting.invoices.adjust (403), the draft unchanged
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      is refused the issue action by a reader without accounting.invoices.adjust
      (403), the draft unchanged
  - scenario: ATS-ACC-TRX-016-02
    assertion: it answers 409 to the issue action on an issued invoice
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      answers 409 to the issue action on an issued invoice
  - scenario: ATS-ACC-TRX-016-04
    assertion: >-
      it answers 404 for the other tenant’s invoice read in this tenant, as for
      an invoice that does not exist
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      answers 404 for the other tenant’s invoice read in this tenant, as for an
      invoice that does not exist
  - scenario: ATS-ACC-TRX-016-04
    assertion: >-
      it answers 404 to issuing the other tenant’s invoice in this tenant, and
      leaves it a draft
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js#it
      answers 404 to issuing the other tenant’s invoice in this tenant, and
      leaves it a draft
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/invoices.e2e.spec.js'
evidence:
  - provenance: test
    source: 'services-accounting:modules/transactions/tests/e2e/invoices.e2e.spec.js'
    assertion_titles:
      - the invoice routes (end to end)
      - a caller without the route’s permission
      - >-
        is refused POST /invoices/{tenantId} without accounting.invoices.create
        (403)
      - >-
        is refused PUT /invoices/{tenantId}/{id} without
        accounting.invoices.create (403)
      - >-
        is refused GET /invoices/{tenantId}/{id} without
        accounting.invoices.read (403)
      - >-
        is refused DELETE /invoices/{tenantId}/{id} without
        accounting.invoices.delete (403)
      - >-
        is refused GET /invoices/{tenantId} without accounting.invoices.read
        (403)
      - >-
        is refused POST /invoices/{tenantId}/{id}/issue without
        accounting.invoices.adjust (403)
      - >-
        is refused POST /invoices/{tenantId}/{id}/convert without
        accounting.invoices.adjust (403)
      - >-
        is refused POST /invoices/{tenantId}/{id}/void without
        accounting.invoices.void (403)
      - >-
        is refused PUT /invoices/{tenantId}/{id}/due_date without
        accounting.invoices.update (403)
      - >-
        is refused PUT /invoices/{tenantId}/{id}/terms without
        accounting.invoices.update (403)
      - >-
        is refused POST /invoices/{tenantId}/{id}/amend without
        accounting.invoices.adjust (403)
      - >-
        is refused PUT /invoices/{tenantId}/{id}/details without
        accounting.invoices.update (403)
      - >-
        is refused GET
        /customer_invoices/{tenantId}/{customerType}/{customerId}/open without
        accounting.invoices.read (403)
      - >-
        is refused GET /invoices/{tenantId}/{id}/actions without
        accounting.invoices.read (403)
      - >-
        is refused POST /invoices/{tenantId}/{id}/actions/{action_id} without
        accounting.invoices.read (403)
      - >-
        is refused the issue action by a reader without
        accounting.invoices.adjust (403), the draft unchanged
      - another tenant’s invoice
      - >-
        answers 404 for the other tenant’s invoice read in this tenant, as for
        an invoice that does not exist
      - >-
        answers 404 to issuing the other tenant’s invoice in this tenant, and
        leaves it a draft
      - refuses a path naming a tenant the signed context does not carry (403)
      - a body the contract refuses
      - answers 400 to a create without an Idempotency-Key
      - answers 400 to an amount that is not a whole number of minor units
      - answers 400 to an invoice date that is not a calendar date
      - answers 400 when the header and the body carry different keys
      - creates nothing for a refused body
      - 'create, issue and void'
      - answers 200 with the draft and its money in minor units
      - answers the replay of the same key and body with the same draft
      - 'answers 200 to the issue with the numbered, open invoice in its batch'
      - answers 200 to the void with the void invoice and its reason
      - reads the invoice back void
      - >-
        answers 409 to the same create key with another body
        (idempotency_key_reused)
      - answers 409 to issuing the void invoice (invoice_not_draft)
      - the draft and detail routes
      - >-
        REGRESSION — replaces a draft’s lines at the version read (PUT), which
        parses its body twice and so refuses every request
      - moves the due date (PUT .../due_date)
      - changes the terms and the due date with them (PUT .../terms)
      - changes the details (PUT .../details)
      - >-
        moves an issued invoice to another open batch (PUT .../batch), and
        refuses a closed one batch_not_open
      - >-
        amends an issued, unposted invoice (POST .../amend): a line added, the
        revision 2, the e-mail subject saying so
      - >-
        moves the invoice date of an issued, unposted invoice (PUT .../details),
        the due date staying after it
      - 'deletes a draft (DELETE), after which it reads 404'
      - converts an issued pro forma (POST .../convert)
      - the list and the open invoices
      - 'answers the newest of the unit’s invoices first, with a cursor'
      - 'answers the next page from the cursor, the last without one'
      - filters by status
      - answers 400 to a cursor the list did not issue
      - lists the customer’s open invoices oldest first
      - answers 400 to a customer type that is neither contact nor organization
      - the actions routes
      - 'lists issue, void and delete for a draft'
      - lists void and reassign batch for an issued invoice
      - lists no action to a reader who may perform none
      - issues a draft through POST .../actions/issue
      - answers 409 to the issue action on an issued invoice
    imports:
      - >-
        const { parseBody, proxyEvent } =
        require('@rhythmsoftware/macroservice-testing/signed-context');
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { accountingApi, accountingGrant } =
        require('../../../books/tests/e2e/e2e-security');
      - >-
        const { PERMISSION_MISSING, accessRefusalOf, requireOk } =
        require('../../../books/tests/e2e/configuration-e2e-support');
      - '} = require(''../integration/invoices-fixtures'');'
      - "\t\t\tctx: ctx ?? session.require().administrator,"
      - "\t\tsession.require();"
      - "\t\tsession.require();"
      - "\t\tsession.require();"
      - "\t\tconst outsider = () => session.require().outsider;"
      - "\t\tconst id = () => drafted.require().id;"
      - "\t\t\tconst answer = await call('POST', ACTION, { id: id(), action_id: 'issue', body: {}, ctx: session.require().reader });"
      - "\t\t\tconst other = foreign.require();"
      - "\t\t\tconst other = foreign.require();"
      - "\t\t\tconst other = foreign.require();"
      - "\t\t\tconst answer = await call('GET', ONE, { tenant: OTHER, id: other.id, ctx: session.require().tenantOnly });"
      - "\t\t\tsession.require();"
      - "\t\t\tsession.require();"
      - "\t\t\tsession.require();"
      - "\t\t\tsession.require();"
      - "\t\t\tsession.require();"
      - "\t\t\tsession.require();"
      - "\t\t\tconst { create } = flow.require();"
      - "\t\t\tconst { create, replay } = flow.require();"
      - "\t\t\tconst { issue } = flow.require();"
      - "\t\t\tconst { voiding } = flow.require();"
      - "\t\t\tconst { read, voiding } = flow.require();"
      - "\t\t\tflow.require();"
      - "\t\t\tconst { create } = flow.require();"
      - "\t\t\tsession.require();"
      - "\t\t\tconst { second, page1 } = listing.require();"
      - "\t\t\tconst { first, page2 } = listing.require();"
      - "\t\t\tconst { first, second } = listing.require();"
      - "\t\t\tlisting.require();"
      - "\t\t\tconst { first, second } = listing.require();"
      - "\t\t\tlisting.require();"
      - "\t\t\tconst open = opened.require();"
      - "\t\t\tconst draft = drafted.require();"
      - "\t\t\tconst answer = await call('GET', ACTIONS, { id: draft.id, ctx: session.require().reader });"
      - "\t\t\tconst open = opened.require();"
    test_double_declarations:
      - ' * accounts, products, batches, the CRM stand-in''s parties) is written through the persistence services, as the integration'
---

# 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

Its cited assertions contribute evidence for rounded lines reconcile with their document; amendment retains a revised bill and its delta; date correction retains opposing history; correction authority is distinct from reading; action lists explain lifecycle and protection; execution checks authority and current standing; workspace isolation treats foreign records as absent. 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.
