---
id: TST-ACC-TRX-039
title: Reassign and edit 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/document-edits/reassign-and-edit.integration.spec.js
implements:
  - ATS-ACC-TRX-002-01
  - ATS-ACC-TRX-002-02
  - ATS-ACC-TRX-002-03
  - ATS-ACC-TRX-002-07
  - ATS-ACC-TRX-015-03
  - ATS-ACC-TRX-015-04
  - ATS-ACC-TRX-015-05
  - ATS-ACC-TRX-015-06
  - ATS-ACC-TRX-015-07
implements_parts:
  - scenario: ATS-ACC-TRX-002-01
    assertion: >-
      it answers the invoice at revision 2 with the line added after the last,
      the line repriced and the totals re-derived
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      answers the invoice at revision 2 with the line added after the last, the
      line repriced and the totals re-derived
  - scenario: ATS-ACC-TRX-002-01
    assertion: >-
      it writes the amended facts for the delta, the originals untouched, and
      the amend event with the delta
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      writes the amended facts for the delta, the originals untouched, and the
      amend event with the delta
  - scenario: ATS-ACC-TRX-002-01
    assertion: >-
      it taxes the added line at the invoice’s address and re-makes the repriced
      line’s tax lines from its new net amount
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      taxes the added line at the invoice’s address and re-makes the repriced
      line’s tax lines from its new net amount
  - scenario: ATS-ACC-TRX-002-02
    assertion: >-
      it removes a line with nothing applied at the next revision, and refuses
      removing or repricing the paid line
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      removes a line with nothing applied at the next revision, and refuses
      removing or repricing the paid line
  - scenario: ATS-ACC-TRX-002-03
    assertion: it is refused batch_not_open once the batch is posted
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      is refused batch_not_open once the batch is posted
  - scenario: ATS-ACC-TRX-002-03
    assertion: >-
      it is refused batch_not_open on a change of its dates, while its text
      still changes
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      is refused batch_not_open on a change of its dates, while its text still
      changes
  - scenario: ATS-ACC-TRX-002-07
    assertion: >-
      it moves the invoice date of an issued, unposted invoice, re-dating its
      facts; refuses a date after its due date
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      moves the invoice date of an issued, unposted invoice, re-dating its
      facts; refuses a date after its due date
  - scenario: ATS-ACC-TRX-015-03
    assertion: it moves an invoice to alpha-2026-03 and writes its event
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      moves an invoice to alpha-2026-03 and writes its event
  - scenario: ATS-ACC-TRX-015-03
    assertion: it moves a credit application to alpha-2026-03 and writes its event
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      moves a credit application to alpha-2026-03 and writes its event
  - scenario: ATS-ACC-TRX-015-03
    assertion: it is refused batch_not_open on a reassignment out of the batch
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      is refused batch_not_open on a reassignment out of the batch
  - scenario: ATS-ACC-TRX-015-03
    assertion: it is refused batch_not_open as a target of a reassignment
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      is refused batch_not_open as a target of a reassignment
  - scenario: ATS-ACC-TRX-015-03
    assertion: it answers the payment unchanged when the batch named is its own
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      answers the payment unchanged when the batch named is its own
  - scenario: ATS-ACC-TRX-015-04
    assertion: it moves the allocation rows batched with it
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      moves the allocation rows batched with it
  - scenario: ATS-ACC-TRX-015-04
    assertion: >-
      it writes the reassign event with both batches and the rows moved, and no
      fact
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      writes the reassign event with both batches and the rows moved, and no
      fact
  - scenario: ATS-ACC-TRX-015-04
    assertion: it replays the same key without moving again
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      replays the same key without moving again
  - scenario: ATS-ACC-TRX-015-05
    assertion: it refuses a void payment
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      refuses a void payment
  - scenario: ATS-ACC-TRX-015-06
    assertion: >-
      it changes the reference number and notes, clears the memo, and leaves the
      money
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      changes the reference number and notes, clears the memo, and leaves the
      money
  - scenario: ATS-ACC-TRX-015-06
    assertion: 'it never clears a required field (a credit’s reason), and changes its memo'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      never clears a required field (a credit’s reason), and changes its memo
  - scenario: ATS-ACC-TRX-015-07
    assertion: >-
      it negates the facts on the old accounting date and restates them on the
      new one, the originals untouched
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      negates the facts on the old accounting date and restates them on the new
      one, the originals untouched
  - scenario: ATS-ACC-TRX-015-07
    assertion: it is read as of the new date and no longer as of the old one
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      is read as of the new date and no longer as of the old one
  - scenario: ATS-ACC-TRX-015-07
    assertion: 'it moves a credit memo’s accounting date, re-dating its facts'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      moves a credit memo’s accounting date, re-dating its facts
  - scenario: ATS-ACC-TRX-015-07
    assertion: it refuses an accounting date no fiscal period covers (period_not_open)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js#it
      refuses an accounting date no fiscal period covers (period_not_open)
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/document-edits/reassign-and-edit.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/document-edits/reassign-and-edit.integration.spec.js
    assertion_titles:
      - reassign batch and edit the non-money fields (integration)
      - reassigning a payment
      - 'answers the payment in its new batch, at the next version'
      - moves the allocation rows batched with it
      - >-
        writes the reassign event with both batches and the rows moved, and no
        fact
      - replays the same key without moving again
      - answers the payment unchanged when the batch named is its own
      - >-
        refuses a closed batch, another unit’s batch and a batch that does not
        exist
      - refuses a void payment
      - reassigning the other kinds
      - moves an invoice to alpha-2026-03 and writes its event
      - moves a credit memo to alpha-2026-03 and writes its event
      - moves a write-off to alpha-2026-03 and writes its event
      - moves a credit to alpha-2026-03 and writes its event
      - moves a credit application to alpha-2026-03 and writes its event
      - a document of a posted batch
      - is refused batch_not_open on a reassignment out of the batch
      - is refused batch_not_open as a target of a reassignment
      - >-
        is refused batch_not_open on a change of its dates, while its text still
        changes
      - editing the non-money fields
      - >-
        changes the reference number and notes, clears the memo, and leaves the
        money
      - >-
        moves the payment date and the accounting date while the payment is
        unposted
      - >-
        negates the facts on the old accounting date and restates them on the
        new one, the originals untouched
      - is read as of the new date and no longer as of the old one
      - refuses an accounting date no fiscal period covers (period_not_open)
      - 'never clears a required field (a credit’s reason), and changes its memo'
      - 'moves a credit memo’s accounting date, re-dating its facts'
      - the invoice’s dates through its own command
      - >-
        moves the invoice date of an issued, unposted invoice, re-dating its
        facts; refuses a date after its due date
      - 'amending an issued, unposted invoice'
      - >-
        answers the invoice at revision 2 with the line added after the last,
        the line repriced and the totals re-derived
      - >-
        writes the amended facts for the delta, the originals untouched, and the
        amend event with the delta
      - >-
        removes a line with nothing applied at the next revision, and refuses
        removing or repricing the paid line
      - >-
        changes the due date, writing the details-changed fact, and keeps the
        live balance equal to the facts
      - is refused batch_not_open once the batch is posted
      - amending a taxed invoice (the tax configuration laid over the world)
      - >-
        issued with the dues line taxed (State 8.875% and City 4.5% of 60.00)
        and the gala line not
      - >-
        taxes the added line at the invoice’s address and re-makes the repriced
        line’s tax lines from its new net amount
      - >-
        writes the amended facts with the tax inside, and the balance equal to
        the facts
      - 'removes the added, taxed line with its tax lines at the next revision'
    imports:
      - 'const { sql } = require(''drizzle-orm'');'
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { saveBatches } =
        require('../../../../../batches/services/persistence/batches');
      - >-
        const { createCreditMemo } =
        require('../../../../services/change-memos/memo-commands');
      - >-
        const { applyCredit, createCredit } =
        require('../../../../services/credits/credit-commands');
      - >-
        const { reassignBatch } =
        require('../../../../services/document-edits/batch-reassignment');
      - >-
        const { updateDocumentDetails } =
        require('../../../../services/document-edits/detail-edits');
      - >-
        const { amendInvoice } =
        require('../../../../services/invoices/invoice-amendments');
      - >-
        const { updateDetails } =
        require('../../../../services/invoices/invoice-changes');
      - >-
        const { voidPayment } =
        require('../../../../services/payments/payment-allocate');
      - >-
        const { receivePayment } =
        require('../../../../services/payments/payment-receive');
      - >-
        const { listOpenItemsAsOf } =
        require('../../../../services/persistence/receivable-events');
      - >-
        const { createWriteOff } =
        require('../../../../services/write-offs/write-off-commands');
      - >-
        const { NEW_YORK_SOCIETY, createTaxWorld } =
        require('../../tax-fixtures');
      - '} = require(''../../payments-fixtures'');'
      - "\t\t\tconst { invoice } = world.require();"
      - "\t\t\tconst { payment, answer } = moved.require();"
      - "\t\t\tconst { payment } = moved.require();"
      - "\t\t\tconst { payment, factsBefore } = moved.require();"
      - "\t\t\tconst { answer, replay } = moved.require();"
      - "\t\t\tconst { payment, answer } = moved.require();"
      - "\t\t\tconst { payment } = moved.require();"
      - "\t\t\tconst { invoice } = world.require();"
      - "\t\t\tawait movedToMarch('invoice', 'invoices', made.require().invoice);"
      - "\t\t\tawait movedToMarch('credit_memo', 'credit_memos', made.require().memo);"
      - "\t\t\tawait movedToMarch('write_off', 'write_offs', made.require().writeOff);"
      - "\t\t\tawait movedToMarch('credit', 'credits', made.require().credit);"
      - "\t\t\tawait movedToMarch('credit_application', 'credit_applications', made.require().application);"
      - "\t\t\tconst { invoice } = world.require();"
      - "\t\t\tconst { payment } = posted.require();"
      - "\t\t\tconst { invoice } = world.require();"
      - "\t\t\tconst { payment } = posted.require();"
      - "\t\t\tconst { invoice } = world.require();"
      - "\t\t\tconst { payment, text } = edited.require();"
      - "\t\t\tconst { dated } = edited.require();"
      - "\t\t\tconst { payment, factsBefore } = edited.require();"
      - "\t\t\tconst { invoice, openBefore } = edited.require();"
      - "\t\t\tconst { payment } = edited.require();"
      - "\t\t\tconst { invoice } = world.require();"
      - "\t\t\tconst { invoice, answer } = amended.require();"
      - "\t\t\tconst { invoice, factsBefore } = amended.require();"
      - "\t\t\tconst { invoice, answer } = amended.require();"
      - "\t\t\tconst { invoice } = amended.require();"
      - "\t\t\tconst { invoice } = taxed.require();"
      - "\t\t\tconst { invoice, answer } = taxed.require();"
      - "\t\t\tconst { invoice, answer } = taxed.require();"
      - "\t\t\tconst { invoice, answer } = taxed.require();"
    test_double_declarations: []
---

# Reassign and edit 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 amendment retains a revised bill and its delta; applied lines resist replacement; posting prevents commercial correction; date correction retains opposing history; movement preserves the posting boundary; receipt movement includes its original applications; inactive money cannot change batch; descriptive correction cannot erase required explanation; date correction restates history in an eligible period. 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.
