/** * Accounting period locks (Festschreibung). One document per * (skrType, period 'YYYY-MM') in the LedgerPeriod collection. * * festschreibePeriod() stamps all posted schemaVersion-2 entries of the * period as finalized with an atomic plural update — deliberately bypassing * the doc-level immutability guard (beforeSave), because the finalization * fields live OUTSIDE the entry hash. Detection of any other tampering is * verifyHashChain()'s job. */ import * as plugins from './plugins.js'; import { type TDbSession } from './skr.database.js'; import type { TSKRType } from './skr.types.js'; export declare const LEDGER_PERIOD_COLLECTION = "LedgerPeriod"; export interface ILedgerPeriodState { skrType: TSKRType; period: string; status: 'open' | 'locked'; lockedAt?: Date; lockedBy?: string; chainCheckpoint?: { lastSequenceNumber: number; headHash: string; } | null; } /** The lock state of one (skrType, period). */ export declare class LedgerPeriod extends plugins.nosqldb.SmartDataDbDoc { skrType: TSKRType; period: string; status: 'open' | 'locked'; lockedAt?: Date; lockedBy?: string; chainCheckpoint?: { lastSequenceNumber: number; headHash: string; } | null; } export declare function periodOf(date: Date): string; export declare function fiscalYearOf(date: Date): number; /** * Throws PeriodLockedError when the period is festgeschrieben. Runs inside * the posting transaction so a concurrent lock aborts the posting. */ export declare function assertPeriodOpen(skrType: TSKRType, period: string, session?: TDbSession): Promise; export declare function getPeriodState(skrType: TSKRType, period: string): Promise; /** * Festschreibung: lock the period against new postings and stamp all posted * schemaVersion-2 entries as finalized. Idempotent — locking a locked period * throws so callers notice double runs. */ export declare function festschreibePeriod(params: { skrType: TSKRType; period: string; lockedBy?: string; lockedAt?: Date; }): Promise<{ finalizedEntries: number; checkpoint: ILedgerPeriodState['chainCheckpoint']; }>;