@classytic/ledger 0.3.0 → 0.4.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.
Files changed (33) hide show
  1. package/dist/constants/index.d.mts +2 -2
  2. package/dist/constants/index.mjs +3 -3
  3. package/dist/{date-lock.plugin-eYAJ9h_u.mjs → date-lock.plugin-C8kqPBjh.mjs} +2 -2
  4. package/dist/{engine-Cn-9yerQ.d.mts → engine-DF-MtsEr.d.mts} +1 -1
  5. package/dist/exports/index.d.mts +1 -1
  6. package/dist/exports/index.mjs +1 -1
  7. package/dist/{exports-I5Xkq-9_.mjs → exports-DoGQQtMQ.mjs} +96 -75
  8. package/dist/{fiscal-close-B6LhQ10f.mjs → fiscal-close-DmPV82e4.mjs} +748 -751
  9. package/dist/{index-BPukb3L8.d.mts → index-J-XIbXH-.d.mts} +7 -7
  10. package/dist/index.d.mts +85 -85
  11. package/dist/index.mjs +9 -9
  12. package/dist/{fiscal-period.schema-BMnlI9H5.d.mts → journal-entry.schema-B1CzLwC3.d.mts} +12 -12
  13. package/dist/{journals-oH-FK3g8.mjs → journals-BcMn71Cq.mjs} +27 -4
  14. package/dist/{currencies-4WAbFRlw.d.mts → journals-DTipb_rz.d.mts} +16 -7
  15. package/dist/money.mjs +2 -2
  16. package/dist/plugins/index.d.mts +1 -1
  17. package/dist/plugins/index.mjs +1 -1
  18. package/dist/{reconciliation.repository-CW4-8q90.d.mts → reconciliation.repository-DEybU_Ok.d.mts} +14 -14
  19. package/dist/{account.repository-BpkSd6q3.mjs → reconciliation.repository-DgJEDVS-.mjs} +255 -255
  20. package/dist/{reconciliation.schema-BuetvZTd.mjs → reconciliation.schema-KScbsXbY.mjs} +174 -173
  21. package/dist/reports/index.d.mts +1 -1
  22. package/dist/reports/index.mjs +1 -1
  23. package/dist/repositories/index.d.mts +1 -1
  24. package/dist/repositories/index.mjs +1 -1
  25. package/dist/schemas/index.d.mts +6 -6
  26. package/dist/schemas/index.mjs +1 -1
  27. package/dist/{tenant-guard-Fm6AID_6.mjs → tenant-guard-CAxXoWuS.mjs} +1 -1
  28. package/dist/{revaluation-D9x0NE8w.d.mts → trial-balance-DcQ0xj_4.d.mts} +124 -124
  29. package/package.json +14 -6
  30. /package/dist/{categories-CclX7Q94.mjs → categories-FJlrvzcl.mjs} +0 -0
  31. /package/dist/{errors-B7yC-Jfw.mjs → errors-BoGUSUYL.mjs} +0 -0
  32. /package/dist/{idempotency.plugin-B_CNsInz.d.mts → idempotency.plugin-zU-GKJ0-.d.mts} +0 -0
  33. /package/dist/{logger-CbHWZl7v.d.mts → logger-UbTdBb1x.d.mts} +0 -0
@@ -121,16 +121,16 @@ declare function extractAllRows<TRow>(fieldMap: ExportFieldMap<TRow>, rows: read
121
121
  /** One-shot: map + serialize to CSV string. */
122
122
  declare function exportToCsv<TRow>(fieldMap: ExportFieldMap<TRow>, rows: readonly TRow[], options?: CsvOptions): string;
123
123
  //#endregion
124
- //#region src/exports/flatten-journal.d.ts
125
- /** Flatten a single journal entry into one FlatJournalRow per journal item. */
126
- declare function flattenJournalEntry(entry: PopulatedJournalEntry): FlatJournalRow[];
127
- /** Flatten multiple journal entries into a single flat row array. */
128
- declare function flattenJournalEntries(entries: readonly PopulatedJournalEntry[]): FlatJournalRow[];
129
- //#endregion
130
124
  //#region src/exports/field-maps/quickbooks.d.ts
131
125
  declare const quickbooksFieldMap: ExportFieldMap<FlatJournalRow>;
132
126
  //#endregion
133
127
  //#region src/exports/field-maps/universal.d.ts
134
128
  declare const universalFieldMap: ExportFieldMap<FlatJournalRow>;
135
129
  //#endregion
136
- export { PopulatedJournalEntry as _, exportToCsv as a, getHeaders as c, serializeCsv as d, CsvOptions as f, PopulatedAccount as g, FlatJournalRow as h, flattenJournalEntry as i, buildCsv as l, ExportFieldMap as m, quickbooksFieldMap as n, extractAllRows as o, ExportField as p, flattenJournalEntries as r, extractRow as s, universalFieldMap as t, escapeCell as u, PopulatedJournalItem as v };
130
+ //#region src/exports/flatten-journal.d.ts
131
+ /** Flatten a single journal entry into one FlatJournalRow per journal item. */
132
+ declare function flattenJournalEntry(entry: PopulatedJournalEntry): FlatJournalRow[];
133
+ /** Flatten multiple journal entries into a single flat row array. */
134
+ declare function flattenJournalEntries(entries: readonly PopulatedJournalEntry[]): FlatJournalRow[];
135
+ //#endregion
136
+ export { PopulatedJournalEntry as _, exportToCsv as a, getHeaders as c, serializeCsv as d, CsvOptions as f, PopulatedAccount as g, FlatJournalRow as h, quickbooksFieldMap as i, buildCsv as l, ExportFieldMap as m, flattenJournalEntry as n, extractAllRows as o, ExportField as p, universalFieldMap as r, extractRow as s, flattenJournalEntries as t, escapeCell as u, PopulatedJournalItem as v };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,14 @@
1
1
  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-8Xfnpn6g.mjs";
2
- import { _ as getNormalBalance, a as JOURNAL_CODES, b as isValidCategory, c as getJournalTypeCodes, d as CATEGORY_KEYS, i as isValidCurrency, l as isValidJournalType, n as getCurrency, o as JOURNAL_TYPES, r as getMinorUnit, t as CURRENCIES, u as CATEGORIES, v as isBalanceSheet, y as isIncomeStatement } from "./currencies-4WAbFRlw.mjs";
2
+ 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-DTipb_rz.mjs";
3
3
  import { a as TaxReportLine, i as TaxCodesByRegion, n as CountryPackInput, o as TaxReportTemplate, r as TaxCode, s as defineCountryPack, t as CountryPack } from "./index-CxZqRaOU.mjs";
4
- import { _ as PopulatedJournalEntry, a as exportToCsv, h as FlatJournalRow, m as ExportFieldMap, n as quickbooksFieldMap, p as ExportField, r as flattenJournalEntries, t as universalFieldMap } from "./index-BPukb3L8.mjs";
4
+ 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
5
  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 BudgetVsActualReport, A as generateGeneralLedger, B as GeneralLedgerAccount, E as reopenFiscalPeriod, G as ReportCategory, H as IncomeStatementReport, I as generateTrialBalance, J as TaxReturnSummary, K as ReportGroup, L as BalanceSheetReport, M as generateIncomeStatement, O as generateCashFlow, P as generateBalanceSheet, R as CashFlowReport, T as closeFiscalPeriod, U as LedgerEntry, V as GeneralLedgerReport, W as ReportAccount, X as TrialBalanceRow, Y as TrialBalanceReport, _ as DimensionBreakdownOptions, a as AccountForeignBalance, b as DimensionBreakdownRow, c as buildRevaluationEntry, d as AgedBalanceParams, f as AgedBalanceReport, g as generateAgedBalance, h as DEFAULT_BUCKETS, i as generateRevaluation, l as computeRevaluation, m as AgedBucketConfig, n as RevaluationParams, o as RevaluationRate, p as AgedBalanceRow, q as TaxReport, r as RevaluationReport, s as RevaluationResult, t as RevaluationOptions, u as AgedBalanceOptions, v as DimensionBreakdownParams, x as generateDimensionBreakdown, y as DimensionBreakdownReport, z as CashFlowSection } from "./revaluation-D9x0NE8w.mjs";
7
- import { n as defaultLogger, t as Logger } from "./logger-CbHWZl7v.mjs";
8
- import { a as MultiTenantConfig, i as MultiCurrencyConfig, n as AuditConfig, o as SchemaOptions, r as JournalSchemaOptions, s as StrictnessConfig, t as AccountingEngineConfig } from "./engine-Cn-9yerQ.mjs";
9
- import { a as BulkCreateInput, c as PostOptions, d as ReverseOptions, f as ReverseResult, i as AccountRepository, l as ReconcileParams, m as SeedResult, n as wireAccountMethods, o as BulkCreateResult, p as SeedOptions, r as wireJournalEntryMethods, s as JournalEntryRepository, t as wireReconciliationMethods, u as ReconciliationRepository } from "./reconciliation.repository-CW4-8q90.mjs";
10
- import { n as createJournalEntrySchema, r as createAccountSchema, t as createFiscalPeriodSchema } from "./fiscal-period.schema-BMnlI9H5.mjs";
11
- import { c as dateLockPlugin, i as fiscalLockPlugin, n as idempotencyPlugin, o as doubleEntryPlugin } from "./idempotency.plugin-B_CNsInz.mjs";
6
+ import { n as defaultLogger, t as Logger } from "./logger-UbTdBb1x.mjs";
7
+ import { a as MultiTenantConfig, i as MultiCurrencyConfig, n as AuditConfig, o as SchemaOptions, r as JournalSchemaOptions, s as StrictnessConfig, t as AccountingEngineConfig } from "./engine-DF-MtsEr.mjs";
8
+ import { a as BulkCreateInput, c as PostOptions, d as ReverseOptions, f as ReverseResult, i as AccountRepository, l as ReconcileParams, m as SeedResult, n as wireJournalEntryMethods, o as BulkCreateResult, p as SeedOptions, r as wireAccountMethods, s as JournalEntryRepository, t as wireReconciliationMethods, u as ReconciliationRepository } from "./reconciliation.repository-DEybU_Ok.mjs";
9
+ import { n as createFiscalPeriodSchema, r as createAccountSchema, t as createJournalEntrySchema } from "./journal-entry.schema-B1CzLwC3.mjs";
10
+ import { c as dateLockPlugin, i as fiscalLockPlugin, n as idempotencyPlugin, o as doubleEntryPlugin } from "./idempotency.plugin-zU-GKJ0-.mjs";
11
+ import { $ as AgedBucketConfig, A as BudgetVsActualReport, B as IncomeStatementReport, C as DimensionBreakdownReport, D as generateCashFlow, F as BalanceSheetReport, G as TaxReport, H as ReportAccount, I as CashFlowReport, J as TrialBalanceRow, K as TaxReturnSummary, L as CashFlowSection, M as generateBudgetVsActual, O as BudgetVsActualOptions, P as generateBalanceSheet, Q as AgedBalanceRow, R as GeneralLedgerAccount, S as DimensionBreakdownParams, T as generateDimensionBreakdown, U as ReportCategory, V as LedgerEntry, W as ReportGroup, X as AgedBalanceParams, Y as AgedBalanceOptions, Z as AgedBalanceReport, a as RevaluationReport, b as reopenFiscalPeriod, c as RevaluationRate, d as computeRevaluation, et as DEFAULT_BUCKETS, h as generateGeneralLedger, i as RevaluationParams, j as BudgetVsActualRow, k as BudgetVsActualParams, l as RevaluationResult, n as generateTrialBalance, o as generateRevaluation, p as generateIncomeStatement, q as TrialBalanceReport, r as RevaluationOptions, s as AccountForeignBalance, tt as generateAgedBalance, u as buildRevaluationEntry, w as DimensionBreakdownRow, x as DimensionBreakdownOptions, y as closeFiscalPeriod, z as GeneralLedgerReport } from "./trial-balance-DcQ0xj_4.mjs";
12
12
  import * as mongoose$1 from "mongoose";
13
13
  import { ClientSession, Connection, Model } from "mongoose";
14
14
  import { PluginType, Repository } from "@classytic/mongokit";
@@ -53,9 +53,9 @@ declare class AccountingEngine {
53
53
  [x: string]: any;
54
54
  } & mongoose$1.DefaultTimestampProps, {
55
55
  id: string;
56
- }, mongoose$1.MergeType<mongoose$1.DefaultSchemaOptions, {
56
+ }, Omit<mongoose$1.DefaultSchemaOptions, "timestamps"> & {
57
57
  timestamps: true;
58
- }>> & Omit<{
58
+ }> & Omit<{
59
59
  [x: number]: any;
60
60
  [x: string]: any;
61
61
  } & mongoose$1.DefaultTimestampProps & {
@@ -84,9 +84,9 @@ declare class AccountingEngine {
84
84
  [x: string]: any;
85
85
  } & mongoose$1.DefaultTimestampProps, {
86
86
  id: string;
87
- }, mongoose$1.MergeType<mongoose$1.DefaultSchemaOptions, {
87
+ }, Omit<mongoose$1.DefaultSchemaOptions, "timestamps"> & {
88
88
  timestamps: true;
89
- }>> & Omit<{
89
+ }> & Omit<{
90
90
  [x: number]: any;
91
91
  [x: string]: any;
92
92
  } & mongoose$1.DefaultTimestampProps & {
@@ -115,9 +115,9 @@ declare class AccountingEngine {
115
115
  [x: string]: any;
116
116
  } & mongoose$1.DefaultTimestampProps, {
117
117
  id: string;
118
- }, mongoose$1.MergeType<mongoose$1.DefaultSchemaOptions, {
118
+ }, Omit<mongoose$1.DefaultSchemaOptions, "timestamps"> & {
119
119
  timestamps: true;
120
- }>> & Omit<{
120
+ }> & Omit<{
121
121
  [x: number]: any;
122
122
  [x: string]: any;
123
123
  } & mongoose$1.DefaultTimestampProps & {
@@ -146,9 +146,9 @@ declare class AccountingEngine {
146
146
  [x: string]: any;
147
147
  } & mongoose$1.DefaultTimestampProps, {
148
148
  id: string;
149
- }, mongoose$1.MergeType<mongoose$1.DefaultSchemaOptions, {
149
+ }, Omit<mongoose$1.DefaultSchemaOptions, "timestamps"> & {
150
150
  timestamps: true;
151
- }>> & Omit<{
151
+ }> & Omit<{
152
152
  [x: number]: any;
153
153
  [x: string]: any;
154
154
  } & mongoose$1.DefaultTimestampProps & {
@@ -177,9 +177,9 @@ declare class AccountingEngine {
177
177
  [x: string]: any;
178
178
  } & mongoose$1.DefaultTimestampProps, {
179
179
  id: string;
180
- }, mongoose$1.MergeType<mongoose$1.DefaultSchemaOptions, {
180
+ }, Omit<mongoose$1.DefaultSchemaOptions, "timestamps"> & {
181
181
  timestamps: true;
182
- }>> & Omit<{
182
+ }> & Omit<{
183
183
  [x: number]: any;
184
184
  [x: string]: any;
185
185
  } & mongoose$1.DefaultTimestampProps & {
@@ -337,22 +337,6 @@ declare class AccountingEngine {
337
337
  }
338
338
  declare function createAccountingEngine(config: AccountingEngineConfig): AccountingEngine;
339
339
  //#endregion
340
- //#region src/utils/date-range.d.ts
341
- /**
342
- * Compute start/end dates from a date option + value.
343
- *
344
- * @throws {Error} If value is null/undefined/invalid for the given option
345
- *
346
- * Examples:
347
- * getDateRange('month', '2025-03') → Mar 1 – Mar 31
348
- * getDateRange('quarter', { quarter: 2, year: 2025 }) → Apr 1 – Jun 30
349
- * getDateRange('year', 2025) → Jan 1 – Dec 31
350
- * getDateRange('custom', { startDate, endDate })
351
- */
352
- declare function getDateRange(option: DateOption, value: unknown): DateRange;
353
- /** Get fiscal year start date for a given date and fiscal start month */
354
- declare function getFiscalYearStart(date: Date, fiscalStartMonth?: number): Date;
355
- //#endregion
356
340
  //#region src/utils/account-helpers.d.ts
357
341
  /**
358
342
  * Check if an account type is a virtual tax sub-account.
@@ -379,60 +363,21 @@ declare function computeEndingBalance(category: CategoryKey, totalDebit: number,
379
363
  */
380
364
  declare function buildAccountTypeMap(accountTypes: readonly AccountType[]): Map<string, AccountType>;
381
365
  //#endregion
382
- //#region src/utils/errors.d.ts
383
- /**
384
- * Typed error for the accounting package.
385
- * Carries HTTP status + machine-readable code.
386
- * Replaces all ad-hoc `(error as ...).status = N` patterns.
387
- */
388
- declare class AccountingError extends Error {
389
- readonly status: number;
390
- readonly code: string;
391
- constructor(message: string, status?: number, code?: string);
392
- }
393
- /** Convenience factory functions */
394
- declare const Errors: {
395
- readonly validation: (msg: string) => AccountingError;
396
- readonly notFound: (msg: string) => AccountingError;
397
- readonly conflict: (msg: string) => AccountingError;
398
- readonly immutable: (msg: string) => AccountingError;
399
- readonly fiscal: (msg: string) => AccountingError;
400
- };
401
- //#endregion
402
- //#region src/utils/session.d.ts
403
- interface SessionResult {
404
- session: ClientSession | null;
405
- ownSession: boolean;
406
- }
407
- /**
408
- * Acquire a session: uses external if provided, otherwise creates an internal one.
409
- * Returns { session, ownSession } so callers can commit/abort/end appropriately.
410
- *
411
- * When transactions are unavailable (no replica set / standalone), returns
412
- * session=null and the function runs without transactional safety.
413
- */
414
- declare function acquireSession(db: Connection, externalSession: ClientSession | undefined | null, logger?: Logger): Promise<SessionResult>;
415
- /**
416
- * Finalize an owned session: commit or abort, then always end.
417
- */
418
- declare function finalizeSession(session: ClientSession | null, ownSession: boolean, success: boolean): Promise<void>;
419
- //#endregion
420
- //#region src/utils/filter-builder.d.ts
366
+ //#region src/utils/date-range.d.ts
421
367
  /**
422
- * Filter Builder Sanitizes user-supplied dimension filters for aggregation pipelines.
368
+ * Compute start/end dates from a date option + value.
423
369
  *
424
- * Prevents injection of dangerous MongoDB operators while allowing
425
- * standard equality and comparison filters on custom dimension fields.
426
- */
427
- /**
428
- * Build a sanitized filter object from user-supplied dimension filters.
429
- * Blocks dangerous operators ($where, $expr, $function, etc.).
370
+ * @throws {Error} If value is null/undefined/invalid for the given option
430
371
  *
431
- * @param filters - Key-value filters (e.g. { 'journalItems.departmentId': 'dept-1' })
432
- * @returns Sanitized filter object safe for $match stages
433
- * @throws Error if a blocked operator is used
372
+ * Examples:
373
+ * getDateRange('month', '2025-03') → Mar 1 Mar 31
374
+ * getDateRange('quarter', { quarter: 2, year: 2025 }) Apr 1 – Jun 30
375
+ * getDateRange('year', 2025) → Jan 1 – Dec 31
376
+ * getDateRange('custom', { startDate, endDate })
434
377
  */
435
- declare function buildItemFilters(filters?: Record<string, unknown>): Record<string, unknown>;
378
+ declare function getDateRange(option: DateOption, value: unknown): DateRange;
379
+ /** Get fiscal year start date for a given date and fiscal start month */
380
+ declare function getFiscalYearStart(date: Date, fiscalStartMonth?: number): Date;
436
381
  //#endregion
437
382
  //#region src/utils/dimensions.d.ts
438
383
  /**
@@ -483,6 +428,61 @@ declare function buildDimensionIndexes(dimensions: DimensionDefinition[], orgFie
483
428
  options?: Record<string, unknown>;
484
429
  }>;
485
430
  //#endregion
431
+ //#region src/utils/errors.d.ts
432
+ /**
433
+ * Typed error for the accounting package.
434
+ * Carries HTTP status + machine-readable code.
435
+ * Replaces all ad-hoc `(error as ...).status = N` patterns.
436
+ */
437
+ declare class AccountingError extends Error {
438
+ readonly status: number;
439
+ readonly code: string;
440
+ constructor(message: string, status?: number, code?: string);
441
+ }
442
+ /** Convenience factory functions */
443
+ declare const Errors: {
444
+ readonly validation: (msg: string) => AccountingError;
445
+ readonly notFound: (msg: string) => AccountingError;
446
+ readonly conflict: (msg: string) => AccountingError;
447
+ readonly immutable: (msg: string) => AccountingError;
448
+ readonly fiscal: (msg: string) => AccountingError;
449
+ };
450
+ //#endregion
451
+ //#region src/utils/filter-builder.d.ts
452
+ /**
453
+ * Filter Builder — Sanitizes user-supplied dimension filters for aggregation pipelines.
454
+ *
455
+ * Prevents injection of dangerous MongoDB operators while allowing
456
+ * standard equality and comparison filters on custom dimension fields.
457
+ */
458
+ /**
459
+ * Build a sanitized filter object from user-supplied dimension filters.
460
+ * Blocks dangerous operators ($where, $expr, $function, etc.).
461
+ *
462
+ * @param filters - Key-value filters (e.g. { 'journalItems.departmentId': 'dept-1' })
463
+ * @returns Sanitized filter object safe for $match stages
464
+ * @throws Error if a blocked operator is used
465
+ */
466
+ declare function buildItemFilters(filters?: Record<string, unknown>): Record<string, unknown>;
467
+ //#endregion
468
+ //#region src/utils/session.d.ts
469
+ interface SessionResult {
470
+ session: ClientSession | null;
471
+ ownSession: boolean;
472
+ }
473
+ /**
474
+ * Acquire a session: uses external if provided, otherwise creates an internal one.
475
+ * Returns { session, ownSession } so callers can commit/abort/end appropriately.
476
+ *
477
+ * When transactions are unavailable (no replica set / standalone), returns
478
+ * session=null and the function runs without transactional safety.
479
+ */
480
+ declare function acquireSession(db: Connection, externalSession: ClientSession | undefined | null, logger?: Logger): Promise<SessionResult>;
481
+ /**
482
+ * Finalize an owned session: commit or abort, then always end.
483
+ */
484
+ declare function finalizeSession(session: ClientSession | null, ownSession: boolean, success: boolean): Promise<void>;
485
+ //#endregion
486
486
  //#region src/types/contracts.d.ts
487
487
  /** A single line produced by a subledger for posting */
488
488
  interface SubledgerJournalItem {
@@ -527,4 +527,4 @@ interface PostingResult {
527
527
  idempotencyKeys?: string[];
528
528
  }
529
529
  //#endregion
530
- export { type AccountForeignBalance, type AccountRepository, type AccountType, AccountingEngine, type AccountingEngineConfig, AccountingError, type AgedBalanceOptions, type AgedBalanceParams, type AgedBalanceReport, type AgedBalanceRow, type AgedBucketConfig, type AuditConfig, type BalanceSheetReport, type BulkCreateInput, type BulkCreateResult, CATEGORIES, CATEGORY_KEYS, CURRENCIES, type CashFlowCategory, type CashFlowReport, type CashFlowSection, type CategoryKey, type Cents, type CountryPack, type CountryPackInput, type Currency, DEFAULT_BUCKETS, type DateOption, type DateRange, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type DimensionDefinition, type EntryState, Errors, type ExportField, type ExportFieldMap, type FlatJournalRow, type GeneralLedgerAccount, type GeneralLedgerReport, type IncomeStatementReport, JOURNAL_CODES, JOURNAL_TYPES, type JournalEntryRepository, type JournalItem, type JournalSchemaOptions, type JournalType, type LedgerEntry, type Logger, type MainType, Money, type MultiCurrencyConfig, type MultiTenantConfig, type NormalBalance, type PopulatedJournalEntry, type PostOptions, type PostingContract, type PostingResult, type ReconcileParams, type ReconciliationRepository, type ReportAccount, type ReportCategory, type ReportGroup, type RevaluationOptions, type RevaluationParams, type RevaluationRate, type RevaluationReport, type RevaluationResult, type ReverseOptions, type ReverseResult, type SchemaOptions, type SeedOptions, type SeedResult, type SessionResult, type StatementType, type StrictnessConfig, type SubledgerJournalItem, type SubledgerPostingInput, type TaxCode, type TaxCodesByRegion, type TaxDetail, type TaxMetadata, type TaxReport, type TaxReportLine, type TaxReportTemplate, type TaxReturnSummary, type TotalAccountOp, type TrialBalanceReport, type TrialBalanceRow, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountSchema, createAccountingEngine, createFiscalPeriodSchema, createJournalEntrySchema, dateLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, generateAgedBalance, generateBalanceSheet, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, getCurrency, getDateRange, getFiscalYearStart, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, quickbooksFieldMap, reopenFiscalPeriod, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
530
+ export { type AccountForeignBalance, type AccountRepository, type AccountType, AccountingEngine, type AccountingEngineConfig, AccountingError, 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 Currency, DEFAULT_BUCKETS, type DateOption, type DateRange, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type DimensionDefinition, type EntryState, Errors, type ExportField, type ExportFieldMap, type FlatJournalRow, type GeneralLedgerAccount, type GeneralLedgerReport, type IncomeStatementReport, JOURNAL_CODES, JOURNAL_TYPES, type JournalEntryRepository, type JournalItem, type JournalSchemaOptions, type JournalType, type LedgerEntry, type Logger, type MainType, Money, type MultiCurrencyConfig, type MultiTenantConfig, type NormalBalance, type PopulatedJournalEntry, type PostOptions, type PostingContract, type PostingResult, type ReconcileParams, type ReconciliationRepository, type ReportAccount, type ReportCategory, type ReportGroup, type RevaluationOptions, type RevaluationParams, type RevaluationRate, type RevaluationReport, type RevaluationResult, type ReverseOptions, type ReverseResult, type SchemaOptions, type SeedOptions, type SeedResult, type SessionResult, type StatementType, type StrictnessConfig, type SubledgerJournalItem, type SubledgerPostingInput, type TaxCode, type TaxCodesByRegion, type TaxDetail, type TaxMetadata, type TaxReport, type TaxReportLine, type TaxReportTemplate, type TaxReturnSummary, type TotalAccountOp, type TrialBalanceReport, type TrialBalanceRow, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountSchema, createAccountingEngine, createFiscalPeriodSchema, createJournalEntrySchema, dateLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, getCurrency, getCustomJournalTypes, getDateRange, getFiscalYearStart, getJournalType, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, quickbooksFieldMap, registerJournalType, reopenFiscalPeriod, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- import { a as createAccountSchema, i as createJournalEntrySchema, n as createBudgetSchema, r as createFiscalPeriodSchema, t as createReconciliationSchema } from "./reconciliation.schema-BuetvZTd.mjs";
2
- import { a as isValidJournalType, i as getJournalTypeCodes, n as JOURNAL_TYPES, t as JOURNAL_CODES } from "./journals-oH-FK3g8.mjs";
3
- import { C as getDateRange, S as buildItemFilters, _ as buildAccountTypeMap, a as defaultLogger, b as isVirtualTaxAccount, c as computeRevaluation, d as DEFAULT_BUCKETS, f as generateAgedBalance, g as generateBalanceSheet, h as generateIncomeStatement, i as finalizeSession, l as generateBudgetVsActual, m as generateGeneralLedger, n as reopenFiscalPeriod, o as generateRevaluation, p as generateCashFlow, r as acquireSession, s as buildRevaluationEntry, t as closeFiscalPeriod, u as generateDimensionBreakdown, v as calculateTotal, w as getFiscalYearStart, x as generateTrialBalance, y as computeEndingBalance } from "./fiscal-close-B6LhQ10f.mjs";
4
- import { n as Errors, t as AccountingError } from "./errors-B7yC-Jfw.mjs";
5
- import { c as getNormalBalance, d as isValidCategory, l as isBalanceSheet, n as CATEGORY_KEYS, t as CATEGORIES, u as isIncomeStatement } from "./categories-CclX7Q94.mjs";
6
- import { n as wireJournalEntryMethods, r as wireReconciliationMethods, t as wireAccountMethods } from "./account.repository-BpkSd6q3.mjs";
7
1
  import { Money, add, allocate, format, formatPlain, fromDecimal, multiply, parseCents, percentage, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal } from "./money.mjs";
8
- import { i as doubleEntryPlugin, n as idempotencyPlugin, r as fiscalLockPlugin, t as dateLockPlugin } from "./date-lock.plugin-eYAJ9h_u.mjs";
2
+ import { n as Errors, t as AccountingError } from "./errors-BoGUSUYL.mjs";
3
+ import { i as doubleEntryPlugin, n as idempotencyPlugin, r as fiscalLockPlugin, t as dateLockPlugin } from "./date-lock.plugin-C8kqPBjh.mjs";
4
+ import { C as DEFAULT_BUCKETS, S as isVirtualTaxAccount, _ as getDateRange, a as defaultLogger, b as calculateTotal, c as buildRevaluationEntry, d as generateGeneralLedger, f as generateDimensionBreakdown, g as buildItemFilters, h as generateBalanceSheet, i as finalizeSession, l as computeRevaluation, m as generateBudgetVsActual, n as reopenFiscalPeriod, o as generateTrialBalance, p as generateCashFlow, r as acquireSession, s as generateRevaluation, t as closeFiscalPeriod, u as generateIncomeStatement, v as getFiscalYearStart, w as generateAgedBalance, x as computeEndingBalance, y as buildAccountTypeMap } from "./fiscal-close-DmPV82e4.mjs";
5
+ import { c as getNormalBalance, d as isValidCategory, l as isBalanceSheet, n as CATEGORY_KEYS, t as CATEGORIES, u as isIncomeStatement } from "./categories-FJlrvzcl.mjs";
6
+ import { n as wireJournalEntryMethods, r as wireAccountMethods, t as wireReconciliationMethods } from "./reconciliation.repository-DgJEDVS-.mjs";
7
+ import { a as createAccountSchema, i as createBudgetSchema, n as createJournalEntrySchema, r as createFiscalPeriodSchema, t as createReconciliationSchema } from "./reconciliation.schema-KScbsXbY.mjs";
8
+ import { a as getJournalType, c as registerJournalType, i as getCustomJournalTypes, n as JOURNAL_TYPES, o as getJournalTypeCodes, s as isValidJournalType, t as JOURNAL_CODES } from "./journals-BcMn71Cq.mjs";
9
9
  import { i as isValidCurrency, n as getCurrency, r as getMinorUnit, t as CURRENCIES } from "./currencies-W8kQAkm0.mjs";
10
10
  import { defineCountryPack } from "./country/index.mjs";
11
- import { a as exportToCsv, n as quickbooksFieldMap, r as flattenJournalEntries, t as universalFieldMap } from "./exports-I5Xkq-9_.mjs";
11
+ import { a as exportToCsv, i as quickbooksFieldMap, r as universalFieldMap, t as flattenJournalEntries } from "./exports-DoGQQtMQ.mjs";
12
12
  import { Schema } from "mongoose";
13
13
  //#region src/engine.ts
14
14
  var AccountingEngine = class {
@@ -265,4 +265,4 @@ function buildDimensionIndexes(dimensions, orgField) {
265
265
  });
266
266
  }
267
267
  //#endregion
268
- export { AccountingEngine, AccountingError, CATEGORIES, CATEGORY_KEYS, CURRENCIES, DEFAULT_BUCKETS, Errors, JOURNAL_CODES, JOURNAL_TYPES, Money, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountSchema, createAccountingEngine, createFiscalPeriodSchema, createJournalEntrySchema, dateLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, generateAgedBalance, generateBalanceSheet, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, getCurrency, getDateRange, getFiscalYearStart, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, quickbooksFieldMap, reopenFiscalPeriod, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
268
+ export { AccountingEngine, AccountingError, CATEGORIES, CATEGORY_KEYS, CURRENCIES, DEFAULT_BUCKETS, Errors, JOURNAL_CODES, JOURNAL_TYPES, Money, acquireSession, add, allocate, buildAccountTypeMap, buildDimensionFields, buildDimensionIndexes, buildItemFilters, buildRevaluationEntry, calculateTotal, closeFiscalPeriod, computeEndingBalance, computeRevaluation, createAccountSchema, createAccountingEngine, createFiscalPeriodSchema, createJournalEntrySchema, dateLockPlugin, defaultLogger, defineCountryPack, doubleEntryPlugin, exportToCsv, finalizeSession, fiscalLockPlugin, flattenJournalEntries, format, formatPlain, fromDecimal, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, getCurrency, getCustomJournalTypes, getDateRange, getFiscalYearStart, getJournalType, getJournalTypeCodes, getMinorUnit, getNormalBalance, idempotencyPlugin, isBalanceSheet, isIncomeStatement, isValidCategory, isValidCurrency, isValidJournalType, isVirtualTaxAccount, multiply, parseCents, percentage, quickbooksFieldMap, registerJournalType, reopenFiscalPeriod, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
@@ -1,4 +1,4 @@
1
- import { o as SchemaOptions, r as JournalSchemaOptions, t as AccountingEngineConfig } from "./engine-Cn-9yerQ.mjs";
1
+ import { o as SchemaOptions, r as JournalSchemaOptions, t as AccountingEngineConfig } from "./engine-DF-MtsEr.mjs";
2
2
  import mongoose from "mongoose";
3
3
 
4
4
  //#region src/schemas/account.schema.d.ts
@@ -12,9 +12,9 @@ declare function createAccountSchema(config: AccountingEngineConfig, options?: S
12
12
  [x: string]: any;
13
13
  } & mongoose.DefaultTimestampProps, {
14
14
  id: string;
15
- }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
15
+ }, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
16
16
  timestamps: true;
17
- }>> & Omit<{
17
+ }> & Omit<{
18
18
  [x: number]: any;
19
19
  [x: string]: any;
20
20
  } & mongoose.DefaultTimestampProps & {
@@ -34,8 +34,8 @@ declare function createAccountSchema(config: AccountingEngineConfig, options?: S
34
34
  __v: number;
35
35
  }>;
36
36
  //#endregion
37
- //#region src/schemas/journal-entry.schema.d.ts
38
- declare function createJournalEntrySchema(config: AccountingEngineConfig, accountModelName: string, options?: JournalSchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
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
39
  timestamps: true;
40
40
  }, {
41
41
  [x: number]: any;
@@ -45,9 +45,9 @@ declare function createJournalEntrySchema(config: AccountingEngineConfig, accoun
45
45
  [x: string]: any;
46
46
  } & mongoose.DefaultTimestampProps, {
47
47
  id: string;
48
- }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
48
+ }, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
49
49
  timestamps: true;
50
- }>> & Omit<{
50
+ }> & Omit<{
51
51
  [x: number]: any;
52
52
  [x: string]: any;
53
53
  } & mongoose.DefaultTimestampProps & {
@@ -67,8 +67,8 @@ declare function createJournalEntrySchema(config: AccountingEngineConfig, accoun
67
67
  __v: number;
68
68
  }>;
69
69
  //#endregion
70
- //#region src/schemas/fiscal-period.schema.d.ts
71
- declare function createFiscalPeriodSchema(config: AccountingEngineConfig, options?: SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
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
72
  timestamps: true;
73
73
  }, {
74
74
  [x: number]: any;
@@ -78,9 +78,9 @@ declare function createFiscalPeriodSchema(config: AccountingEngineConfig, option
78
78
  [x: string]: any;
79
79
  } & mongoose.DefaultTimestampProps, {
80
80
  id: string;
81
- }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
81
+ }, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
82
82
  timestamps: true;
83
- }>> & Omit<{
83
+ }> & Omit<{
84
84
  [x: number]: any;
85
85
  [x: string]: any;
86
86
  } & mongoose.DefaultTimestampProps & {
@@ -100,4 +100,4 @@ declare function createFiscalPeriodSchema(config: AccountingEngineConfig, option
100
100
  __v: number;
101
101
  }>;
102
102
  //#endregion
103
- export { createJournalEntrySchema as n, createAccountSchema as r, createFiscalPeriodSchema as t };
103
+ export { createFiscalPeriodSchema as n, createAccountSchema as r, createJournalEntrySchema as t };
@@ -77,14 +77,37 @@ const JOURNAL_TYPES = Object.freeze({
77
77
  }
78
78
  });
79
79
  const JOURNAL_CODES = Object.freeze(Object.fromEntries(Object.keys(JOURNAL_TYPES).map((k) => [k, k])));
80
+ const _customTypes = {};
81
+ let _frozen = false;
82
+ /**
83
+ * Register a custom journal type. Must be called **before** schema
84
+ * initialization (`createJournalEntrySchema`). Custom types are
85
+ * automatically included in Mongoose enum validation and all lookup
86
+ * functions.
87
+ */
88
+ function registerJournalType(code, def) {
89
+ if (_frozen) throw new Error("Cannot register journal types after schema initialization");
90
+ if (code in JOURNAL_TYPES) throw new Error(`Cannot override built-in journal type: ${code}`);
91
+ if (def.code !== code) throw new Error(`Journal type code mismatch: key="${code}" but def.code="${def.code}"`);
92
+ if (!def.name || !def.description) throw new Error(`Journal type "${code}" requires non-empty name and description`);
93
+ _customTypes[code] = def;
94
+ }
95
+ /** Returns all custom (non-built-in) journal types. */
96
+ function getCustomJournalTypes() {
97
+ return Object.values(_customTypes);
98
+ }
99
+ /** @internal Lock the registry — called by `createJournalEntrySchema`. */
100
+ function _freezeJournalTypes() {
101
+ _frozen = true;
102
+ }
80
103
  function getJournalTypeCodes() {
81
- return Object.keys(JOURNAL_TYPES);
104
+ return [...Object.keys(JOURNAL_TYPES), ...Object.keys(_customTypes)];
82
105
  }
83
106
  function isValidJournalType(code) {
84
- return code in JOURNAL_TYPES;
107
+ return code in JOURNAL_TYPES || code in _customTypes;
85
108
  }
86
109
  function getJournalType(code) {
87
- return JOURNAL_TYPES[code] ?? null;
110
+ return JOURNAL_TYPES[code] ?? _customTypes[code] ?? null;
88
111
  }
89
112
  //#endregion
90
- export { isValidJournalType as a, getJournalTypeCodes as i, JOURNAL_TYPES as n, getJournalType as r, JOURNAL_CODES as t };
113
+ export { getJournalType as a, registerJournalType as c, getCustomJournalTypes as i, JOURNAL_TYPES as n, getJournalTypeCodes as o, _freezeJournalTypes as r, isValidJournalType as s, JOURNAL_CODES as t };
@@ -21,17 +21,26 @@ declare function extractMainType(key: string): MainType | null;
21
21
  /** Extract statement type from a category key string */
22
22
  declare function extractStatementType(key: string): StatementType | null;
23
23
  //#endregion
24
+ //#region src/constants/currencies.d.ts
25
+ declare const CURRENCIES: Readonly<Record<string, Currency>>;
26
+ declare function getCurrency(code: string): Currency | null;
27
+ declare function isValidCurrency(code: string): boolean;
28
+ declare function getMinorUnit(code: string): number;
29
+ //#endregion
24
30
  //#region src/constants/journals.d.ts
25
31
  declare const JOURNAL_TYPES: Readonly<Record<string, JournalType>>;
26
32
  declare const JOURNAL_CODES: Readonly<Record<string, string>>;
33
+ /**
34
+ * Register a custom journal type. Must be called **before** schema
35
+ * initialization (`createJournalEntrySchema`). Custom types are
36
+ * automatically included in Mongoose enum validation and all lookup
37
+ * functions.
38
+ */
39
+ declare function registerJournalType(code: string, def: JournalType): void;
40
+ /** Returns all custom (non-built-in) journal types. */
41
+ declare function getCustomJournalTypes(): JournalType[];
27
42
  declare function getJournalTypeCodes(): string[];
28
43
  declare function isValidJournalType(code: string): boolean;
29
44
  declare function getJournalType(code: string): JournalType | null;
30
45
  //#endregion
31
- //#region src/constants/currencies.d.ts
32
- declare const CURRENCIES: Readonly<Record<string, Currency>>;
33
- declare function getCurrency(code: string): Currency | null;
34
- declare function isValidCurrency(code: string): boolean;
35
- declare function getMinorUnit(code: string): number;
36
- //#endregion
37
- export { getNormalBalance as _, JOURNAL_CODES as a, isValidCategory as b, getJournalTypeCodes as c, CATEGORY_KEYS as d, categoryKey as f, getCategoryStatementType as g, getCategoryMainType as h, isValidCurrency as i, isValidJournalType as l, extractStatementType as m, getCurrency as n, JOURNAL_TYPES as o, extractMainType as p, getMinorUnit as r, getJournalType as s, CURRENCIES as t, CATEGORIES as u, isBalanceSheet as v, isIncomeStatement as y };
46
+ export { isValidCategory as S, getCategoryMainType as _, getJournalTypeCodes as a, isBalanceSheet as b, CURRENCIES as c, isValidCurrency as d, CATEGORIES as f, extractStatementType as g, extractMainType as h, getJournalType as i, getCurrency as l, categoryKey as m, JOURNAL_TYPES as n, isValidJournalType as o, CATEGORY_KEYS as p, getCustomJournalTypes as r, registerJournalType as s, JOURNAL_CODES as t, getMinorUnit as u, getCategoryStatementType as v, isIncomeStatement as x, getNormalBalance as y };
package/dist/money.mjs CHANGED
@@ -93,7 +93,7 @@ function allocate(totalCents, ratios) {
93
93
  const ratioSum = ratios.reduce((s, r) => s + r, 0);
94
94
  if (ratioSum === 0) throw new Error("Sum of ratios must be > 0");
95
95
  const allocations = ratios.map((r) => Math.floor(totalCents * r / ratioSum));
96
- let remainder = totalCents - allocations.reduce((s, a) => s + a, 0);
96
+ const remainder = totalCents - allocations.reduce((s, a) => s + a, 0);
97
97
  const fractions = ratios.map((r, i) => ({
98
98
  index: i,
99
99
  frac: totalCents * r / ratioSum - allocations[i]
@@ -166,7 +166,7 @@ function parseCents(input, minorUnit = 2) {
166
166
  if (typeof input === "number") return fromDecimal(input, minorUnit);
167
167
  const cleaned = input.replace(/[$,\s]/g, "");
168
168
  const parsed = parseFloat(cleaned);
169
- if (isNaN(parsed)) throw new Error(`Cannot parse "${input}" as money`);
169
+ if (Number.isNaN(parsed)) throw new Error(`Cannot parse "${input}" as money`);
170
170
  return fromDecimal(parsed, minorUnit);
171
171
  }
172
172
  const Money = {
@@ -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-B_CNsInz.mjs";
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-zU-GKJ0-.mjs";
2
2
  import { RepositoryInstance } from "@classytic/mongokit";
3
3
 
4
4
  //#region src/utils/tax-hooks.d.ts
@@ -1,4 +1,4 @@
1
- import { i as doubleEntryPlugin, n as idempotencyPlugin, r as fiscalLockPlugin, t as dateLockPlugin } from "../date-lock.plugin-eYAJ9h_u.mjs";
1
+ import { i as doubleEntryPlugin, n as idempotencyPlugin, r as fiscalLockPlugin, t as dateLockPlugin } from "../date-lock.plugin-C8kqPBjh.mjs";
2
2
  //#region src/utils/tax-hooks.ts
3
3
  /**
4
4
  * Apply a tax hook to journal items.
@@ -1,5 +1,5 @@
1
1
  import { t as CountryPack } from "./index-CxZqRaOU.mjs";
2
- import { s as StrictnessConfig } from "./engine-Cn-9yerQ.mjs";
2
+ import { s as StrictnessConfig } from "./engine-DF-MtsEr.mjs";
3
3
  import { ClientSession, Model } from "mongoose";
4
4
  import { Repository } from "@classytic/mongokit";
5
5
 
@@ -96,6 +96,18 @@ interface ReconciliationRepository<TDoc = unknown> extends Repository<TDoc> {
96
96
  }): Promise<Record<string, unknown>[]>;
97
97
  }
98
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
99
111
  //#region src/repositories/journal-entry.repository.d.ts
100
112
  /**
101
113
  * Wire post/reverse onto an existing mongokit Repository.
@@ -110,18 +122,6 @@ interface ReconciliationRepository<TDoc = unknown> extends Repository<TDoc> {
110
122
  */
111
123
  declare function wireJournalEntryMethods<TDoc = unknown>(repository: Repository<TDoc>, _JournalEntryModel: unknown, orgField?: string, strictness?: StrictnessConfig): JournalEntryRepository<TDoc>;
112
124
  //#endregion
113
- //#region src/repositories/account.repository.d.ts
114
- /**
115
- * Wire seedAccounts, bulkCreate and posting-account validation
116
- * onto an existing mongokit Repository.
117
- *
118
- * @param repository - A mongokit Repository instance (already created)
119
- * @param AccountModel - The Mongoose model for accounts
120
- * @param country - The CountryPack for account type lookups
121
- * @param orgField - The multi-tenant field name (e.g. 'business')
122
- */
123
- declare function wireAccountMethods<TDoc = unknown>(repository: Repository<TDoc>, AccountModel: Model<unknown>, country: CountryPack, orgField?: string): AccountRepository<TDoc>;
124
- //#endregion
125
125
  //#region src/repositories/reconciliation.repository.d.ts
126
126
  /**
127
127
  * Wire reconciliation methods onto an existing mongokit Repository.
@@ -132,4 +132,4 @@ declare function wireAccountMethods<TDoc = unknown>(repository: Repository<TDoc>
132
132
  */
133
133
  declare function wireReconciliationMethods<TDoc = unknown>(repository: Repository<TDoc>, _ReconciliationModel: Model<unknown>, JournalEntryModel: Model<unknown>, orgField?: string): ReconciliationRepository<TDoc>;
134
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, wireAccountMethods as n, BulkCreateResult as o, SeedOptions as p, wireJournalEntryMethods as r, JournalEntryRepository as s, wireReconciliationMethods as t, ReconciliationRepository as u };
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 };