---
id: TST-ACC-TRX-030
title: Batches for documents 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/batches-for-documents.integration.spec.js
implements:
  - ATS-ACC-TRX-015-01
  - ATS-ACC-TRX-015-02
implements_parts:
  - scenario: ATS-ACC-TRX-015-01
    assertion: it accepts an open transaction batch of the unit
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      accepts an open transaction batch of the unit
  - scenario: ATS-ACC-TRX-015-01
    assertion: 'it accepts a batch of the unit in error, as Rhythm 1.0 did'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      accepts a batch of the unit in error, as Rhythm 1.0 did
  - scenario: ATS-ACC-TRX-015-01
    assertion: 'it refuses a closed batch (batch_not_open), in 1.0’s sentence'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      refuses a closed batch (batch_not_open), in 1.0’s sentence
  - scenario: ATS-ACC-TRX-015-01
    assertion: it refuses a posted batch (batch_not_open)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      refuses a posted batch (batch_not_open)
  - scenario: ATS-ACC-TRX-015-01
    assertion: >-
      it refuses a system batch, which is period close’s: a transaction batch
      only (batch_not_open)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      refuses a system batch, which is period close’s: a transaction batch only
      (batch_not_open)
  - scenario: ATS-ACC-TRX-015-01
    assertion: it refuses an open batch of another business unit (batch_not_open)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      refuses an open batch of another business unit (batch_not_open)
  - scenario: ATS-ACC-TRX-015-02
    assertion: >-
      it gives an invoice, which no rule matches, the active batch of the
      default recurring batch
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      gives an invoice, which no rule matches, the active batch of the default
      recurring batch
  - scenario: ATS-ACC-TRX-015-02
    assertion: >-
      it gives a credit memo the active batch of the recurring batch its rule
      chooses
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      gives a credit memo the active batch of the recurring batch its rule
      chooses
  - scenario: ATS-ACC-TRX-015-02
    assertion: >-
      it is refused batch_required once the chosen recurring batch’s active
      batch is closed (BA-12), naming the reason
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js#it
      is refused batch_required once the chosen recurring batch’s active batch
      is closed (BA-12), naming the reason
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/batches-for-documents.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/batches-for-documents.integration.spec.js
    assertion_titles:
      - the batch a document posts in (integration)
      - the batch named
      - accepts an open transaction batch of the unit
      - 'accepts a batch of the unit in error, as Rhythm 1.0 did'
      - 'refuses a closed batch (batch_not_open), in 1.0’s sentence'
      - refuses a posted batch (batch_not_open)
      - >-
        refuses a system batch, which is period close’s: a transaction batch
        only (batch_not_open)
      - refuses an open batch of another business unit (batch_not_open)
      - refuses a batch the tenant has not (not_found)
      - judges a memo’s and a write-off’s batch by the same rule
      - no batch named
      - is refused batch_required in a unit without batch assignment settings
      - with the unit’s assignment rules
      - opened a first batch for each recurring batch (premise)
      - >-
        gives an invoice, which no rule matches, the active batch of the default
        recurring batch
      - >-
        gives a credit memo the active batch of the recurring batch its rule
        chooses
      - 'gives a write-off, which the rule leaves out, the default’s'
      - >-
        is refused batch_required once the chosen recurring batch’s active batch
        is closed (BA-12), naming the reason
      - 'still gives an invoice the default’s active batch, which is open'
    imports:
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { batchForDocument } =
        require('../../../services/batches-for-documents');
      - >-
        const { closeBatch, saveBatches } =
        require('../../../../batches/services/persistence/batches');
      - >-
        const { saveBatchAssignmentSettings } =
        require('../../../../batches/services/persistence/batch-assignment-settings');
      - >-
        const { createRecurringBatchWithFirstBatch } =
        require('../../../../batches/services/roll/first-batch');
      - >-
        const { createInvoiceWorld, expect, fixedIn, ready, refusalOf,
        removeTenantInvoices, testId } = require('../invoices-fixtures');
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tworld.require();"
      - "\t\t\t\t\tworld.require();"
      - "\t\t\t\tconst { daily, memos } = assigned.require();"
      - "\t\t\t\texpect(await batchFor(null, 'invoice')).to.equal(assigned.require().daily);"
      - "\t\t\t\texpect(await batchFor(null, 'credit_memo')).to.equal(assigned.require().memos);"
      - "\t\t\t\texpect(await batchFor(null, 'write_off')).to.equal(assigned.require().daily);"
      - "\t\t\t\tconst { memos } = assigned.require();"
      - "\t\t\t\texpect(await batchFor(null, 'invoice')).to.equal(assigned.require().daily);"
    test_double_declarations: []
---

# Batches for documents 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 batch eligibility distinguishes transaction destinations; assignment resolves each document kind. 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.
