@classytic/ledger 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -348
- package/dist/bridges/index.d.mts +2 -0
- package/dist/bridges/index.mjs +1 -0
- package/dist/constants/index.d.mts +1 -1
- package/dist/constants/index.mjs +2 -2
- package/dist/country/index.d.mts +1 -1
- package/dist/errors-BI5k4iak.mjs +121 -0
- package/dist/events/index.d.mts +2 -0
- package/dist/events/index.mjs +2 -0
- package/dist/exports/index.d.mts +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/{fx-realization.plugin-DDVK-oYO.mjs → fx-realization.plugin-Bxlb8cIx.mjs} +2 -2
- package/dist/{index-RNZsX0Yo.d.mts → index-08IpHhrU.d.mts} +1 -1
- package/dist/{index-BSsvrf3m.d.mts → index-ClLwzNRF.d.mts} +3 -3
- package/dist/index-Dih0lM65.d.mts +169 -0
- package/dist/index.d.mts +233 -65
- package/dist/index.mjs +400 -99
- package/dist/{journals-Dd4A9TN3.d.mts → journals-DUpWwFt1.d.mts} +1 -1
- package/dist/outbox-store-DQbL-KYT.mjs +132 -0
- package/dist/outbox-store-UYC4eZpI.d.mts +249 -0
- package/dist/{partner-ledger-D9H5hegI.mjs → partner-ledger-BoebloHk.mjs} +2 -2
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/reports/index.d.mts +1 -1
- package/dist/reports/index.mjs +1 -1
- package/dist/sync/index.d.mts +1 -1
- package/dist/sync/index.mjs +1 -1
- package/dist/{sync-CnuVf441.d.mts → sync-JvchM3FO.d.mts} +1 -1
- package/dist/{trial-balance-DTj-c21f.d.mts → trial-balance-DyNm5bFu.d.mts} +2 -2
- package/package.json +27 -14
- package/dist/errors-CSDQPNyt.mjs +0 -33
- /package/dist/{categories-BkKdv16V.mjs → categories-FJlrvzcl.mjs} +0 -0
- /package/dist/{core-MpgjCqK0.d.mts → core-DwjkrRkJ.d.mts} +0 -0
- /package/dist/{currencies-CsuBGfgs.mjs → currencies-Jo5oaM_4.mjs} +0 -0
- /package/dist/{exports-B3whucXe.mjs → exports-C30yRapf.mjs} +0 -0
- /package/dist/{index-bCEeSzdO.d.mts → index-J-XIbXH-.d.mts} +0 -0
- /package/dist/{opening-balance-DPXmAIzN.mjs → opening-balance-1cixYh6Y.mjs} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as EntryReversedPayload, D as ReconciliationUnmatchedPayload, E as ReconciliationMatchedPayload, O as LEDGER_EVENTS, S as EntryPostedPayload, T as JournalSeededPayload, _ as AccountBulkCreatedPayload, a as OutboxOwnershipError, b as EntryCreatedPayload, c as InProcessLedgerBus, d as createEvent, f as DomainEvent, g as PublishManyResult, h as EventTransport, i as OutboxFailOptions, k as LedgerEventName, l as InProcessLedgerBusOptions, m as EventLogger, n as OutboxClaimOptions, o as OutboxStore, p as EventHandler, r as OutboxErrorInfo, s as OutboxWriteOptions, t as OutboxAcknowledgeOptions, u as EventContext, v as AccountSeededPayload, w as EntryUnpostedPayload, x as EntryDuplicatedPayload, y as EntryArchivedPayload } from "../outbox-store-UYC4eZpI.mjs";
|
|
2
|
+
export { type AccountBulkCreatedPayload, type AccountSeededPayload, type DomainEvent, type EntryArchivedPayload, type EntryCreatedPayload, type EntryDuplicatedPayload, type EntryPostedPayload, type EntryReversedPayload, type EntryUnpostedPayload, type EventContext, type EventHandler, type EventLogger, type EventTransport, InProcessLedgerBus, type InProcessLedgerBusOptions, type JournalSeededPayload, LEDGER_EVENTS, type LedgerEventName, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, type PublishManyResult, type ReconciliationMatchedPayload, type ReconciliationUnmatchedPayload, createEvent };
|
package/dist/exports/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as PopulatedJournalEntry, a as exportToCsv, c as getHeaders, d as serializeCsv, f as CsvOptions, g as PopulatedAccount, h as FlatJournalRow, i as quickbooksFieldMap, l as buildCsv, m as ExportFieldMap, n as flattenJournalEntry, o as extractAllRows, p as ExportField, r as universalFieldMap, s as extractRow, t as flattenJournalEntries, u as escapeCell, v as PopulatedJournalItem } from "../index-
|
|
1
|
+
import { _ as PopulatedJournalEntry, a as exportToCsv, c as getHeaders, d as serializeCsv, f as CsvOptions, g as PopulatedAccount, h as FlatJournalRow, i as quickbooksFieldMap, l as buildCsv, m as ExportFieldMap, n as flattenJournalEntry, o as extractAllRows, p as ExportField, r as universalFieldMap, s as extractRow, t as flattenJournalEntries, u as escapeCell, v as PopulatedJournalItem } from "../index-J-XIbXH-.mjs";
|
|
2
2
|
export { CsvOptions, ExportField, ExportFieldMap, FlatJournalRow, PopulatedAccount, PopulatedJournalEntry, PopulatedJournalItem, buildCsv, escapeCell, exportToCsv, extractAllRows, extractRow, flattenJournalEntries, flattenJournalEntry, getHeaders, quickbooksFieldMap, serializeCsv, universalFieldMap };
|
package/dist/exports/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as exportToCsv, c as getHeaders, d as serializeCsv, i as quickbooksFieldMap, l as buildCsv, n as flattenJournalEntry, o as extractAllRows, r as universalFieldMap, s as extractRow, t as flattenJournalEntries, u as escapeCell } from "../exports-
|
|
1
|
+
import { a as exportToCsv, c as getHeaders, d as serializeCsv, i as quickbooksFieldMap, l as buildCsv, n as flattenJournalEntry, o as extractAllRows, r as universalFieldMap, s as extractRow, t as flattenJournalEntries, u as escapeCell } from "../exports-C30yRapf.mjs";
|
|
2
2
|
export { buildCsv, escapeCell, exportToCsv, extractAllRows, extractRow, flattenJournalEntries, flattenJournalEntry, getHeaders, quickbooksFieldMap, serializeCsv, universalFieldMap };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as IdempotencyConflictError, i as Errors, t as AccountingError } from "./errors-BI5k4iak.mjs";
|
|
2
2
|
//#region src/plugins/double-entry.plugin.ts
|
|
3
3
|
function doubleEntryPlugin(options = {}) {
|
|
4
4
|
const { onlyOnPost = true, JournalEntryModel, AccountModel, orgField } = options;
|
|
@@ -166,7 +166,7 @@ function idempotencyPlugin(options) {
|
|
|
166
166
|
const query = { idempotencyKey: data.idempotencyKey };
|
|
167
167
|
if (orgField && data[orgField]) query[orgField] = data[orgField];
|
|
168
168
|
const existing = await JournalEntryModel.findOne(query).select("_id").session(context.session ?? null).lean();
|
|
169
|
-
if (existing) throw
|
|
169
|
+
if (existing) throw new IdempotencyConflictError(data.idempotencyKey, existing._id);
|
|
170
170
|
});
|
|
171
171
|
repo.on("before:createMany", async (context) => {
|
|
172
172
|
const docs = context.dataArray;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _classytic_mongokit0 from "@classytic/mongokit";
|
|
1
|
+
import * as _$_classytic_mongokit0 from "@classytic/mongokit";
|
|
2
2
|
import { Repository, RepositoryContext, RepositoryInstance } from "@classytic/mongokit";
|
|
3
3
|
import { ClientSession, Model } from "mongoose";
|
|
4
4
|
|
|
@@ -427,7 +427,7 @@ interface FiscalLockPluginOptions {
|
|
|
427
427
|
}
|
|
428
428
|
declare function fiscalLockPlugin(options: FiscalLockPluginOptions): {
|
|
429
429
|
name: string;
|
|
430
|
-
apply(repo: _classytic_mongokit0.RepositoryInstance): void;
|
|
430
|
+
apply(repo: _$_classytic_mongokit0.RepositoryInstance): void;
|
|
431
431
|
};
|
|
432
432
|
interface DailyLockPluginOptions {
|
|
433
433
|
/**
|
|
@@ -441,7 +441,7 @@ interface DailyLockPluginOptions {
|
|
|
441
441
|
}
|
|
442
442
|
declare function dailyLockPlugin(options: DailyLockPluginOptions): {
|
|
443
443
|
name: string;
|
|
444
|
-
apply(repo: _classytic_mongokit0.RepositoryInstance): void;
|
|
444
|
+
apply(repo: _$_classytic_mongokit0.RepositoryInstance): void;
|
|
445
445
|
};
|
|
446
446
|
//#endregion
|
|
447
447
|
//#region src/plugins/lock/watermark-resolver.d.ts
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//#region src/bridges/exchange-rate.bridge.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Exchange Rate Bridge — host-injected rate sourcing.
|
|
4
|
+
*
|
|
5
|
+
* The ledger never hardcodes where exchange rates come from. The host
|
|
6
|
+
* provides an implementation at engine init time:
|
|
7
|
+
*
|
|
8
|
+
* - ManualRateBridge: user-entered Currency Exchange records
|
|
9
|
+
* - BangladeshBankRateBridge: BB daily rate API
|
|
10
|
+
* - FixedRateBridge: hardcoded for testing
|
|
11
|
+
* - ProviderRateBridge: third-party rate API (Wise, Open Exchange Rates)
|
|
12
|
+
*
|
|
13
|
+
* When no bridge is provided, the caller must supply the exchange rate
|
|
14
|
+
* explicitly on every journal item (the existing behavior). The bridge
|
|
15
|
+
* is a convenience for hosts that want automatic rate lookup.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const engine = createAccountingEngine({
|
|
20
|
+
* country: bdPack,
|
|
21
|
+
* currency: 'BDT',
|
|
22
|
+
* multiCurrency: { enabled: true, currencies: ['USD', 'EUR'] },
|
|
23
|
+
* bridges: {
|
|
24
|
+
* exchangeRate: {
|
|
25
|
+
* async getRate(from, to, date) {
|
|
26
|
+
* const row = await CurrencyExchange.findOne({ from, to, date });
|
|
27
|
+
* if (!row) throw new Error(`No rate for ${from}→${to} on ${date}`);
|
|
28
|
+
* return row.rate;
|
|
29
|
+
* },
|
|
30
|
+
* },
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
interface ExchangeRateBridge {
|
|
36
|
+
/**
|
|
37
|
+
* Get the exchange rate for converting `fromCurrency` to `toCurrency`
|
|
38
|
+
* on a given date.
|
|
39
|
+
*
|
|
40
|
+
* @param fromCurrency ISO 4217 code (e.g., 'USD')
|
|
41
|
+
* @param toCurrency ISO 4217 code (e.g., 'BDT')
|
|
42
|
+
* @param date Transaction date (rate as of this date)
|
|
43
|
+
* @param purpose Optional: 'buying' or 'selling' rate (some central
|
|
44
|
+
* banks publish separate rates)
|
|
45
|
+
* @returns The rate as a positive decimal. Example: 120.50 means
|
|
46
|
+
* 1 USD = 120.50 BDT.
|
|
47
|
+
* @throws When no rate is available for the requested pair + date.
|
|
48
|
+
*/
|
|
49
|
+
getRate(fromCurrency: string, toCurrency: string, date: Date, purpose?: 'buying' | 'selling'): Promise<number>;
|
|
50
|
+
/**
|
|
51
|
+
* Optional batch lookup — avoids N+1 when posting multi-line entries
|
|
52
|
+
* with different currencies. Host implementations that cache rates
|
|
53
|
+
* benefit from a single DB round-trip.
|
|
54
|
+
*
|
|
55
|
+
* When absent, the engine falls back to calling `getRate()` per item.
|
|
56
|
+
*/
|
|
57
|
+
getRates?(requests: Array<{
|
|
58
|
+
fromCurrency: string;
|
|
59
|
+
toCurrency: string;
|
|
60
|
+
date: Date;
|
|
61
|
+
purpose?: 'buying' | 'selling';
|
|
62
|
+
}>): Promise<Map<string, number>>;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/bridges/notification.bridge.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* NotificationBridge — host-implemented delivery for ledger-originated alerts.
|
|
68
|
+
*
|
|
69
|
+
* The ledger generates operational alerts that hosts may want to route to
|
|
70
|
+
* email, Slack, in-app notifications, or an audit/compliance system:
|
|
71
|
+
*
|
|
72
|
+
* - `periodLocked` — a fiscal period was locked (audit sign-off)
|
|
73
|
+
* - `periodUnlocked` — a locked period was re-opened (requires elevated role)
|
|
74
|
+
* - `entryReversed` — a posted entry was reversed (accounting correction)
|
|
75
|
+
* - `reconciliationMismatch` — match debit/credit totals differ (FX gain/loss)
|
|
76
|
+
*
|
|
77
|
+
* This is deliberately thin — richer integrations should subscribe to the
|
|
78
|
+
* EventTransport (§11-14) and route via their own notification stack.
|
|
79
|
+
* NotificationBridge exists for hosts that want a direct callback without
|
|
80
|
+
* owning an event bus.
|
|
81
|
+
*
|
|
82
|
+
* All methods are optional. Skip the bridge entirely if the host uses events.
|
|
83
|
+
*/
|
|
84
|
+
interface NotificationBridgeContext {
|
|
85
|
+
organizationId?: unknown;
|
|
86
|
+
actorId?: unknown;
|
|
87
|
+
correlationId?: string;
|
|
88
|
+
}
|
|
89
|
+
interface PeriodLockedNotification {
|
|
90
|
+
periodId: unknown;
|
|
91
|
+
startDate: Date;
|
|
92
|
+
endDate: Date;
|
|
93
|
+
lockedBy?: unknown;
|
|
94
|
+
}
|
|
95
|
+
interface EntryReversedNotification {
|
|
96
|
+
originalEntryId: unknown;
|
|
97
|
+
reversalEntryId: unknown;
|
|
98
|
+
reversalDate: Date;
|
|
99
|
+
reversedBy?: unknown;
|
|
100
|
+
reason?: string;
|
|
101
|
+
}
|
|
102
|
+
interface ReconciliationMismatchNotification {
|
|
103
|
+
matchingNumber: string;
|
|
104
|
+
account: unknown;
|
|
105
|
+
debitTotal: number;
|
|
106
|
+
creditTotal: number;
|
|
107
|
+
difference: number;
|
|
108
|
+
currency: string | null;
|
|
109
|
+
}
|
|
110
|
+
interface NotificationBridge {
|
|
111
|
+
onPeriodLocked?(payload: PeriodLockedNotification, ctx: NotificationBridgeContext): Promise<void>;
|
|
112
|
+
onPeriodUnlocked?(payload: PeriodLockedNotification, ctx: NotificationBridgeContext): Promise<void>;
|
|
113
|
+
onEntryReversed?(payload: EntryReversedNotification, ctx: NotificationBridgeContext): Promise<void>;
|
|
114
|
+
onReconciliationMismatch?(payload: ReconciliationMismatchNotification, ctx: NotificationBridgeContext): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/bridges/source.bridge.d.ts
|
|
118
|
+
/**
|
|
119
|
+
* SourceBridge — host-implemented resolver for polymorphic external references.
|
|
120
|
+
*
|
|
121
|
+
* Ledger journal entries commonly carry a `reference`/`externalRef` pointing
|
|
122
|
+
* at a source document that lives outside the ledger package — an Invoice,
|
|
123
|
+
* Payment, Payroll Run, Stripe Charge, ERP voucher, etc. Storing these as
|
|
124
|
+
* opaque `String + sourceModel` (per PACKAGE_RULES §7) keeps the ledger
|
|
125
|
+
* transport-agnostic: the same schema works whether the source lives in the
|
|
126
|
+
* same Mongo, a different Mongo, Postgres, or an external REST API.
|
|
127
|
+
*
|
|
128
|
+
* Hosts implement `SourceBridge` to hydrate those refs when building
|
|
129
|
+
* enriched views (partner ledger with invoice details, audit trail with
|
|
130
|
+
* payment metadata, reconciliation UI with source documents, etc.).
|
|
131
|
+
*
|
|
132
|
+
* All methods are optional. Features that need resolution degrade gracefully
|
|
133
|
+
* when a bridge is not provided.
|
|
134
|
+
*/
|
|
135
|
+
interface SourceRef {
|
|
136
|
+
sourceId: string;
|
|
137
|
+
sourceModel: string;
|
|
138
|
+
}
|
|
139
|
+
interface SourceBridgeContext {
|
|
140
|
+
organizationId?: unknown;
|
|
141
|
+
actorId?: unknown;
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
}
|
|
144
|
+
interface SourceBridge {
|
|
145
|
+
/**
|
|
146
|
+
* Resolve a single external reference.
|
|
147
|
+
*
|
|
148
|
+
* Return `null` when the source cannot be found (deleted, permission
|
|
149
|
+
* denied, wrong model). Do not throw for missing sources — callers
|
|
150
|
+
* expect `null` for graceful degradation.
|
|
151
|
+
*/
|
|
152
|
+
resolve?(sourceId: string, sourceModel: string, ctx: SourceBridgeContext): Promise<unknown | null>;
|
|
153
|
+
/**
|
|
154
|
+
* Batch resolver — avoids N+1 round-trips when enriching a list.
|
|
155
|
+
* Key the returned map by `sourceId`. Missing sources may be omitted or
|
|
156
|
+
* mapped to `null` at the implementer's discretion.
|
|
157
|
+
*/
|
|
158
|
+
resolveMany?(refs: ReadonlyArray<SourceRef>, ctx: SourceBridgeContext): Promise<Map<string, unknown>>;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/bridges/index.d.ts
|
|
162
|
+
/** Collected bridges exposed as `engine.bridges`. All optional per PACKAGE_RULES §23. */
|
|
163
|
+
interface LedgerBridges {
|
|
164
|
+
source?: SourceBridge;
|
|
165
|
+
notification?: NotificationBridge;
|
|
166
|
+
exchangeRate?: ExchangeRateBridge;
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
export { EntryReversedNotification as a, PeriodLockedNotification as c, SourceRef as i, ReconciliationMismatchNotification as l, SourceBridge as n, NotificationBridge as o, SourceBridgeContext as r, NotificationBridgeContext as s, LedgerBridges as t, ExchangeRateBridge as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { i as
|
|
4
|
-
import {
|
|
1
|
+
import { a as EntryReversedNotification, c as PeriodLockedNotification, i as SourceRef, l as ReconciliationMismatchNotification, n as SourceBridge, o as NotificationBridge, r as SourceBridgeContext, s as NotificationBridgeContext, t as LedgerBridges, u as ExchangeRateBridge } from "./index-Dih0lM65.mjs";
|
|
2
|
+
import { _ as TaxMetadata, a as Cents, c as DateRange, d as JournalType, f as MainType, g as TaxDetail, h as StatementType, i as CategoryKey, l as EntryState, m as ObjectId, n as CashFlowCategory, o as Currency, p as NormalBalance, s as DateOption, t as AccountType, u as JournalItem, v as TotalAccountOp } from "./core-DwjkrRkJ.mjs";
|
|
3
|
+
import { S as isValidCategory, a as getJournalTypeCodes, b as isBalanceSheet, c as CURRENCIES, d as isValidCurrency, f as CATEGORIES, i as getJournalType, l as getCurrency, n as JOURNAL_TYPES, o as isValidJournalType, p as CATEGORY_KEYS, r as getCustomJournalTypes, s as registerJournalType, t as JOURNAL_CODES, u as getMinorUnit, x as isIncomeStatement, y as getNormalBalance } from "./journals-DUpWwFt1.mjs";
|
|
4
|
+
import { i as defineCountryPack, n as CountryPackInput, r as JournalTemplate, t as CountryPack } from "./index-08IpHhrU.mjs";
|
|
5
|
+
import { C as EntryReversedPayload, D as ReconciliationUnmatchedPayload, E as ReconciliationMatchedPayload, O as LEDGER_EVENTS, S as EntryPostedPayload, T as JournalSeededPayload, _ as AccountBulkCreatedPayload, a as OutboxOwnershipError, b as EntryCreatedPayload, c as InProcessLedgerBus, d as createEvent, f as DomainEvent, g as PublishManyResult, h as EventTransport, i as OutboxFailOptions, k as LedgerEventName, l as InProcessLedgerBusOptions, m as EventLogger, n as OutboxClaimOptions, o as OutboxStore, p as EventHandler, r as OutboxErrorInfo, s as OutboxWriteOptions, t as OutboxAcknowledgeOptions, u as EventContext, v as AccountSeededPayload, w as EntryUnpostedPayload, x as EntryDuplicatedPayload, y as EntryArchivedPayload } from "./outbox-store-UYC4eZpI.mjs";
|
|
6
|
+
import { _ as PopulatedJournalEntry, a as exportToCsv, h as FlatJournalRow, i as quickbooksFieldMap, m as ExportFieldMap, p as ExportField, r as universalFieldMap, t as flattenJournalEntries } from "./index-J-XIbXH-.mjs";
|
|
5
7
|
import { Money, abs, add, allocate, equals, format, formatPlain, fromDecimal, isNegative, isPositive, isValid, isZero, max, min, multiply, negate, parseCents, percentage, round, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal } from "./money.mjs";
|
|
6
|
-
import { $ as AgedBalanceParams, A as generateDimensionBreakdown, B as BalanceSheetReport, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as IncomeStatementReport, H as CashFlowSection, I as BudgetVsActualRow, J as ReportCategory, K as LedgerEntry, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, Q as AgedBalanceOptions, T as reopenFiscalPeriod, U as GeneralLedgerAccount, V as CashFlowReport, W as GeneralLedgerReport, X as TrialBalanceReport, Y as ReportGroup, Z as TrialBalanceRow, a as RevaluationReport, at as Logger, b as generateGeneralLedger, c as RevaluationRate, d as computeRevaluation, et as AgedBalanceReport, f as PartnerLedgerLine, g as generatePartnerLedger, h as PartnerLedgerReport, i as RevaluationParams, it as generateAgedBalance, k as DimensionBreakdownRow, l as RevaluationResult, m as PartnerLedgerParams, n as generateTrialBalance, nt as AgedBucketConfig, o as generateRevaluation, ot as defaultLogger, p as PartnerLedgerOptions, q as ReportAccount, r as RevaluationOptions, rt as DEFAULT_BUCKETS, s as AccountForeignBalance, tt as AgedBalanceRow, u as buildRevaluationEntry, v as generateIncomeStatement, w as closeFiscalPeriod, z as generateBalanceSheet } from "./trial-balance-
|
|
7
|
-
import { A as OpenItem, C as AccountRepository, D as JournalItemRef, E as JournalEntryRepository, F as SeedOptions, I as SeedResult, M as ReconciliationRepository, N as ReverseOptions, O as JournalRepository, P as ReverseResult, S as creditLimitPlugin, T as BulkCreateResult, _ as FxRealizationPluginOptions, a as dailyLockPlugin, b as doubleEntryPlugin, c as periodResolver, d as LockAccountSelector, f as LockHit, g as idempotencyPlugin, i as FiscalLockPluginOptions, j as PostOptions, k as MatchInput, l as createLockPlugin, m as LockResolverContext, n as watermarkResolver, o as fiscalLockPlugin, p as LockResolver, r as DailyLockPluginOptions, s as PeriodResolverOptions, t as WatermarkResolverOptions, u as CreateLockPluginOptions, v as fxRealizationPlugin, w as BulkCreateInput, x as CreditLimitPluginOptions } from "./index-
|
|
8
|
-
import { PaginationConfig, PluginType, QueryParser, QueryParserOptions, Repository } from "@classytic/mongokit";
|
|
8
|
+
import { $ as AgedBalanceParams, A as generateDimensionBreakdown, B as BalanceSheetReport, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as IncomeStatementReport, H as CashFlowSection, I as BudgetVsActualRow, J as ReportCategory, K as LedgerEntry, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, Q as AgedBalanceOptions, T as reopenFiscalPeriod, U as GeneralLedgerAccount, V as CashFlowReport, W as GeneralLedgerReport, X as TrialBalanceReport, Y as ReportGroup, Z as TrialBalanceRow, a as RevaluationReport, at as Logger, b as generateGeneralLedger, c as RevaluationRate, d as computeRevaluation, et as AgedBalanceReport, f as PartnerLedgerLine, g as generatePartnerLedger, h as PartnerLedgerReport, i as RevaluationParams, it as generateAgedBalance, k as DimensionBreakdownRow, l as RevaluationResult, m as PartnerLedgerParams, n as generateTrialBalance, nt as AgedBucketConfig, o as generateRevaluation, ot as defaultLogger, p as PartnerLedgerOptions, q as ReportAccount, r as RevaluationOptions, rt as DEFAULT_BUCKETS, s as AccountForeignBalance, tt as AgedBalanceRow, u as buildRevaluationEntry, v as generateIncomeStatement, w as closeFiscalPeriod, z as generateBalanceSheet } from "./trial-balance-DyNm5bFu.mjs";
|
|
9
|
+
import { A as OpenItem, C as AccountRepository, D as JournalItemRef, E as JournalEntryRepository, F as SeedOptions, I as SeedResult, M as ReconciliationRepository, N as ReverseOptions, O as JournalRepository, P as ReverseResult, S as creditLimitPlugin, T as BulkCreateResult, _ as FxRealizationPluginOptions, a as dailyLockPlugin, b as doubleEntryPlugin, c as periodResolver, d as LockAccountSelector, f as LockHit, g as idempotencyPlugin, i as FiscalLockPluginOptions, j as PostOptions, k as MatchInput, l as createLockPlugin, m as LockResolverContext, n as watermarkResolver, o as fiscalLockPlugin, p as LockResolver, r as DailyLockPluginOptions, s as PeriodResolverOptions, t as WatermarkResolverOptions, u as CreateLockPluginOptions, v as fxRealizationPlugin, w as BulkCreateInput, x as CreditLimitPluginOptions } from "./index-ClLwzNRF.mjs";
|
|
10
|
+
import { PaginationConfig, PluginFunction, PluginType, QueryParser, QueryParserOptions, Repository } from "@classytic/mongokit";
|
|
9
11
|
import { ClientSession, Connection, Model } from "mongoose";
|
|
10
12
|
|
|
13
|
+
//#region src/plugins/immutable-guard.plugin.d.ts
|
|
14
|
+
interface ImmutableGuardOptions {
|
|
15
|
+
/** The JournalEntry Mongoose model, for looking up current state on update. */
|
|
16
|
+
JournalEntryModel: Model<unknown>;
|
|
17
|
+
/** Multi-tenant org field name (if enabled). */
|
|
18
|
+
orgField?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a mongokit plugin function. Install only when
|
|
22
|
+
* `config.strictness.immutable === true`.
|
|
23
|
+
*/
|
|
24
|
+
declare function immutableGuardPlugin(options: ImmutableGuardOptions): PluginFunction;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/utils/errors.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* Typed error for the accounting package.
|
|
29
|
+
* Carries HTTP status + machine-readable code + structured field errors.
|
|
30
|
+
*
|
|
31
|
+
* The `fields` array lets AI agents and API clients pinpoint exactly
|
|
32
|
+
* what failed in a multi-field validation:
|
|
33
|
+
*
|
|
34
|
+
* throw Errors.validationWithFields('Journal entry invalid', [
|
|
35
|
+
* { path: 'journalItems.2.account', issue: 'account does not exist', value: '...' },
|
|
36
|
+
* { path: 'journalItems', issue: 'debits must equal credits', value: { debit: 500, credit: 450 } },
|
|
37
|
+
* ]);
|
|
38
|
+
*/
|
|
39
|
+
/** A single field-level validation error. */
|
|
40
|
+
interface FieldError {
|
|
41
|
+
/** Dot-notation path to the invalid field (e.g. `journalItems.2.account`) */
|
|
42
|
+
readonly path: string;
|
|
43
|
+
/** Human-readable description of what's wrong */
|
|
44
|
+
readonly issue: string;
|
|
45
|
+
/** The offending value (optional — omit for sensitive data) */
|
|
46
|
+
readonly value?: unknown;
|
|
47
|
+
}
|
|
48
|
+
declare class AccountingError extends Error {
|
|
49
|
+
readonly status: number;
|
|
50
|
+
readonly code: string;
|
|
51
|
+
readonly fields?: ReadonlyArray<FieldError>;
|
|
52
|
+
constructor(message: string, status?: number, code?: string, fields?: ReadonlyArray<FieldError>);
|
|
53
|
+
/** Serialize to a plain object for API responses and logs. */
|
|
54
|
+
toJSON(): {
|
|
55
|
+
name: string;
|
|
56
|
+
message: string;
|
|
57
|
+
status: number;
|
|
58
|
+
code: string;
|
|
59
|
+
fields?: ReadonlyArray<FieldError>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface ErrorsFactories {
|
|
63
|
+
validation: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
64
|
+
notFound: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
65
|
+
conflict: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
66
|
+
immutable: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
67
|
+
locked: (scope: string, msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
68
|
+
}
|
|
69
|
+
declare const Errors: ErrorsFactories;
|
|
70
|
+
/**
|
|
71
|
+
* Thrown when an idempotent create was attempted with a key that already
|
|
72
|
+
* resolved to a different winner (not the common "same winner, same payload"
|
|
73
|
+
* replay — that returns the existing doc without throwing).
|
|
74
|
+
*
|
|
75
|
+
* Typically surfaces when the host supplies an `idempotencyKey` that collides
|
|
76
|
+
* with a logically-different prior write.
|
|
77
|
+
*/
|
|
78
|
+
declare class IdempotencyConflictError extends AccountingError {
|
|
79
|
+
readonly idempotencyKey: string;
|
|
80
|
+
readonly existingId: unknown;
|
|
81
|
+
constructor(idempotencyKey: string, existingId: unknown, message?: string);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Thrown when the unique `referenceNumber` index fires. With the new atomic
|
|
85
|
+
* counter this should be effectively impossible — if it ever throws, it
|
|
86
|
+
* indicates either a pre-atomic-counter doc that was hand-inserted OR a bug
|
|
87
|
+
* in the counter partitioning.
|
|
88
|
+
*/
|
|
89
|
+
declare class DuplicateReferenceError extends AccountingError {
|
|
90
|
+
readonly referenceNumber: string;
|
|
91
|
+
constructor(referenceNumber: string, message?: string);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Thrown when an optimistic-concurrency FSM transition fails because another
|
|
95
|
+
* writer advanced the state or version between our read and our write.
|
|
96
|
+
*
|
|
97
|
+
* Callers should re-fetch the doc and decide whether to retry or surface.
|
|
98
|
+
*/
|
|
99
|
+
declare class ConcurrencyError extends AccountingError {
|
|
100
|
+
readonly resource: string;
|
|
101
|
+
readonly resourceId: unknown;
|
|
102
|
+
constructor(resource: string, resourceId: unknown, message?: string);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Thrown when a mutation targets an entry that is protected by immutability —
|
|
106
|
+
* either `strictness.immutable` or the double-entry plugin's posted-entry
|
|
107
|
+
* guard. Factory `Errors.immutable(msg)` returns this subclass so callers
|
|
108
|
+
* can `instanceof`-match without sniffing the `code` field.
|
|
109
|
+
*/
|
|
110
|
+
declare class ImmutableViolationError extends AccountingError {
|
|
111
|
+
readonly entryId: unknown;
|
|
112
|
+
constructor(entryId: unknown, message?: string, fields?: ReadonlyArray<FieldError>);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Detect a Mongo duplicate-key error (11000) and return the index name the
|
|
116
|
+
* conflict hit on, so callers can switch on which unique key fired.
|
|
117
|
+
*
|
|
118
|
+
* Handles both driver-style and mongoose-style error shapes. Safe to call
|
|
119
|
+
* with any `unknown` — returns `null` when the error is not a dup-key.
|
|
120
|
+
*/
|
|
121
|
+
declare function classifyDuplicateKey(err: unknown): {
|
|
122
|
+
indexName: string;
|
|
123
|
+
keyPattern?: Record<string, unknown>;
|
|
124
|
+
} | null;
|
|
125
|
+
//#endregion
|
|
11
126
|
//#region src/types/engine.d.ts
|
|
12
127
|
/** Mongokit plugins to install per repository (composes with engine built-ins). */
|
|
13
128
|
interface LedgerRepositoryPlugins {
|
|
@@ -33,6 +148,22 @@ interface MultiTenantConfig {
|
|
|
33
148
|
orgField: string;
|
|
34
149
|
/** Mongoose model name the org field references (e.g., 'Business', 'Organization') */
|
|
35
150
|
orgRef: string;
|
|
151
|
+
/**
|
|
152
|
+
* Enable mongokit's `multiTenantPlugin` on every ledger repository. The plugin
|
|
153
|
+
* injects the tenant filter at POLICY priority (before cache/audit) whenever
|
|
154
|
+
* `ctx.organizationId` is present on a call. When `false` (default), only
|
|
155
|
+
* manual `orgField` filters inside domain verbs enforce scoping.
|
|
156
|
+
*
|
|
157
|
+
* Recommended: `true` for new hosts. Keep `false` if your app has not yet
|
|
158
|
+
* migrated to context-based scoping.
|
|
159
|
+
*/
|
|
160
|
+
plugin?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Fail closed when `ctx.organizationId` is missing on a plugin-scoped call.
|
|
163
|
+
* Only applies when `plugin: true`. Default: `false` (skip injection when
|
|
164
|
+
* context is empty — matches historical ledger behavior).
|
|
165
|
+
*/
|
|
166
|
+
required?: boolean;
|
|
36
167
|
}
|
|
37
168
|
/** Options passed to schema factory functions */
|
|
38
169
|
interface SchemaOptions {
|
|
@@ -148,12 +279,70 @@ interface AccountingEngineConfig {
|
|
|
148
279
|
audit?: AuditConfig;
|
|
149
280
|
/** Enable built-in idempotency key field on journal entries */
|
|
150
281
|
idempotency?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* TTL in seconds for idempotency records — stale replay keys auto-expire
|
|
284
|
+
* via a partial TTL index so they don't collide with legitimate reuse
|
|
285
|
+
* after the window closes. Default: 86400 (24h). Matches Stripe / Saleor
|
|
286
|
+
* convention. Only applies when `idempotency: true`.
|
|
287
|
+
*/
|
|
288
|
+
idempotencyTtlSeconds?: number;
|
|
289
|
+
/**
|
|
290
|
+
* Automatically call `Model.syncIndexes()` on every managed model right
|
|
291
|
+
* after the engine boots. Ensures new partial/TTL indexes (0.9.0+) are
|
|
292
|
+
* present in MongoDB before the first write. Default: `false` — hosts
|
|
293
|
+
* that run migrations themselves should leave this off.
|
|
294
|
+
*/
|
|
295
|
+
syncIndexes?: boolean;
|
|
151
296
|
/** Strictness rules for the ledger */
|
|
152
297
|
strictness?: StrictnessConfig;
|
|
153
298
|
/** Mongokit plugins to install per repository. */
|
|
154
299
|
plugins?: LedgerRepositoryPlugins;
|
|
155
300
|
/** Pagination caps per repository. */
|
|
156
301
|
pagination?: LedgerPaginationConfig;
|
|
302
|
+
/**
|
|
303
|
+
* Mongoose type for the multi-tenant field on all ledger schemas.
|
|
304
|
+
*
|
|
305
|
+
* - `'string'` (default, back-compat): stores tenant IDs as strings.
|
|
306
|
+
* Accepts any external auth system (UUIDs, slugs, external identifiers).
|
|
307
|
+
* - `'objectId'`: stores tenant IDs as native MongoDB ObjectId with a
|
|
308
|
+
* Mongoose ref to the organization collection. Enables `$lookup` and
|
|
309
|
+
* `.populate()` against Better Auth's `organization` collection.
|
|
310
|
+
*
|
|
311
|
+
* New hosts wiring Better Auth should pass `'objectId'`. See
|
|
312
|
+
* PACKAGE_RULES §9.1 and §9.2.
|
|
313
|
+
*
|
|
314
|
+
* Note: this field is plumbed into `multiTenantPlugin` when
|
|
315
|
+
* `multiTenant.plugin: true`. Schema-level type switching is applied
|
|
316
|
+
* by the models factory when it supports dynamic type declaration.
|
|
317
|
+
*/
|
|
318
|
+
tenantFieldType?: 'objectId' | 'string';
|
|
319
|
+
/**
|
|
320
|
+
* Optional event transport — structurally identical to `@classytic/arc`'s
|
|
321
|
+
* `EventTransport`. Drop in any arc transport (Memory, Redis, Kafka, BullMQ)
|
|
322
|
+
* or provide a custom one. When omitted, the engine uses an in-process bus
|
|
323
|
+
* (`InProcessLedgerBus`) that is NOT suitable for multi-instance deployments.
|
|
324
|
+
*/
|
|
325
|
+
eventTransport?: EventTransport;
|
|
326
|
+
/**
|
|
327
|
+
* Optional host-owned outbox store — structurally identical to
|
|
328
|
+
* `@classytic/arc`'s `OutboxStore`. When provided, domain events are
|
|
329
|
+
* persisted via `outbox.save(event, { session })` inside the same
|
|
330
|
+
* mongoose session as the ledger write, giving at-least-once delivery
|
|
331
|
+
* guarantees. A host-side relay worker calls `store.claimPending` +
|
|
332
|
+
* `transport.publish` + `store.acknowledge` independently.
|
|
333
|
+
*
|
|
334
|
+
* Package-owned durable outbox storage is an anti-pattern per
|
|
335
|
+
* PACKAGE_RULES §5.5. Ledger does NOT ship a concrete store — the
|
|
336
|
+
* host picks `MongoOutboxStore` (arc), a SQL store, a Redis store,
|
|
337
|
+
* etc. See `src/events/outbox-store.ts` for the interface contract.
|
|
338
|
+
*/
|
|
339
|
+
outboxStore?: OutboxStore;
|
|
340
|
+
/**
|
|
341
|
+
* Host-provided bridges for external integrations (source resolution,
|
|
342
|
+
* notifications). All bridges and all methods are optional — features
|
|
343
|
+
* degrade gracefully when a bridge is missing.
|
|
344
|
+
*/
|
|
345
|
+
bridges?: LedgerBridges;
|
|
157
346
|
}
|
|
158
347
|
//#endregion
|
|
159
348
|
//#region src/models/factory.d.ts
|
|
@@ -185,16 +374,20 @@ interface LedgerRepositories {
|
|
|
185
374
|
reconciliations: ReconciliationRepository<unknown>;
|
|
186
375
|
journals: JournalRepository<unknown>;
|
|
187
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Extra wiring context passed into wireXxxMethods so domain verbs can emit
|
|
379
|
+
* events and reach out through host-provided bridges. Always optional so
|
|
380
|
+
* consumers without events/bridges see no behavioral change.
|
|
381
|
+
*/
|
|
382
|
+
interface LedgerRepositoryIntegrations {
|
|
383
|
+
events?: EventTransport;
|
|
384
|
+
bridges?: LedgerBridges;
|
|
385
|
+
outboxStore?: OutboxStore;
|
|
386
|
+
}
|
|
188
387
|
/**
|
|
189
388
|
* Build all ledger repositories with plugins + domain methods pre-wired.
|
|
190
|
-
*
|
|
191
|
-
* - `accounts` — has seedAccounts(), bulkCreate()
|
|
192
|
-
* - `journalEntries` — has post(), unpost(), reverse(), duplicate() + double-entry + fiscal-lock (+ idempotency if enabled)
|
|
193
|
-
* - `fiscalPeriods` — plain CRUD
|
|
194
|
-
* - `budgets` — plain CRUD
|
|
195
|
-
* - `reconciliations` — has reconcile(), unreconcile(), getUnreconciled()
|
|
196
389
|
*/
|
|
197
|
-
declare function createRepositories(models: LedgerModels, config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins, pagination?: LedgerPaginationConfig): LedgerRepositories;
|
|
390
|
+
declare function createRepositories(models: LedgerModels, config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins, pagination?: LedgerPaginationConfig, integrations?: LedgerRepositoryIntegrations): LedgerRepositories;
|
|
198
391
|
//#endregion
|
|
199
392
|
//#region src/semantic/introspect.d.ts
|
|
200
393
|
interface AccountSummary {
|
|
@@ -500,8 +693,33 @@ declare class AccountingEngine {
|
|
|
500
693
|
readonly repositories: LedgerRepositories;
|
|
501
694
|
readonly record: RecordAPI;
|
|
502
695
|
readonly introspect: IntrospectAPI;
|
|
696
|
+
/**
|
|
697
|
+
* Event transport — structurally matches `@classytic/arc`'s `EventTransport`.
|
|
698
|
+
* When the host does not inject one, the engine instantiates
|
|
699
|
+
* `InProcessLedgerBus` (suitable for single-instance deployments only).
|
|
700
|
+
* Subscribe with glob patterns: `ledger:entry.*`, `ledger:reconciliation.*`, `*`.
|
|
701
|
+
*/
|
|
702
|
+
readonly events: EventTransport;
|
|
703
|
+
/**
|
|
704
|
+
* Host-provided bridges. Empty object when none supplied. Callers should
|
|
705
|
+
* optional-chain every method (`engine.bridges.source?.resolve?.(...)`).
|
|
706
|
+
*/
|
|
707
|
+
readonly bridges: LedgerBridges;
|
|
708
|
+
/**
|
|
709
|
+
* Host-provided outbox store for durable event delivery (0.9.0). When
|
|
710
|
+
* present, every domain event is persisted to the outbox in the same
|
|
711
|
+
* mongoose session as the ledger write before the transport publish.
|
|
712
|
+
* Undefined when the host opts out of durable delivery.
|
|
713
|
+
*/
|
|
714
|
+
readonly outboxStore: OutboxStore | undefined;
|
|
503
715
|
private _reports?;
|
|
504
716
|
constructor(config: AccountingEngineConfig);
|
|
717
|
+
/**
|
|
718
|
+
* Explicitly sync indexes on all managed models.
|
|
719
|
+
* Call this in deploy-time scripts — NOT on every boot.
|
|
720
|
+
* See PACKAGE_RULES section 32.
|
|
721
|
+
*/
|
|
722
|
+
syncIndexes(): Promise<void>;
|
|
505
723
|
/**
|
|
506
724
|
* Pre-built reports bound to the engine's owned models.
|
|
507
725
|
* Lazy-initialized on first access.
|
|
@@ -752,56 +970,6 @@ declare function buildDimensionIndexes(dimensions: DimensionDefinition[], orgFie
|
|
|
752
970
|
options?: Record<string, unknown>;
|
|
753
971
|
}>;
|
|
754
972
|
//#endregion
|
|
755
|
-
//#region src/utils/errors.d.ts
|
|
756
|
-
/**
|
|
757
|
-
* Typed error for the accounting package.
|
|
758
|
-
* Carries HTTP status + machine-readable code + structured field errors.
|
|
759
|
-
*
|
|
760
|
-
* The `fields` array lets AI agents and API clients pinpoint exactly
|
|
761
|
-
* what failed in a multi-field validation:
|
|
762
|
-
*
|
|
763
|
-
* throw Errors.validationWithFields('Journal entry invalid', [
|
|
764
|
-
* { path: 'journalItems.2.account', issue: 'account does not exist', value: '...' },
|
|
765
|
-
* { path: 'journalItems', issue: 'debits must equal credits', value: { debit: 500, credit: 450 } },
|
|
766
|
-
* ]);
|
|
767
|
-
*/
|
|
768
|
-
/** A single field-level validation error. */
|
|
769
|
-
interface FieldError {
|
|
770
|
-
/** Dot-notation path to the invalid field (e.g. `journalItems.2.account`) */
|
|
771
|
-
readonly path: string;
|
|
772
|
-
/** Human-readable description of what's wrong */
|
|
773
|
-
readonly issue: string;
|
|
774
|
-
/** The offending value (optional — omit for sensitive data) */
|
|
775
|
-
readonly value?: unknown;
|
|
776
|
-
}
|
|
777
|
-
declare class AccountingError extends Error {
|
|
778
|
-
readonly status: number;
|
|
779
|
-
readonly code: string;
|
|
780
|
-
readonly fields?: ReadonlyArray<FieldError>;
|
|
781
|
-
constructor(message: string, status?: number, code?: string, fields?: ReadonlyArray<FieldError>);
|
|
782
|
-
/** Serialize to a plain object for API responses and logs. */
|
|
783
|
-
toJSON(): {
|
|
784
|
-
name: string;
|
|
785
|
-
message: string;
|
|
786
|
-
status: number;
|
|
787
|
-
code: string;
|
|
788
|
-
fields?: ReadonlyArray<FieldError>;
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
/** Convenience factory functions. */
|
|
792
|
-
declare const Errors: {
|
|
793
|
-
readonly validation: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
794
|
-
readonly notFound: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
795
|
-
readonly conflict: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
796
|
-
readonly immutable: (msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
797
|
-
/**
|
|
798
|
-
* Period/scope lock violation. Replaces the old `fiscal` factory — use the
|
|
799
|
-
* `scope` argument to distinguish fiscal / tax / daily / bank / etc. The
|
|
800
|
-
* resulting error code is `PERIOD_LOCKED_{SCOPE}` (e.g. `PERIOD_LOCKED_FISCAL`).
|
|
801
|
-
*/
|
|
802
|
-
readonly locked: (scope: string, msg: string, fields?: ReadonlyArray<FieldError>) => AccountingError;
|
|
803
|
-
};
|
|
804
|
-
//#endregion
|
|
805
973
|
//#region src/utils/filter-builder.d.ts
|
|
806
974
|
/**
|
|
807
975
|
* Filter Builder — Sanitizes user-supplied dimension filters for aggregation pipelines.
|
|
@@ -881,4 +1049,4 @@ interface PostingResult {
|
|
|
881
1049
|
idempotencyKeys?: string[];
|
|
882
1050
|
}
|
|
883
1051
|
//#endregion
|
|
884
|
-
export { type AccountCode, type AccountForeignBalance, type AccountRepository, type AccountSummary, type AccountType, AccountingEngine, type AccountingEngineConfig, AccountingError, type ActorContext, type AgedBalanceOptions, type AgedBalanceParams, type AgedBalanceReport, type AgedBalanceRow, type AgedBucketConfig, type AuditConfig, type BalanceSheetReport, type BudgetVsActualOptions, type BudgetVsActualParams, type BudgetVsActualReport, type BudgetVsActualRow, type BulkCreateInput, type BulkCreateResult, CATEGORIES, CATEGORY_KEYS, CURRENCIES, type CashFlowCategory, type CashFlowReport, type CashFlowSection, type CategoryKey, type Cents, type CountryPack, type CountryPackInput, type CreateLockPluginOptions, type CreditLimitPluginOptions, type Currency, DEFAULT_BUCKETS, type DailyLockPluginOptions, type DateOption, type DateRange, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type DimensionDefinition, type EntryState, Errors, type ExportField, type ExportFieldMap, type FieldError, type FiscalLockPluginOptions, type FiscalPeriodSummary, type FlatJournalRow, type FxRealizationPluginOptions, type GeneralLedgerAccount, type GeneralLedgerReport, type IncomeStatementReport, type IntrospectAPI, JOURNAL_CODES, JOURNAL_TYPES, type JournalEntryRepository, type JournalItem, type JournalItemRef, type JournalRepository, type JournalSchemaOptions, type JournalTemplate, type JournalType, type LedgerEntry, type LedgerModels, type LedgerPaginationConfig, type LedgerRepositories, type LedgerRepositoryPlugins, type LockAccountSelector, type LockHit, type LockResolver, type LockResolverContext, type Logger, type MainType, type MatchHookContext, type MatchHookItem, type MatchInput, type ModelNames, Money, type MultiCurrencyConfig, type MultiTenantConfig, type NormalBalance, type OpenItem, type PartnerLedgerLine, type PartnerLedgerOptions, type PartnerLedgerParams, type PartnerLedgerReport, type PeriodResolverOptions, type PopulatedJournalEntry, type PostOptions, type PostingContract, type PostingResult, type ReconciliationRepository, type RecordAPI, type RecordAdjustmentInput, type RecordAdjustmentLine, type RecordExpenseInput, type RecordOptions, type RecordPaymentInput, type RecordSaleInput, type RecordTransferInput, type ReportAccount, type ReportCategory, type ReportDescriptor, type ReportGroup, type ResolvedModelNames, type RevaluationOptions, type RevaluationParams, type RevaluationRate, type RevaluationReport, type RevaluationResult, type ReverseOptions, type ReverseResult, type SchemaOptions, type SeedOptions, type SeedResult, type Cents$1 as SemanticCents, type SessionResult, type StatementType, type StrictnessConfig, type SubledgerJournalItem, type SubledgerPostingInput, type TaxDetail, type TaxMetadata, type TotalAccountOp, type TrialBalanceReport, type TrialBalanceRow, type UnmatchHookContext, type WatermarkResolverOptions, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountingEngine, createLockPlugin, createModels, createRepositories, creditLimitPlugin, dailyLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, fxRealizationPlugin, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generatePartnerLedger, generateRevaluation, generateTrialBalance, getCurrency, getCustomJournalTypes, getDateRange, getFiscalYearStart, getJournalType, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, periodResolver, quickbooksFieldMap, registerJournalType, reopenFiscalPeriod, resolveModelNames, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, watermarkResolver };
|
|
1052
|
+
export { type AccountBulkCreatedPayload, type AccountCode, type AccountForeignBalance, type AccountRepository, type AccountSeededPayload, type AccountSummary, type AccountType, AccountingEngine, type AccountingEngineConfig, AccountingError, type ActorContext, type AgedBalanceOptions, type AgedBalanceParams, type AgedBalanceReport, type AgedBalanceRow, type AgedBucketConfig, type AuditConfig, type BalanceSheetReport, type BudgetVsActualOptions, type BudgetVsActualParams, type BudgetVsActualReport, type BudgetVsActualRow, type BulkCreateInput, type BulkCreateResult, CATEGORIES, CATEGORY_KEYS, CURRENCIES, type CashFlowCategory, type CashFlowReport, type CashFlowSection, type CategoryKey, type Cents, ConcurrencyError, type CountryPack, type CountryPackInput, type CreateLockPluginOptions, type CreditLimitPluginOptions, type Currency, DEFAULT_BUCKETS, type DailyLockPluginOptions, type DateOption, type DateRange, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type DimensionDefinition, type DomainEvent, DuplicateReferenceError, type EntryArchivedPayload, type EntryCreatedPayload, type EntryDuplicatedPayload, type EntryPostedPayload, type EntryReversedNotification, type EntryReversedPayload, type EntryState, type EntryUnpostedPayload, Errors, type EventContext, type EventHandler, type EventLogger, type EventTransport, type ExchangeRateBridge, type ExportField, type ExportFieldMap, type FieldError, type FiscalLockPluginOptions, type FiscalPeriodSummary, type FlatJournalRow, type FxRealizationPluginOptions, type GeneralLedgerAccount, type GeneralLedgerReport, IdempotencyConflictError, type ImmutableGuardOptions, ImmutableViolationError, InProcessLedgerBus, type InProcessLedgerBusOptions, type IncomeStatementReport, type IntrospectAPI, JOURNAL_CODES, JOURNAL_TYPES, type JournalEntryRepository, type JournalItem, type JournalItemRef, type JournalRepository, type JournalSchemaOptions, type JournalSeededPayload, type JournalTemplate, type JournalType, LEDGER_EVENTS, type LedgerBridges, type LedgerEntry, type LedgerEventName, type LedgerModels, type LedgerPaginationConfig, type LedgerRepositories, type LedgerRepositoryPlugins, type LockAccountSelector, type LockHit, type LockResolver, type LockResolverContext, type Logger, type MainType, type MatchHookContext, type MatchHookItem, type MatchInput, type ModelNames, Money, type MultiCurrencyConfig, type MultiTenantConfig, type NormalBalance, type NotificationBridge, type NotificationBridgeContext, type OpenItem, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, type PartnerLedgerLine, type PartnerLedgerOptions, type PartnerLedgerParams, type PartnerLedgerReport, type PeriodLockedNotification, type PeriodResolverOptions, type PopulatedJournalEntry, type PostOptions, type PostingContract, type PostingResult, type PublishManyResult, type ReconciliationMatchedPayload, type ReconciliationMismatchNotification, type ReconciliationRepository, type ReconciliationUnmatchedPayload, type RecordAPI, type RecordAdjustmentInput, type RecordAdjustmentLine, type RecordExpenseInput, type RecordOptions, type RecordPaymentInput, type RecordSaleInput, type RecordTransferInput, type ReportAccount, type ReportCategory, type ReportDescriptor, type ReportGroup, type ResolvedModelNames, type RevaluationOptions, type RevaluationParams, type RevaluationRate, type RevaluationReport, type RevaluationResult, type ReverseOptions, type ReverseResult, type SchemaOptions, type SeedOptions, type SeedResult, type Cents$1 as SemanticCents, type SessionResult, type SourceBridge, type SourceBridgeContext, type SourceRef, type StatementType, type StrictnessConfig, type SubledgerJournalItem, type SubledgerPostingInput, type TaxDetail, type TaxMetadata, type TotalAccountOp, type TrialBalanceReport, type TrialBalanceRow, type UnmatchHookContext, type WatermarkResolverOptions, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, classifyDuplicateKey, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountingEngine, createEvent, createLockPlugin, createModels, createRepositories, creditLimitPlugin, dailyLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, fxRealizationPlugin, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generatePartnerLedger, generateRevaluation, generateTrialBalance, getCurrency, getCustomJournalTypes, getDateRange, getFiscalYearStart, getJournalType, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, immutableGuardPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, periodResolver, quickbooksFieldMap, registerJournalType, reopenFiscalPeriod, resolveModelNames, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, watermarkResolver };
|