---
id: WF-ACC-BAT-008
title: 'Post, recognise and reverse system batches for fiscal close'
trigger: >-
  Fiscal close or reopening reaches recognition and system-accounting work for a
  business-unit period.
product_area: accounting
module: batches
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
implements:
  - CAP-ACC-BAT-020
  - CAP-ACC-BAT-019
moves:
  - STATE-ACC-BAT-001
  - STATE-ACC-BAT-004
  - STATE-ACC-BAT-005
crosses:
  - SVC-ACC-BAT-batches
idempotency: >-
  A system event key reuses an identical recorded request and rejects changed
  content. Repeating reversal for an already retired generation reports no new
  reversal.
concurrency: >-
  All functions require the fiscal caller transaction. They share-lock the
  period and lock affected current plans and system collection; fiscal
  orchestration holds its own period lock.
hops:
  - 'n': 1
    actor_or_service: Month-end Close
    action: Invoke due recognition within the fiscal caller transaction.
    anchor: >-
      services-accounting:modules/batches/services/close/revenue-recognition.ts:recogniseDueEntries
    seam: sync
    on_failure: An invalid transaction or recognition failure aborts fiscal accounting.
    left_inconsistent: No partial fiscal recognition commits.
    observer: The fiscal job phases
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/close/revenue-recognition.integration.spec.js#refuses
      recognition outside a transaction (`transaction-required`)
  - 'n': 2
    actor_or_service: Recognition
    action: >-
      Lock current Open plans, release due entries, mark fully released plans
      Recognized and return the corresponding system entries.
    anchor: >-
      services-accounting:modules/batches/services/close/close-rules.ts:recogniseSchedule
    seam: sync
    on_failure: Periods outside Open or Closing reject recognition.
    left_inconsistent: Plan changes roll back with fiscal accounting.
    observer: Fiscal close
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/close/revenue-recognition.ts:recogniseDueEntries
  - 'n': 3
    actor_or_service: System batches
    action: >-
      Validate balanced entries, same-unit accounts, dates and duplicates, then
      create or reuse the period system collection and posting event.
    anchor: >-
      services-accounting:modules/batches/services/close/system-batches.ts:postSystemBatch
    seam: sync
    on_failure: >-
      Invalid content, reused key or conflicting collection rejects the fiscal
      transaction.
    left_inconsistent: No partial system generation commits.
    observer: Fiscal close
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/close/post-system-batch.integration.spec.js#writes
      the batch already posted, in the period, named and dated as given
  - 'n': 4
    actor_or_service: Month-end Close (reopen)
    action: >-
      On reopening, unrecognise affected releases in the caller transaction
      before retiring the corresponding system generation.
    anchor: >-
      services-accounting:modules/batches/services/close/revenue-recognition.ts:unrecogniseEntries
    seam: sync
    on_failure: Periods outside Closed or Reopening reject the function.
    left_inconsistent: Plan restoration rolls back with the caller transaction.
    observer: Fiscal reopening
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/close/revenue-recognition.integration.spec.js#un-recognizes
      A's and B's September entries and opens both schedules again
  - 'n': 5
    actor_or_service: System batches
    action: >-
      Append mirrored entries, retain originals, mark the system posting
      reversed and restore the collection to Open.
    anchor: >-
      services-accounting:modules/batches/services/close/system-batches.ts:reverseSystemBatch
    seam: sync
    on_failure: Any reversal write failure aborts the caller transaction.
    left_inconsistent: No partial mirror generation commits.
    observer: Fiscal reopening
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/close/reverse-system-batch.integration.spec.js#writes
      a reversing entry for each entry, debits and credits swapped, and keeps
      the originals
branches:
  - >-
    Closing again after reopening creates a new system generation and suffixes
    reused entry identities.
waits: []
evidence:
  - >-
    services-accounting at f47cb263: modules/batches/services/close/**;
    services/posting-period-guard.ts; services/persistence/system-batches.ts,
    revenue-recognition-schedules.ts, subledger-entries.ts;
    docs/migrations/batch-posting/README.md (Fiscal close functions)
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-TEN-004, TC-DAT-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-PI-001, TC-PI-003, TC-PI-005]
---

# Post, recognise and reverse system batches for fiscal close

## What It Does

Fiscal orchestration owns the period process; Batch Management supplies recognition and system-ledger functions inside that caller transaction. Fiscal reopening retains original entries and writes mirrors, which differs from ordinary unposting deletion.

## The Flow

```mermaid
flowchart LR
  F[Fiscal transaction] --> R[Release due plan entries]
  R --> P[Post system generation]
  F --> U[Undo affected recognition]
  U --> M[Mirror system generation]
  P --> C[Caller commit]
  M --> C
```

## When Something Fails

Invalid fiscal state or accounting content aborts the caller transaction. Event identity protects identical repeats, while changed requests require another event key. No later compensation path is invented by this contract.

## Open Design Questions

Product must resolve interactions between recognition and ordinary source unposting, including the possibility of periods completed out of order.
