@classytic/ledger 0.4.1 → 0.5.0
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 +227 -189
- package/dist/constants/index.d.mts +1 -1
- package/dist/constants/index.mjs +2 -3
- package/dist/country/index.d.mts +1 -1
- package/dist/{journals-BfwnCFam.mjs → currencies-CsuBGfgs.mjs} +80 -1
- package/dist/{date-lock.plugin-DL6pe24p.mjs → date-lock.plugin-B2Jy0ukX.mjs} +61 -10
- package/dist/errors-BmRjW38t.mjs +33 -0
- package/dist/exports/index.d.mts +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/{fiscal-close-B2_7WMTe.mjs → fiscal-close-Dk3yRT9i.mjs} +14 -4
- package/dist/{index-CxZqRaOU.d.mts → index-GmfEFxVn.d.mts} +1 -1
- package/dist/index.d.mts +530 -338
- package/dist/index.mjs +1824 -175
- package/dist/{journals-DTipb_rz.d.mts → journals-C50E9mpo.d.mts} +1 -1
- 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/{trial-balance-DcQ0xj_4.d.mts → trial-balance-BZ7yOOFD.d.mts} +16 -4
- package/package.json +1 -11
- package/dist/currencies-W8kQAkm0.mjs +0 -80
- package/dist/engine-scgOvxHJ.d.mts +0 -130
- package/dist/errors-B_dyYZc_.mjs +0 -26
- package/dist/journal-entry.schema-JqrfbvB4.d.mts +0 -103
- package/dist/logger-UbTdBb1x.d.mts +0 -14
- package/dist/reconciliation.repository-D-D_ITL-.d.mts +0 -135
- package/dist/reconciliation.repository-fPwFKvrk.mjs +0 -542
- package/dist/reconciliation.schema-BA1lPv4t.mjs +0 -666
- package/dist/repositories/index.d.mts +0 -2
- package/dist/repositories/index.mjs +0 -2
- package/dist/schemas/index.d.mts +0 -71
- package/dist/schemas/index.mjs +0 -2
- package/dist/tenant-guard-r17Se3Bb.mjs +0 -13
- /package/dist/{categories-DWogBUgQ.mjs → categories-BkKdv16V.mjs} +0 -0
- /package/dist/{core-8Xfnpn6g.d.mts → core-BkGjuVZj.d.mts} +0 -0
- /package/dist/{exports-DoGQQtMQ.mjs → exports-BP-0Ni5W.mjs} +0 -0
- /package/dist/{idempotency.plugin-zU-GKJ0-.d.mts → idempotency.plugin-CK7LHnBn.d.mts} +0 -0
- /package/dist/{index-J-XIbXH-.d.mts → index-D1ZjgVxn.d.mts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as JournalType, f as MainType, h as StatementType, i as CategoryKey, o as Currency, r as Category } from "./core-
|
|
1
|
+
import { d as JournalType, f as MainType, h as StatementType, i as CategoryKey, o as Currency, r as Category } from "./core-BkGjuVZj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/constants/categories.d.ts
|
|
4
4
|
/** All valid categories */
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DoubleEntryPluginOptions, c as dateLockPlugin, i as fiscalLockPlugin, n as idempotencyPlugin, o as doubleEntryPlugin, r as FiscalLockPluginOptions, s as DateLockPluginOptions, t as IdempotencyPluginOptions } from "../idempotency.plugin-
|
|
1
|
+
import { a as DoubleEntryPluginOptions, c as dateLockPlugin, i as fiscalLockPlugin, n as idempotencyPlugin, o as doubleEntryPlugin, r as FiscalLockPluginOptions, s as DateLockPluginOptions, t as IdempotencyPluginOptions } from "../idempotency.plugin-CK7LHnBn.mjs";
|
|
2
2
|
import { RepositoryInstance } from "@classytic/mongokit";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/tax-hooks.d.ts
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as doubleEntryPlugin, n as idempotencyPlugin, r as fiscalLockPlugin, t as dateLockPlugin } from "../date-lock.plugin-
|
|
1
|
+
import { i as doubleEntryPlugin, n as idempotencyPlugin, r as fiscalLockPlugin, t as dateLockPlugin } from "../date-lock.plugin-B2Jy0ukX.mjs";
|
|
2
2
|
//#region src/utils/tax-hooks.ts
|
|
3
3
|
/**
|
|
4
4
|
* Apply a tax hook to journal items.
|
package/dist/reports/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as AgedBucketConfig, A as BudgetVsActualReport, C as DimensionBreakdownReport, D as generateCashFlow, E as CashFlowOptions, M as generateBudgetVsActual, N as BalanceSheetOptions, O as BudgetVsActualOptions, P as generateBalanceSheet, Q as AgedBalanceRow, S as DimensionBreakdownParams, T as generateDimensionBreakdown, X as AgedBalanceParams, Y as AgedBalanceOptions, Z as AgedBalanceReport, _ as FiscalCloseResult, a as RevaluationReport, b as reopenFiscalPeriod, et as DEFAULT_BUCKETS, f as IncomeStatementOptions, g as FiscalCloseOptions, h as generateGeneralLedger, i as RevaluationParams, j as BudgetVsActualRow, k as BudgetVsActualParams, m as GeneralLedgerOptions, n as generateTrialBalance, o as generateRevaluation, p as generateIncomeStatement, r as RevaluationOptions, t as TrialBalanceOptions, tt as generateAgedBalance, v as FiscalReopenResult, w as DimensionBreakdownRow, x as DimensionBreakdownOptions, y as closeFiscalPeriod } from "../trial-balance-
|
|
1
|
+
import { $ as AgedBucketConfig, A as BudgetVsActualReport, C as DimensionBreakdownReport, D as generateCashFlow, E as CashFlowOptions, M as generateBudgetVsActual, N as BalanceSheetOptions, O as BudgetVsActualOptions, P as generateBalanceSheet, Q as AgedBalanceRow, S as DimensionBreakdownParams, T as generateDimensionBreakdown, X as AgedBalanceParams, Y as AgedBalanceOptions, Z as AgedBalanceReport, _ as FiscalCloseResult, a as RevaluationReport, b as reopenFiscalPeriod, et as DEFAULT_BUCKETS, f as IncomeStatementOptions, g as FiscalCloseOptions, h as generateGeneralLedger, i as RevaluationParams, j as BudgetVsActualRow, k as BudgetVsActualParams, m as GeneralLedgerOptions, n as generateTrialBalance, o as generateRevaluation, p as generateIncomeStatement, r as RevaluationOptions, t as TrialBalanceOptions, tt as generateAgedBalance, v as FiscalReopenResult, w as DimensionBreakdownRow, x as DimensionBreakdownOptions, y as closeFiscalPeriod } from "../trial-balance-BZ7yOOFD.mjs";
|
|
2
2
|
export { type AgedBalanceOptions, type AgedBalanceParams, type AgedBalanceReport, type AgedBalanceRow, type AgedBucketConfig, type BalanceSheetOptions, type BudgetVsActualOptions, type BudgetVsActualParams, type BudgetVsActualReport, type BudgetVsActualRow, type CashFlowOptions, DEFAULT_BUCKETS, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type FiscalCloseOptions, type FiscalCloseResult, type FiscalReopenResult, type GeneralLedgerOptions, type IncomeStatementOptions, type RevaluationOptions, type RevaluationParams, type RevaluationReport, type TrialBalanceOptions, closeFiscalPeriod, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, reopenFiscalPeriod };
|
package/dist/reports/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as DEFAULT_BUCKETS, d as generateGeneralLedger, f as generateDimensionBreakdown, h as generateBalanceSheet, m as generateBudgetVsActual, n as reopenFiscalPeriod, o as generateTrialBalance, p as generateCashFlow, s as generateRevaluation, t as closeFiscalPeriod, u as generateIncomeStatement, w as generateAgedBalance } from "../fiscal-close-
|
|
1
|
+
import { C as DEFAULT_BUCKETS, d as generateGeneralLedger, f as generateDimensionBreakdown, h as generateBalanceSheet, m as generateBudgetVsActual, n as reopenFiscalPeriod, o as generateTrialBalance, p as generateCashFlow, s as generateRevaluation, t as closeFiscalPeriod, u as generateIncomeStatement, w as generateAgedBalance } from "../fiscal-close-Dk3yRT9i.mjs";
|
|
2
2
|
export { DEFAULT_BUCKETS, closeFiscalPeriod, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, reopenFiscalPeriod };
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { c as DateRange } from "./core-
|
|
2
|
-
import { t as CountryPack } from "./index-
|
|
3
|
-
import { t as Logger } from "./logger-UbTdBb1x.mjs";
|
|
1
|
+
import { c as DateRange } from "./core-BkGjuVZj.mjs";
|
|
2
|
+
import { t as CountryPack } from "./index-GmfEFxVn.mjs";
|
|
4
3
|
import { ClientSession, Model } from "mongoose";
|
|
5
4
|
|
|
5
|
+
//#region src/utils/logger.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Minimal logger interface for the accounting package.
|
|
8
|
+
* Defaults to console. App layer can inject a real logger (Winston/Pino).
|
|
9
|
+
*/
|
|
10
|
+
interface Logger {
|
|
11
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
12
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
13
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
14
|
+
}
|
|
15
|
+
/** Default console-based implementation */
|
|
16
|
+
declare const defaultLogger: Logger;
|
|
17
|
+
//#endregion
|
|
6
18
|
//#region src/reports/aged-balance.d.ts
|
|
7
19
|
interface AgedBucketConfig {
|
|
8
20
|
label: string;
|
|
@@ -527,4 +539,4 @@ declare function generateTrialBalance(opts: TrialBalanceOptions, params: {
|
|
|
527
539
|
filters?: Record<string, unknown>;
|
|
528
540
|
}): Promise<TrialBalanceReport>;
|
|
529
541
|
//#endregion
|
|
530
|
-
export { AgedBucketConfig as $, BudgetVsActualReport as A, IncomeStatementReport as B, DimensionBreakdownReport as C, generateCashFlow as D, CashFlowOptions as E, BalanceSheetReport as F, TaxReport as G, ReportAccount as H, CashFlowReport as I, TrialBalanceRow as J, TaxReturnSummary as K, CashFlowSection as L, generateBudgetVsActual as M, BalanceSheetOptions as N, BudgetVsActualOptions as O, generateBalanceSheet as P, AgedBalanceRow as Q, GeneralLedgerAccount as R, DimensionBreakdownParams as S, generateDimensionBreakdown as T, ReportCategory as U, LedgerEntry as V, ReportGroup as W, AgedBalanceParams as X, AgedBalanceOptions as Y, AgedBalanceReport as Z, FiscalCloseResult as _, RevaluationReport as a, reopenFiscalPeriod as b, RevaluationRate as c, computeRevaluation as d, DEFAULT_BUCKETS as et, IncomeStatementOptions as f, FiscalCloseOptions as g, generateGeneralLedger as h, RevaluationParams as i, BudgetVsActualRow as j, BudgetVsActualParams as k, RevaluationResult as l, GeneralLedgerOptions as m, generateTrialBalance as n, generateRevaluation as o, generateIncomeStatement as p, TrialBalanceReport as q, RevaluationOptions as r, AccountForeignBalance as s, TrialBalanceOptions as t, generateAgedBalance as tt, buildRevaluationEntry as u, FiscalReopenResult as v, DimensionBreakdownRow as w, DimensionBreakdownOptions as x, closeFiscalPeriod as y, GeneralLedgerReport as z };
|
|
542
|
+
export { AgedBucketConfig as $, BudgetVsActualReport as A, IncomeStatementReport as B, DimensionBreakdownReport as C, generateCashFlow as D, CashFlowOptions as E, BalanceSheetReport as F, TaxReport as G, ReportAccount as H, CashFlowReport as I, TrialBalanceRow as J, TaxReturnSummary as K, CashFlowSection as L, generateBudgetVsActual as M, BalanceSheetOptions as N, BudgetVsActualOptions as O, generateBalanceSheet as P, AgedBalanceRow as Q, GeneralLedgerAccount as R, DimensionBreakdownParams as S, generateDimensionBreakdown as T, ReportCategory as U, LedgerEntry as V, ReportGroup as W, AgedBalanceParams as X, AgedBalanceOptions as Y, AgedBalanceReport as Z, FiscalCloseResult as _, RevaluationReport as a, reopenFiscalPeriod as b, RevaluationRate as c, computeRevaluation as d, DEFAULT_BUCKETS as et, IncomeStatementOptions as f, FiscalCloseOptions as g, generateGeneralLedger as h, RevaluationParams as i, BudgetVsActualRow as j, BudgetVsActualParams as k, RevaluationResult as l, GeneralLedgerOptions as m, generateTrialBalance as n, Logger as nt, generateRevaluation as o, generateIncomeStatement as p, TrialBalanceReport as q, RevaluationOptions as r, defaultLogger as rt, AccountForeignBalance as s, TrialBalanceOptions as t, generateAgedBalance as tt, buildRevaluationEntry as u, FiscalReopenResult as v, DimensionBreakdownRow as w, DimensionBreakdownOptions as x, closeFiscalPeriod as y, GeneralLedgerReport as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/ledger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Production-grade double-entry accounting engine for MongoDB — schemas, reports, tax, multi-tenant",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,11 +18,6 @@
|
|
|
18
18
|
"import": "./dist/money.mjs",
|
|
19
19
|
"default": "./dist/money.mjs"
|
|
20
20
|
},
|
|
21
|
-
"./schemas": {
|
|
22
|
-
"types": "./dist/schemas/index.d.mts",
|
|
23
|
-
"import": "./dist/schemas/index.mjs",
|
|
24
|
-
"default": "./dist/schemas/index.mjs"
|
|
25
|
-
},
|
|
26
21
|
"./reports": {
|
|
27
22
|
"types": "./dist/reports/index.d.mts",
|
|
28
23
|
"import": "./dist/reports/index.mjs",
|
|
@@ -43,11 +38,6 @@
|
|
|
43
38
|
"import": "./dist/country/index.mjs",
|
|
44
39
|
"default": "./dist/country/index.mjs"
|
|
45
40
|
},
|
|
46
|
-
"./repositories": {
|
|
47
|
-
"types": "./dist/repositories/index.d.mts",
|
|
48
|
-
"import": "./dist/repositories/index.mjs",
|
|
49
|
-
"default": "./dist/repositories/index.mjs"
|
|
50
|
-
},
|
|
51
41
|
"./exports": {
|
|
52
42
|
"types": "./dist/exports/index.d.mts",
|
|
53
43
|
"import": "./dist/exports/index.mjs",
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
//#region src/constants/currencies.ts
|
|
2
|
-
const CURRENCIES = Object.freeze({
|
|
3
|
-
CAD: {
|
|
4
|
-
code: "CAD",
|
|
5
|
-
name: "Canadian Dollar",
|
|
6
|
-
symbol: "$",
|
|
7
|
-
minorUnit: 2
|
|
8
|
-
},
|
|
9
|
-
USD: {
|
|
10
|
-
code: "USD",
|
|
11
|
-
name: "US Dollar",
|
|
12
|
-
symbol: "$",
|
|
13
|
-
minorUnit: 2
|
|
14
|
-
},
|
|
15
|
-
GBP: {
|
|
16
|
-
code: "GBP",
|
|
17
|
-
name: "British Pound",
|
|
18
|
-
symbol: "£",
|
|
19
|
-
minorUnit: 2
|
|
20
|
-
},
|
|
21
|
-
EUR: {
|
|
22
|
-
code: "EUR",
|
|
23
|
-
name: "Euro",
|
|
24
|
-
symbol: "€",
|
|
25
|
-
minorUnit: 2
|
|
26
|
-
},
|
|
27
|
-
JPY: {
|
|
28
|
-
code: "JPY",
|
|
29
|
-
name: "Japanese Yen",
|
|
30
|
-
symbol: "¥",
|
|
31
|
-
minorUnit: 0
|
|
32
|
-
},
|
|
33
|
-
AUD: {
|
|
34
|
-
code: "AUD",
|
|
35
|
-
name: "Australian Dollar",
|
|
36
|
-
symbol: "$",
|
|
37
|
-
minorUnit: 2
|
|
38
|
-
},
|
|
39
|
-
CHF: {
|
|
40
|
-
code: "CHF",
|
|
41
|
-
name: "Swiss Franc",
|
|
42
|
-
symbol: "CHF",
|
|
43
|
-
minorUnit: 2
|
|
44
|
-
},
|
|
45
|
-
INR: {
|
|
46
|
-
code: "INR",
|
|
47
|
-
name: "Indian Rupee",
|
|
48
|
-
symbol: "₹",
|
|
49
|
-
minorUnit: 2
|
|
50
|
-
},
|
|
51
|
-
BDT: {
|
|
52
|
-
code: "BDT",
|
|
53
|
-
name: "Bangladeshi Taka",
|
|
54
|
-
symbol: "৳",
|
|
55
|
-
minorUnit: 2
|
|
56
|
-
},
|
|
57
|
-
AED: {
|
|
58
|
-
code: "AED",
|
|
59
|
-
name: "UAE Dirham",
|
|
60
|
-
symbol: "د.إ",
|
|
61
|
-
minorUnit: 2
|
|
62
|
-
},
|
|
63
|
-
SAR: {
|
|
64
|
-
code: "SAR",
|
|
65
|
-
name: "Saudi Riyal",
|
|
66
|
-
symbol: "﷼",
|
|
67
|
-
minorUnit: 2
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
function getCurrency(code) {
|
|
71
|
-
return CURRENCIES[code] ?? null;
|
|
72
|
-
}
|
|
73
|
-
function isValidCurrency(code) {
|
|
74
|
-
return code in CURRENCIES;
|
|
75
|
-
}
|
|
76
|
-
function getMinorUnit(code) {
|
|
77
|
-
return CURRENCIES[code]?.minorUnit ?? 2;
|
|
78
|
-
}
|
|
79
|
-
//#endregion
|
|
80
|
-
export { isValidCurrency as i, getCurrency as n, getMinorUnit as r, CURRENCIES as t };
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { t as CountryPack } from "./index-CxZqRaOU.mjs";
|
|
2
|
-
import { t as Logger } from "./logger-UbTdBb1x.mjs";
|
|
3
|
-
import { Connection } from "mongoose";
|
|
4
|
-
|
|
5
|
-
//#region src/types/engine.d.ts
|
|
6
|
-
/** Multi-tenant configuration */
|
|
7
|
-
interface MultiTenantConfig {
|
|
8
|
-
/** Field name for the organization reference (e.g., 'business', 'organization', 'company') */
|
|
9
|
-
orgField: string;
|
|
10
|
-
/** Mongoose model name the org field references (e.g., 'Business', 'Organization') */
|
|
11
|
-
orgRef: string;
|
|
12
|
-
}
|
|
13
|
-
/** Options passed to schema factory functions */
|
|
14
|
-
interface SchemaOptions {
|
|
15
|
-
/** Add recommended indexes (default: true) */
|
|
16
|
-
indexes?: boolean;
|
|
17
|
-
/** Extra Mongoose schema fields to merge in */
|
|
18
|
-
extraFields?: Record<string, unknown>;
|
|
19
|
-
/** Extra indexes to add */
|
|
20
|
-
extraIndexes?: Array<{
|
|
21
|
-
fields: Record<string, 1 | -1>;
|
|
22
|
-
options?: Record<string, unknown>;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
25
|
-
/** Journal entry schema-specific options */
|
|
26
|
-
interface JournalSchemaOptions extends SchemaOptions {
|
|
27
|
-
/** Auto-generate reference numbers (default: true) */
|
|
28
|
-
autoReference?: boolean;
|
|
29
|
-
/** Enable text search index on reference + label (default: true) */
|
|
30
|
-
textSearch?: boolean;
|
|
31
|
-
/** Extra Mongoose schema fields to merge into the JournalItem subdocument */
|
|
32
|
-
extraItemFields?: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
/** Audit trail configuration */
|
|
35
|
-
interface AuditConfig {
|
|
36
|
-
/** Track actor (user) who performs each operation (post, reverse, approve) */
|
|
37
|
-
trackActor?: boolean;
|
|
38
|
-
}
|
|
39
|
-
/** Strictness rules for the ledger */
|
|
40
|
-
interface StrictnessConfig {
|
|
41
|
-
/** If true, unpost() is disabled — correction only via reverse() (immutable ledger) */
|
|
42
|
-
immutable?: boolean;
|
|
43
|
-
/** If true, actorId is required on post/reverse/unpost operations */
|
|
44
|
-
requireActor?: boolean;
|
|
45
|
-
/** If true, entries must have approvedBy/approvedAt set before posting */
|
|
46
|
-
requireApproval?: boolean;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Multi-currency configuration.
|
|
50
|
-
* When enabled, adds currency and exchange rate fields to journal items
|
|
51
|
-
* and a currency field to accounts. Allows recording transactions in
|
|
52
|
-
* foreign currencies while maintaining a base (functional) currency.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const engine = createAccountingEngine({
|
|
57
|
-
* country: canadaPack,
|
|
58
|
-
* currency: 'CAD', // base/functional currency
|
|
59
|
-
* multiCurrency: {
|
|
60
|
-
* enabled: true,
|
|
61
|
-
* currencies: ['USD', 'GBP', 'BDT'], // allowed foreign currencies
|
|
62
|
-
* },
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
interface MultiCurrencyConfig {
|
|
67
|
-
/** Enable multi-currency fields on schemas */
|
|
68
|
-
enabled: boolean;
|
|
69
|
-
/** Allowed foreign currency codes. If omitted, any ISO 4217 code is accepted. */
|
|
70
|
-
currencies?: readonly string[];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Override default model names. Useful when you want to avoid collisions
|
|
74
|
-
* with existing models or use custom naming conventions.
|
|
75
|
-
*/
|
|
76
|
-
interface ModelNames {
|
|
77
|
-
account?: string;
|
|
78
|
-
journalEntry?: string;
|
|
79
|
-
fiscalPeriod?: string;
|
|
80
|
-
budget?: string;
|
|
81
|
-
reconciliation?: string;
|
|
82
|
-
}
|
|
83
|
-
/** Main engine configuration */
|
|
84
|
-
interface AccountingEngineConfig {
|
|
85
|
-
/**
|
|
86
|
-
* Mongoose connection. Required for `engine.models` and `engine.repositories`
|
|
87
|
-
* to be auto-populated. If omitted, you must use the low-level schema
|
|
88
|
-
* factories (`engine.createAccountSchema()`) and register models yourself.
|
|
89
|
-
*/
|
|
90
|
-
mongoose?: Connection;
|
|
91
|
-
/** Override default model names (e.g. 'Account' → 'GLAccount') */
|
|
92
|
-
modelNames?: ModelNames;
|
|
93
|
-
/** Extra fields / indexes per model */
|
|
94
|
-
schemaOptions?: {
|
|
95
|
-
account?: SchemaOptions;
|
|
96
|
-
journalEntry?: JournalSchemaOptions;
|
|
97
|
-
fiscalPeriod?: SchemaOptions;
|
|
98
|
-
budget?: SchemaOptions;
|
|
99
|
-
reconciliation?: SchemaOptions;
|
|
100
|
-
};
|
|
101
|
-
/** Country pack providing account types, tax codes, and templates */
|
|
102
|
-
country: CountryPack;
|
|
103
|
-
/** Default ISO 4217 currency code — the functional/base currency (e.g., 'CAD', 'BDT') */
|
|
104
|
-
currency: string;
|
|
105
|
-
/** Multi-tenant configuration. Omit for single-tenant apps. */
|
|
106
|
-
multiTenant?: MultiTenantConfig;
|
|
107
|
-
/** Multi-currency support. Omit for single-currency apps. */
|
|
108
|
-
multiCurrency?: MultiCurrencyConfig;
|
|
109
|
-
/** Fiscal year start month (1-12, default: 1 = January) */
|
|
110
|
-
fiscalYearStartMonth?: number;
|
|
111
|
-
/**
|
|
112
|
-
* The retained earnings account code (e.g. '3600' CA, '3310' BD).
|
|
113
|
-
* Overrides the country pack value. See CountryPack.retainedEarningsAccountCode.
|
|
114
|
-
*/
|
|
115
|
-
retainedEarningsAccountCode?: string;
|
|
116
|
-
/** Display code for the "Previous Years Retained Earnings" line. Overrides country pack. */
|
|
117
|
-
retainedEarningsDisplayCode?: string;
|
|
118
|
-
/** Display code for current year net income line. Overrides country pack. */
|
|
119
|
-
currentYearEarningsCode?: string;
|
|
120
|
-
/** Logger instance. Defaults to console-based logger. */
|
|
121
|
-
logger?: Logger;
|
|
122
|
-
/** Audit trail configuration */
|
|
123
|
-
audit?: AuditConfig;
|
|
124
|
-
/** Enable built-in idempotency key field on journal entries */
|
|
125
|
-
idempotency?: boolean;
|
|
126
|
-
/** Strictness rules for the ledger */
|
|
127
|
-
strictness?: StrictnessConfig;
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
export { MultiCurrencyConfig as a, StrictnessConfig as c, ModelNames as i, AuditConfig as n, MultiTenantConfig as o, JournalSchemaOptions as r, SchemaOptions as s, AccountingEngineConfig as t };
|
package/dist/errors-B_dyYZc_.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/utils/errors.ts
|
|
2
|
-
/**
|
|
3
|
-
* Typed error for the accounting package.
|
|
4
|
-
* Carries HTTP status + machine-readable code.
|
|
5
|
-
* Replaces all ad-hoc `(error as ...).status = N` patterns.
|
|
6
|
-
*/
|
|
7
|
-
var AccountingError = class extends Error {
|
|
8
|
-
status;
|
|
9
|
-
code;
|
|
10
|
-
constructor(message, status = 400, code = "ACCOUNTING_ERROR") {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = "AccountingError";
|
|
13
|
-
this.status = status;
|
|
14
|
-
this.code = code;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
/** Convenience factory functions */
|
|
18
|
-
const Errors = {
|
|
19
|
-
validation: (msg) => new AccountingError(msg, 400, "VALIDATION_ERROR"),
|
|
20
|
-
notFound: (msg) => new AccountingError(msg, 404, "NOT_FOUND"),
|
|
21
|
-
conflict: (msg) => new AccountingError(msg, 409, "CONFLICT"),
|
|
22
|
-
immutable: (msg) => new AccountingError(msg, 403, "IMMUTABLE_ENTRY"),
|
|
23
|
-
fiscal: (msg) => new AccountingError(msg, 400, "FISCAL_ERROR")
|
|
24
|
-
};
|
|
25
|
-
//#endregion
|
|
26
|
-
export { Errors as n, AccountingError as t };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { r as JournalSchemaOptions, s as SchemaOptions, t as AccountingEngineConfig } from "./engine-scgOvxHJ.mjs";
|
|
2
|
-
import mongoose from "mongoose";
|
|
3
|
-
|
|
4
|
-
//#region src/schemas/account.schema.d.ts
|
|
5
|
-
declare function createAccountSchema(config: AccountingEngineConfig, options?: SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
6
|
-
timestamps: true;
|
|
7
|
-
}, {
|
|
8
|
-
[x: number]: any;
|
|
9
|
-
[x: string]: any;
|
|
10
|
-
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
11
|
-
[x: number]: any;
|
|
12
|
-
[x: string]: any;
|
|
13
|
-
} & mongoose.DefaultTimestampProps, {
|
|
14
|
-
id: string;
|
|
15
|
-
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
16
|
-
timestamps: true;
|
|
17
|
-
}> & Omit<{
|
|
18
|
-
[x: number]: any;
|
|
19
|
-
[x: string]: any;
|
|
20
|
-
} & mongoose.DefaultTimestampProps & {
|
|
21
|
-
_id: mongoose.Types.ObjectId;
|
|
22
|
-
} & {
|
|
23
|
-
__v: number;
|
|
24
|
-
}, "id"> & {
|
|
25
|
-
id: string;
|
|
26
|
-
}, unknown, {
|
|
27
|
-
[x: number]: any;
|
|
28
|
-
[x: string]: any;
|
|
29
|
-
createdAt: NativeDate;
|
|
30
|
-
updatedAt: NativeDate;
|
|
31
|
-
} & {
|
|
32
|
-
_id: mongoose.Types.ObjectId;
|
|
33
|
-
} & {
|
|
34
|
-
__v: number;
|
|
35
|
-
}>;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/schemas/fiscal-period.schema.d.ts
|
|
38
|
-
declare function createFiscalPeriodSchema(config: AccountingEngineConfig, options?: SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
39
|
-
timestamps: true;
|
|
40
|
-
}, {
|
|
41
|
-
[x: number]: any;
|
|
42
|
-
[x: string]: any;
|
|
43
|
-
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
44
|
-
[x: number]: any;
|
|
45
|
-
[x: string]: any;
|
|
46
|
-
} & mongoose.DefaultTimestampProps, {
|
|
47
|
-
id: string;
|
|
48
|
-
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
49
|
-
timestamps: true;
|
|
50
|
-
}> & Omit<{
|
|
51
|
-
[x: number]: any;
|
|
52
|
-
[x: string]: any;
|
|
53
|
-
} & mongoose.DefaultTimestampProps & {
|
|
54
|
-
_id: mongoose.Types.ObjectId;
|
|
55
|
-
} & {
|
|
56
|
-
__v: number;
|
|
57
|
-
}, "id"> & {
|
|
58
|
-
id: string;
|
|
59
|
-
}, unknown, {
|
|
60
|
-
[x: number]: any;
|
|
61
|
-
[x: string]: any;
|
|
62
|
-
createdAt: NativeDate;
|
|
63
|
-
updatedAt: NativeDate;
|
|
64
|
-
} & {
|
|
65
|
-
_id: mongoose.Types.ObjectId;
|
|
66
|
-
} & {
|
|
67
|
-
__v: number;
|
|
68
|
-
}>;
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/schemas/journal-entry.schema.d.ts
|
|
71
|
-
declare function createJournalEntrySchema(config: AccountingEngineConfig, accountModelName: string, options?: JournalSchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
72
|
-
timestamps: true;
|
|
73
|
-
}, {
|
|
74
|
-
[x: number]: any;
|
|
75
|
-
[x: string]: any;
|
|
76
|
-
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
|
|
77
|
-
[x: number]: any;
|
|
78
|
-
[x: string]: any;
|
|
79
|
-
} & mongoose.DefaultTimestampProps, {
|
|
80
|
-
id: string;
|
|
81
|
-
}, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
|
|
82
|
-
timestamps: true;
|
|
83
|
-
}> & Omit<{
|
|
84
|
-
[x: number]: any;
|
|
85
|
-
[x: string]: any;
|
|
86
|
-
} & mongoose.DefaultTimestampProps & {
|
|
87
|
-
_id: mongoose.Types.ObjectId;
|
|
88
|
-
} & {
|
|
89
|
-
__v: number;
|
|
90
|
-
}, "id"> & {
|
|
91
|
-
id: string;
|
|
92
|
-
}, unknown, {
|
|
93
|
-
[x: number]: any;
|
|
94
|
-
[x: string]: any;
|
|
95
|
-
createdAt: NativeDate;
|
|
96
|
-
updatedAt: NativeDate;
|
|
97
|
-
} & {
|
|
98
|
-
_id: mongoose.Types.ObjectId;
|
|
99
|
-
} & {
|
|
100
|
-
__v: number;
|
|
101
|
-
}>;
|
|
102
|
-
//#endregion
|
|
103
|
-
export { createFiscalPeriodSchema as n, createAccountSchema as r, createJournalEntrySchema as t };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/utils/logger.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Minimal logger interface for the accounting package.
|
|
4
|
-
* Defaults to console. App layer can inject a real logger (Winston/Pino).
|
|
5
|
-
*/
|
|
6
|
-
interface Logger {
|
|
7
|
-
warn(message: string, meta?: Record<string, unknown>): void;
|
|
8
|
-
error(message: string, meta?: Record<string, unknown>): void;
|
|
9
|
-
info(message: string, meta?: Record<string, unknown>): void;
|
|
10
|
-
}
|
|
11
|
-
/** Default console-based implementation */
|
|
12
|
-
declare const defaultLogger: Logger;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { defaultLogger as n, Logger as t };
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { t as CountryPack } from "./index-CxZqRaOU.mjs";
|
|
2
|
-
import { c as StrictnessConfig } from "./engine-scgOvxHJ.mjs";
|
|
3
|
-
import { ClientSession, Model } from "mongoose";
|
|
4
|
-
import { Repository } from "@classytic/mongokit";
|
|
5
|
-
|
|
6
|
-
//#region src/types/repositories.d.ts
|
|
7
|
-
interface PostOptions {
|
|
8
|
-
session?: ClientSession | null;
|
|
9
|
-
/** Actor performing this operation (required when strictness.requireActor is enabled) */
|
|
10
|
-
actorId?: unknown;
|
|
11
|
-
}
|
|
12
|
-
interface ReverseOptions extends PostOptions {
|
|
13
|
-
/** Date for the reversal entry (defaults to now) */
|
|
14
|
-
reversalDate?: Date;
|
|
15
|
-
}
|
|
16
|
-
interface SeedOptions {
|
|
17
|
-
session?: ClientSession | null;
|
|
18
|
-
}
|
|
19
|
-
interface SeedResult {
|
|
20
|
-
created: number;
|
|
21
|
-
skipped: number;
|
|
22
|
-
}
|
|
23
|
-
interface BulkCreateInput {
|
|
24
|
-
accountTypeCode?: string;
|
|
25
|
-
accountNumber?: string;
|
|
26
|
-
name?: string;
|
|
27
|
-
active?: boolean;
|
|
28
|
-
isCashAccount?: boolean;
|
|
29
|
-
}
|
|
30
|
-
interface BulkCreateResult {
|
|
31
|
-
summary: {
|
|
32
|
-
total: number;
|
|
33
|
-
created: number;
|
|
34
|
-
skipped: number;
|
|
35
|
-
errors: number;
|
|
36
|
-
};
|
|
37
|
-
created: Array<Record<string, unknown>>;
|
|
38
|
-
skipped: Array<Record<string, unknown>>;
|
|
39
|
-
errors: Array<Record<string, unknown>>;
|
|
40
|
-
}
|
|
41
|
-
interface ReverseResult {
|
|
42
|
-
original: Record<string, unknown>;
|
|
43
|
-
reversal: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
interface ReconcileParams {
|
|
46
|
-
accountId: unknown;
|
|
47
|
-
journalEntryIds: unknown[];
|
|
48
|
-
organizationId?: unknown;
|
|
49
|
-
note?: string;
|
|
50
|
-
session?: ClientSession;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Journal Entry Repository — extends mongokit Repository with accounting domain methods.
|
|
54
|
-
*
|
|
55
|
-
* Inherits ALL Repository<TDoc> methods: create, getById, getAll, update,
|
|
56
|
-
* delete, count, exists, distinct, aggregate, withTransaction, etc.
|
|
57
|
-
*/
|
|
58
|
-
interface JournalEntryRepository<TDoc = unknown> extends Repository<TDoc> {
|
|
59
|
-
/** Post an entry (draft → posted). Validates items, balance, and accounts. */
|
|
60
|
-
post(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
61
|
-
/** Unpost an entry (posted → draft). Resets state for re-editing. */
|
|
62
|
-
unpost(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
63
|
-
/** Archive a draft entry (draft → archived). Preserves audit trail. */
|
|
64
|
-
archive(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
65
|
-
/** Duplicate an entry as a new draft. Copies items, type, and label. */
|
|
66
|
-
duplicate(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
67
|
-
/** Reverse a posted entry. Creates mirror entry with flipped debits/credits. */
|
|
68
|
-
reverse(id: unknown, orgId?: unknown, options?: ReverseOptions): Promise<ReverseResult>;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Account Repository — extends mongokit Repository with seed and bulk operations.
|
|
72
|
-
*/
|
|
73
|
-
interface AccountRepository<TDoc = unknown> extends Repository<TDoc> {
|
|
74
|
-
/** Seed standard posting accounts for an org from the country pack. */
|
|
75
|
-
seedAccounts(orgId: unknown, options?: SeedOptions): Promise<SeedResult>;
|
|
76
|
-
/** Bulk create accounts with validation and skip-if-exists logic. */
|
|
77
|
-
bulkCreate(accounts: BulkCreateInput[], orgId: unknown): Promise<BulkCreateResult>;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Reconciliation Repository — extends mongokit Repository with bank reconciliation methods.
|
|
81
|
-
*/
|
|
82
|
-
interface ReconciliationRepository<TDoc = unknown> extends Repository<TDoc> {
|
|
83
|
-
/** Reconcile journal entries for a specific account. */
|
|
84
|
-
reconcile(params: ReconcileParams): Promise<Record<string, unknown>>;
|
|
85
|
-
/** Remove a reconciliation record. */
|
|
86
|
-
unreconcile(params: {
|
|
87
|
-
reconciliationId: unknown;
|
|
88
|
-
organizationId?: unknown;
|
|
89
|
-
}): Promise<{
|
|
90
|
-
success: boolean;
|
|
91
|
-
}>;
|
|
92
|
-
/** Get unreconciled journal entries for an account. */
|
|
93
|
-
getUnreconciled(params: {
|
|
94
|
-
accountId: unknown;
|
|
95
|
-
organizationId?: unknown;
|
|
96
|
-
}): Promise<Record<string, unknown>[]>;
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/repositories/account.repository.d.ts
|
|
100
|
-
/**
|
|
101
|
-
* Wire seedAccounts, bulkCreate and posting-account validation
|
|
102
|
-
* onto an existing mongokit Repository.
|
|
103
|
-
*
|
|
104
|
-
* @param repository - A mongokit Repository instance (already created)
|
|
105
|
-
* @param AccountModel - The Mongoose model for accounts
|
|
106
|
-
* @param country - The CountryPack for account type lookups
|
|
107
|
-
* @param orgField - The multi-tenant field name (e.g. 'business')
|
|
108
|
-
*/
|
|
109
|
-
declare function wireAccountMethods<TDoc = unknown>(repository: Repository<TDoc>, AccountModel: Model<unknown>, country: CountryPack, orgField?: string): AccountRepository<TDoc>;
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/repositories/journal-entry.repository.d.ts
|
|
112
|
-
/**
|
|
113
|
-
* Wire post/reverse onto an existing mongokit Repository.
|
|
114
|
-
*
|
|
115
|
-
* All reads use `repository.getByQuery()` so registered plugins
|
|
116
|
-
* (multi-tenant, audit, cache) fire on every operation.
|
|
117
|
-
*
|
|
118
|
-
* @param repository - A mongokit Repository instance (already created)
|
|
119
|
-
* @param _JournalEntryModel - (Deprecated) The Mongoose model — no longer used internally; kept for API compat
|
|
120
|
-
* @param orgField - The multi-tenant field name (e.g. 'business')
|
|
121
|
-
* @param strictness - Strictness rules (immutable, requireActor, requireApproval)
|
|
122
|
-
*/
|
|
123
|
-
declare function wireJournalEntryMethods<TDoc = unknown>(repository: Repository<TDoc>, _JournalEntryModel: unknown, orgField?: string, strictness?: StrictnessConfig): JournalEntryRepository<TDoc>;
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/repositories/reconciliation.repository.d.ts
|
|
126
|
-
/**
|
|
127
|
-
* Wire reconciliation methods onto an existing mongokit Repository.
|
|
128
|
-
*
|
|
129
|
-
* - reconcile() uses repository.create() so hooks (multi-tenant, audit) fire
|
|
130
|
-
* - unreconcile() uses repository.delete() so hooks fire
|
|
131
|
-
* - Cross-repo reads (JournalEntryModel) use direct Model access (acceptable)
|
|
132
|
-
*/
|
|
133
|
-
declare function wireReconciliationMethods<TDoc = unknown>(repository: Repository<TDoc>, _ReconciliationModel: Model<unknown>, JournalEntryModel: Model<unknown>, orgField?: string): ReconciliationRepository<TDoc>;
|
|
134
|
-
//#endregion
|
|
135
|
-
export { BulkCreateInput as a, PostOptions as c, ReverseOptions as d, ReverseResult as f, AccountRepository as i, ReconcileParams as l, SeedResult as m, wireJournalEntryMethods as n, BulkCreateResult as o, SeedOptions as p, wireAccountMethods as r, JournalEntryRepository as s, wireReconciliationMethods as t, ReconciliationRepository as u };
|