---
id: TST-ACC-TRX-065
title: Update draft 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/invoices/update-draft.integration.spec.js
implements:
  - ATS-ACC-TRX-001-01
  - ATS-ACC-TRX-001-02
implements_parts:
  - scenario: ATS-ACC-TRX-001-01
    assertion: it refuses an update at a version the draft has moved past (stale)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/invoices/update-draft.integration.spec.js#it
      refuses an update at a version the draft has moved past (stale)
  - scenario: ATS-ACC-TRX-001-01
    assertion: 'it keeps it a draft, unnumbered, at the next version'
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/invoices/update-draft.integration.spec.js#it
      keeps it a draft, unnumbered, at the next version
  - scenario: ATS-ACC-TRX-001-02
    assertion: >-
      it refuses a change of business unit: a draft keeps its unit
      (business_unit_mismatch)
    provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/invoices/update-draft.integration.spec.js#it
      refuses a change of business unit: a draft keeps its unit
      (business_unit_mismatch)
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/invoices/update-draft.integration.spec.js
evidence:
  - provenance: test
    source: >-
      services-accounting:modules/transactions/tests/integration/services/invoices/update-draft.integration.spec.js
    assertion_titles:
      - updateDraft (integration)
      - replacing a draft’s header and lines at the version read
      - 'answers the one new line, priced and extended from the new quantity'
      - takes the discount reason of the new line
      - recomputes the header totals from the new lines
      - >-
        takes the new bill-to with its name from CRM, the due date from the new
        terms, the memo and the purchase order number
      - 'keeps it a draft, unnumbered, at the next version'
      - reads back what it answered
      - removes the replaced lines from the table
      - records the update_draft document event after the create
      - 'the refusals, each leaving the draft as it was'
      - refuses an update at a version the draft has moved past (stale)
      - >-
        refuses a change of business unit: a draft keeps its unit
        (business_unit_mismatch)
      - >-
        refuses a change of currency, which the unit supports: a draft keeps its
        currency (business_unit_mismatch)
      - refuses a product the tenant has not (not_found)
      - >-
        refuses an issued invoice (invoice_not_draft): an issued invoice changes
        by a memo, never in place
      - records no event for a refused update
    imports:
      - 'const { stage } = require(''@rhythmsoftware/macroservice-testing/stage'');'
      - >-
        const { createDraft, updateDraft } =
        require('../../../../services/invoices/invoice-drafts');
      - >-
        const { issueInvoice } =
        require('../../../../services/invoices/invoice-issue');
      - >-
        const { getInvoice } =
        require('../../../../services/invoices/invoice-reads');
      - '} = require(''../../invoices-fixtures'');'
      - "\t\t\tworld.require();"
      - "\t\t\tconst { updated } = replaced.require();"
      - "\t\t\tconst { draft, updated } = replaced.require();"
      - "\t\t\tconst { updated } = replaced.require();"
      - "\t\t\tconst { updated } = replaced.require();"
      - "\t\t\tconst { draft, updated } = replaced.require();"
      - "\t\t\tconst { updated } = replaced.require();"
      - "\t\t\tconst { draft } = replaced.require();"
      - "\t\t\tconst { draft } = replaced.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tconst before = stateOf(await getInvoice(ctx(), draft.require().id));"
      - "\t\t\treturn [refusal.name, refusal.code, stateOf(await getInvoice(ctx(), draft.require().id)), before];"
      - "\t\t\tconst current = draft.require();"
      - "\t\t\tconst current = draft.require();"
      - "\t\t\tconst current = draft.require();"
      - "\t\t\tconst current = draft.require();"
      - "\t\t\tworld.require();"
      - "\t\t\tconst current = draft.require();"
    test_double_declarations:
      - ' * local stand-in. Doubled: nothing.'
---

# Update draft 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 obsolete draft saves preserve the newer state; draft context cannot switch units. 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.
