# Period End Close

## Overview

Period-end close is a structured, checklist-driven workflow that transitions an accounting period from open (accepting postings) to permanently closed (immutable). The process is modeled through a `PeriodClose` entity that tracks the close status, the user who initiated and completed each step, timestamps, and overall checklist completion percentage. Each close operation is scoped to a single `AccountingPeriod` within a company's active Chart of Accounts, ensuring that all financial activity for the period has been captured, verified, and reconciled before the period is locked. The workflow enforces a deterministic sequence of steps: subledger transfer verification, pending journal batch posting, adjusting entry creation (accruals, deferrals, reclassifications), trial balance verification, preliminary financial statement generation, review and approval, soft lock for the accounting team, final advisor adjustments, and permanent close.

Adjusting entries created during the close process are flagged with an `adjustingEntryType` (ACCRUAL, DEFERRAL, or RECLASSIFICATION) to distinguish them from regular operational entries for reporting and audit purposes. The soft-lock stage supports segregation of duties by allowing the accounting team to finalize routine entries while reserving a window for external auditors or advisors to post final adjustments before the period is permanently closed. Once permanently closed, no further journal entries can be posted regardless of role, preserving the immutability and auditability of the period's financial data.

## Business Purpose

Organizations require a disciplined period-close process to ensure the accuracy and integrity of their financial records:

- **Financial statement reliability**: A structured close checklist ensures all transactions are captured and verified before financial statements are generated, preventing material misstatements and supporting accurate reporting to stakeholders
- **Regulatory compliance**: Public companies and regulated entities must close periods within defined timelines (e.g., SEC 10-Q/10-K deadlines). A tracked, step-by-step workflow provides evidence of due diligence and process adherence for external auditors
- **Subledger completeness**: Verifying that all subledger modules (accounts payable, accounts receivable, inventory, manufacturing) have transferred their transactions to the general ledger prevents omissions that would distort the trial balance
- **Adjusting entry transparency**: Separating accruals, deferrals, and reclassifications from regular entries allows auditors and management to isolate period-end adjustments and assess their impact on reported figures
- **Data immutability after close**: Locking a closed period prevents accidental or unauthorized postings that would alter previously reported figures, preserving the audit trail and historical comparability
- **Multi-step approval**: The soft-lock and final-advisor-adjustment stages support segregation of duties, allowing the accounting team to finalize routine entries while reserving a window for external auditors or advisors to post final adjustments before permanent close
- **Cross-module coordination**: Period close status is consumed by other modules (purchase, sales, inventory, manufacturing) to determine whether they can post transactions to a given period, creating a unified control point for posting eligibility

## Process Flow

The period-close lifecycle follows a linear state machine with defined checkpoints at each stage:

```mermaid
stateDiagram-v2
    [*] --> NotStarted: initiatePeriodClose
    NotStarted --> InProgress: beginClose
    InProgress --> SubledgersVerified: verifySubledgerTransfers
    SubledgersVerified --> AdjustmentsPosted: postAdjustingEntries
    AdjustmentsPosted --> TrialBalanceVerified: verifyTrialBalance
    TrialBalanceVerified --> UnderReview: generatePreliminaryStatements
    UnderReview --> SoftLocked: approveAndLockPeriod
    SoftLocked --> PermanentlyClosed: finalCloseAndLockPeriod
    PermanentlyClosed --> [*]
```

The following flowchart details the end-to-end close checklist:

```mermaid
flowchart TD
    A[Initiate period close for AccountingPeriod] --> B[Verify all subledger transactions transferred to GL]
    B --> C{All subledgers reconciled?}
    C -- No --> B
    C -- Yes --> D[Post all pending journal batches]
    D --> E[Create adjusting entries: accruals, deferrals, reclassifications]
    E --> F[Run trial balance and verify debits equal credits]
    F --> G{Trial balance balanced?}
    G -- No --> E
    G -- Yes --> H[Generate preliminary financial statements]
    H --> I[Management review and approval]
    I --> J[Soft-lock period: block accounting team postings]
    J --> K[Final advisor/auditor adjustments]
    K --> L[Permanently close period]
    L --> M[Period is immutable - no further postings allowed]
```

## Scenario Patterns

- **Standard Monthly Close**: The accounting team initiates the close for January, verifies that AP and AR subledgers have posted all invoices, creates accrual entries for unbilled services received, verifies the trial balance, obtains controller approval, and permanently closes the period within five business days of month-end
- **Quarter-End Close with Reclassifications**: At the end of Q1, the accounting team identifies that certain expenses were posted to the wrong cost center. They create reclassification adjusting entries during the close process, rerun the trial balance, and generate preliminary quarterly financial statements for management review before soft-locking the period
- **Soft Lock with Auditor Adjustments**: The accounting team completes the monthly close checklist and soft-locks the period. An external auditor identifies a material adjustment and posts a correcting entry during the advisor-adjustment window. The period is then permanently closed with the auditor's entry included
- **Failed Subledger Verification**: During the close process, the system detects that the inventory module has pending cost-of-goods-sold entries that have not been transferred to the GL. The close cannot proceed past the subledger verification step until the inventory team completes the transfer and the close operator re-verifies
- **Reopening a Soft-Locked Period**: The controller discovers that an accrual was double-counted after the period was soft-locked but before permanent close. The period is reverted from soft-locked to in-progress, the duplicate accrual is reversed, the trial balance is re-verified, and the period is re-locked and permanently closed
- **Adjusting Entry for Deferred Revenue**: During the close, the accounting team recognizes a portion of deferred revenue that was earned during the period. They create an adjusting entry flagged as DEFERRAL that debits the deferred revenue liability and credits the revenue account, ensuring the income statement reflects revenue earned in the correct period

## Test Cases

- PeriodClose can only be initiated for an AccountingPeriod that is in OPEN status
- PeriodClose cannot be initiated for an AccountingPeriod that is already CLOSED or has an existing close in progress
- PeriodClose lifecycle follows NOT_STARTED -> IN_PROGRESS -> SUBLEDGERS_VERIFIED -> ADJUSTMENTS_POSTED -> TRIAL_BALANCE_VERIFIED -> UNDER_REVIEW -> SOFT_LOCKED -> PERMANENTLY_CLOSED state machine
- PeriodClose cannot skip steps; transitioning from NOT_STARTED directly to TRIAL_BALANCE_VERIFIED is rejected
- Subledger verification step fails if any registered subledger module has pending unposted transactions for the period
- Subledger verification step succeeds when all registered subledger modules confirm transfer completion
- Adjusting entries created during the close process must have a valid adjustingEntryType (ACCRUAL, DEFERRAL, or RECLASSIFICATION)
- Adjusting entries are flagged distinctly from regular journal entries for audit trail purposes
- Adjusting entries must be balanced (total debits equal total credits) before the close can proceed
- Trial balance verification step fails if the period's trial balance has a non-zero difference between total debits and total credits
- Trial balance verification step succeeds when debits equal credits across all accounts for the period
- Preliminary financial statements can only be generated after the trial balance is verified
- Approval step requires a user with the appropriate authorization role (e.g., controller or finance manager)
- Soft-locking a period prevents the accounting team from posting new journal entries to that period
- Soft-locked period still allows postings from users with the advisor/auditor role
- Final advisor adjustments posted during the soft-locked phase are recorded with an audit trail identifying the advisor
- Permanently closing a period makes it fully immutable; no further journal entries can be posted regardless of role
- Attempting to post a journal entry to a permanently closed period is rejected with a period-closed error
- PeriodClose records the userId of the operator who initiated the close and the userId who completed each checklist step
- PeriodClose tracks a completionPercentage that increments as each checklist step is completed
- Each state transition in the PeriodClose lifecycle emits an audit event recording the acting user, timestamp, previous status, and new status
- Reverting a soft-locked period to in-progress is permitted only before permanent close and emits an audit event
- Reverting a permanently closed period is not permitted
- PeriodClose is scoped to a single AccountingPeriod; each period has at most one active PeriodClose record
- Cross-module posting eligibility check: other modules (purchase, sales, inventory) receive a period-closed signal and reject postings to closed periods
- Concurrent close attempts for the same period are rejected with a conflict error

## Reference Links

- [SAP Period-End Closing in Financial Accounting](https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/ee3509643e954b3da2e0ebfa846c02e1/4588dcd34eab6e37e10000000a42189b.html)
- [Oracle Fusion General Ledger Close Process](https://docs.oracle.com/en/cloud/saas/financials/24d/oafcf/general-ledger-close.html)
- [NetSuite Period Close Checklist](https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N1581498.html)
- [Odoo Fiscal Year End and Closing](https://www.odoo.com/documentation/19.0/applications/finance/accounting/get_started/cheat_sheet.html)
- [Sage Intacct Period-End Close](https://www.sage.com/en-us/sage-business-cloud/intacct/features/general-ledger/)
