---
id: TST-ACC-TRX-120
title: Receivables aging pipeline 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/runs/ar-aging-pipeline.integration.spec.js
implements:
  - ATS-ACC-TRX-018-01
  - ATS-ACC-TRX-018-02
  - ATS-ACC-TRX-018-03
  - ATS-ACC-TRX-018-04
  - ATS-ACC-TRX-018-05
  - ATS-ACC-TRX-018-07
implements_parts:
  - scenario: ATS-ACC-TRX-018-01
    assertion: >-
      it plans version 1 of September for each eligible tenant, captured and
      scheduled, known at September’s end
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      plans version 1 of September for each eligible tenant, captured and
      scheduled, known at September’s end
  - scenario: ATS-ACC-TRX-018-01
    assertion: >-
      it plans nothing twice: a second pass creates no run, and the ledger holds
      one run per tenant
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      plans nothing twice: a second pass creates no run, and the ledger holds
      one run per tenant
  - scenario: ATS-ACC-TRX-018-02
    assertion: >-
      it captures the open items as known at September’s end: the back-dated
      check recorded on 5 October is not in it
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      captures the open items as known at September’s end: the back-dated check
      recorded on 5 October is not in it
  - scenario: ATS-ACC-TRX-018-02
    assertion: 'it leaves the voided invoice out: its balance is zero at the period end'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      leaves the voided invoice out: its balance is zero at the period end
  - scenario: ATS-ACC-TRX-018-03
    assertion: >-
      it copies each item’s number, its business unit and currency, and the
      customer’s name from CRM
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      copies each item’s number, its business unit and currency, and the
      customer’s name from CRM
  - scenario: ATS-ACC-TRX-018-03
    assertion: >-
      it totals the items per business unit, currency and bucket, and the totals
      reconcile to 210.00
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      totals the items per business unit, currency and bucket, and the totals
      reconcile to 210.00
  - scenario: ATS-ACC-TRX-018-04
    assertion: it fails the broken tenant’s run and publishes nothing for it
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      fails the broken tenant’s run and publishes nothing for it
  - scenario: ATS-ACC-TRX-018-04
    assertion: >-
      it leaves none of the failed run’s rows behind: its transaction rolled
      back
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      leaves none of the failed run’s rows behind: its transaction rolled back
  - scenario: ATS-ACC-TRX-018-04
    assertion: it queues it for a retry rather than giving up at once
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      queues it for a retry rather than giving up at once
  - scenario: ATS-ACC-TRX-018-05
    assertion: >-
      it publishes version 2 as the current version and keeps version 1, no
      longer current
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      publishes version 2 as the current version and keeps version 1, no longer
      current
  - scenario: ATS-ACC-TRX-018-05
    assertion: 'it keeps version 1’s rows as they were captured, readable by its run'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      keeps version 1’s rows as they were captured, readable by its run
  - scenario: ATS-ACC-TRX-018-07
    assertion: it reads none of another tenant’s items even when the statement names it
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js#it
      reads none of another tenant’s items even when the statement names it
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/runs/ar-aging-pipeline.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/runs/ar-aging-pipeline.integration.spec.js
    assertion_titles:
      - >-
        the A/R aging snapshot: planned, admitted, captured, reconstructed,
        refused, isolated and purged
      - planning
      - >-
        plans version 1 of September for each eligible tenant, captured and
        scheduled, known at September’s end
      - >-
        plans nothing twice: a second pass creates no run, and the ledger holds
        one run per tenant
      - the captured version
      - publishes the main tenant’s run as the current version 1
      - >-
        captures the open items as known at September’s end: the back-dated
        check recorded on 5 October is not in it
      - >-
        copies each item’s number, its business unit and currency, and the
        customer’s name from CRM
      - 'leaves the voided invoice out: its balance is zero at the period end'
      - >-
        totals the items per business unit, currency and bucket, and the totals
        reconcile to 210.00
      - 'records the summary, the row count and every check passed on the run'
      - a validation that fails
      - fails the broken tenant’s run and publishes nothing for it
      - 'names the check that failed: the bucket of the misfiled item'
      - 'leaves none of the failed run’s rows behind: its transaction rolled back'
      - queues it for a retry rather than giving up at once
      - two tenants
      - publishes the other tenant’s own run with its own one item
      - >-
        reads only its own tenant’s items through the published view, with no
        tenant predicate in the statement
      - reads none of another tenant’s items even when the statement names it
      - a reconstructed rerun
      - >-
        publishes version 2 as the current version and keeps version 1, no
        longer current
      - names the version it supersedes
      - >-
        includes the back-dated check recorded after the period end: the invoice
        it paid is 70.00
      - 'keeps version 1’s rows as they were captured, readable by its run'
      - answers only version 2 through the published view
      - the tenant purge
      - had the tenant’s snapshot rows and run jobs before the purge (premise)
      - 'removes every snapshot item, total and run job of the tenant'
      - proves it with an inventory of zero for each snapshot table
      - leaves the other tenant’s snapshot rows where they were
      - was planned at a fixed instant after September’s capture delay (premise)
    imports:
      - 'const { sql } = require(''drizzle-orm'');'
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { planSnapshotRuns } =
        require('@rhythmsoftware/macroservice-snapshots/snapshot-planner');
      - >-
        const { resetJobEngineChannelDepsForTests } =
        require('@rhythmsoftware/macroservice-jobs/engine/job-engine');
      - >-
        const { integrationDatabaseUrl } =
        require('../../../../../../db/config');
      - >-
        const { setLocalTenantLifecycleState } =
        require('../../../../../../db/test-support/platform-tables');
      - >-
        const { listSnapshotTenants } =
        require('../../../../../maintenance/services/persistence/tenants');
      - >-
        const { accountingTransactionsParticipant } =
        require('../../../../services/lifecycle/transactions-participant');
      - >-
        const { SNAPSHOT_STORE, requestSnapshotRun } =
        require('../../../../services/persistence/snapshot-runs');
      - >-
        const { arAgingSnapshot, AR_AGING_CHECKS } =
        require('../../../../services/types/ar-aging');
      - '} = require(''../../ar-aging-fixtures'');'
      - "\t\tarranging.require();"
      - "\t\tplanning.require();"
      - "\t\t\tconst { runs } = planning.require();"
      - "\t\t\tplanning.require();"
      - "\t\t\tconst { main } = running.require();"
      - "\t\t\tconst { main } = running.require();"
      - "\t\t\tconst { main: world } = arranging.require();"
      - "\t\t\tconst { main } = running.require();"
      - "\t\t\tconst { main } = running.require();"
      - "\t\t\texpect((await itemsOf(main.id)).map((item) => item.item_id)).to.not.include(arranging.require().main.i4);"
      - "\t\t\tconst { main } = running.require();"
      - "\t\t\tconst { main } = running.require();"
      - "\t\t\tconst { broken } = running.require();"
      - "\t\t\tconst { broken } = running.require();"
      - "\t\t\tconst { broken } = running.require();"
      - "\t\t\tconst { broken } = running.require();"
      - "\t\t\tconst { other } = running.require();"
      - "\t\t\t\t[{ item_kind: 'invoice', item_id: arranging.require().other, balance: '25.00', aging_bucket: 'current' }],"
      - "\t\t\trunning.require();"
      - "\t\t\trunning.require();"
      - "\t\trunning.require();"
      - "\t\t\tconst { runs } = reconstructing.require();"
      - "\t\t\tconst { runs } = reconstructing.require();"
      - "\t\t\tconst { runs } = reconstructing.require();"
      - "\t\t\tconst { main: world } = arranging.require();"
      - "\t\t\tconst { runs } = reconstructing.require();"
      - "\t\t\tconst { runs } = reconstructing.require();"
      - "\t\treconstructing.require();"
      - "\t\t\texpect(purging.require().before).to.deep.equal({ items: 8, totals: 8, jobs: 2 });"
      - "\t\t\tconst { outcome, after } = purging.require();"
      - "\t\t\tconst { inventory } = purging.require();"
      - "\t\t\tpurging.require();"
    test_double_declarations:
      - ' * Platform''s ledger (its local stand-in), the job engine, the run worker (`aws/lambda/RUN.ts`), the type''s SQL and validation,'
      - >-
        const { resetJobEngineChannelDepsForTests } =
        require('@rhythmsoftware/macroservice-jobs/engine/job-engine');
      - "\tafter(() => resetJobEngineChannelDepsForTests());"
---

# Receivables aging pipeline 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 monthly planning is repeat-safe; capture excludes information learned after cutoff; published items reconcile with grouped totals; validation failure rolls back one capture; new publication preserves the earlier version; aging access also isolates workspaces. 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.
