/** * OPOS (Offene-Posten-Buchhaltung): open-item accounting over the v2 ledger. * * Open items are DERIVED from the hashed journal — no separate bookkeeping * state that could drift. A line on a personal account (debtors 10000-69999, * creditors 70000-99999) belongs to the open item keyed by * (account, belegfeld1); the item is open while its signed sum is non-zero. * The key is DATEV's: Belegfeld 1 is the "Rechnungs-/Belegnummer[, w]ird als * 'Schlüssel' für den Ausgleich offener Rechnungen genutzt" (DATEV-Format, * Buchungsstapel field 11), so every settlement — a payment, a credit note, a * refund — repeats the INVOICE number there and lands on the invoice's item. * Settling an item is ordinary posting (core.bookBankPayment + JournalPoster), * so Festschreibung and the audit chain apply unchanged. * * The derivation itself is pure and lives in the core * (`core.deriveOpenItems`, `core.bucketOpenItems`, `core.openItemsOf`; * re-exported here): only listOpenItems/getAging add the database and the * dunning metadata around it. * * Only dunning metadata lives outside the ledger (OposMeta collection) — * process state, not bookkeeping. */ import * as core from './core/index.js'; import { type IAgingBucket, type IOpenItem, type IOposLineRow, type TOposKind } from './core/core.openitems.js'; export { deriveOpenItems, bucketOpenItems, planOpenItemSettlement } from './core/core.openitems.js'; export type { IAgingBucket, IOpenItem, IOpenItemSettlementPlan, IOposLineRow, TOposKind } from './core/core.openitems.js'; import * as plugins from './plugins.js'; import type { IJournalEntryLine, TSKRType } from './skr.types.js'; export declare const OPOS_META_COLLECTION = "OposMeta"; /** The unique key of a dunning record: one per (skrType, account, reference). */ export declare const OPOS_META_INDEX_NAME = "skrType_1_accountNumber_1_reference_1"; /** Dunning metadata of one open item — process state, not bookkeeping. */ export declare class OposMeta extends plugins.nosqldb.SmartDataDbDoc { skrType: TSKRType; accountNumber: string; reference: string; dunningLevel?: number; dueDate?: string; updatedAt: Date; } /** The fields of a posted journal entry the open-item derivation reads. */ export interface IOposEntryLike { id: string; date: Date; reference?: string; lines: Array>; } export interface IControlTotals { debtorsCents: number; creditorsCents: number; debtorAccounts: number; creditorAccounts: number; } /** * Pick the personal-account lines out of posted journal documents. Pure — the * documents come from the caller. A line without its own Belegfeld 1 falls * back to the entry reference; both empty means the line belongs to the * unreferenced bucket of its account. */ export declare function extractPersonalLines(docs: IOposEntryLike[], policy: core.IAccountPolicy, accountNumber?: string): IOposLineRow[]; /** * Derive open items from the ledger and merge the dunning metadata onto them. */ export declare function listOpenItems(skrType: TSKRType, policy: core.IAccountPolicy, options?: { kind?: TOposKind; accountNumber?: string; asOf?: Date; includeSettled?: boolean; }): Promise; /** * Aging list relative to asOf, bucketed by days since dueDate (falling back * to the item's first posting date). */ export declare function getAging(skrType: TSKRType, policy: core.IAccountPolicy, kind: TOposKind, asOf: Date, bucketDays?: number[]): Promise; /** * Subledger control totals: the aggregated personal-account balances that a * balance sheet reports as Forderungen (B.II.1) / Verbindlichkeiten (C.4) * aus Lieferungen und Leistungen. Control accounts themselves are blocked for * posting, so these aggregates ARE the control balances. */ export declare function getControlTotals(skrType: TSKRType, policy: core.IAccountPolicy, asOf?: Date): Promise; /** * Dunning metadata (process state, not bookkeeping — letters are out of * scope; the level/due-date state machine is in). */ export declare function setOposMeta(params: { skrType: TSKRType; accountNumber: string; reference: string; dunningLevel?: number; dueDate?: string; }): Promise;