@classytic/ledger 0.2.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 (70) hide show
  1. package/README.md +161 -64
  2. package/dist/{categories-CclX7Q94.mjs → categories-FJlrvzcl.mjs} +0 -2
  3. package/dist/constants/index.d.mts +2 -2
  4. package/dist/constants/index.mjs +3 -3
  5. package/dist/core-8Xfnpn6g.d.mts +1 -2
  6. package/dist/country/index.d.mts +1 -1
  7. package/dist/country/index.mjs +0 -2
  8. package/dist/currencies-W8kQAkm0.mjs +0 -2
  9. package/dist/{idempotency.plugin-v9NQ_ta-.mjs → date-lock.plugin-C8kqPBjh.mjs} +51 -11
  10. package/dist/{engine-BzBMpWuy.d.mts → engine-DF-MtsEr.d.mts} +10 -6
  11. package/dist/{errors-B7yC-Jfw.mjs → errors-BoGUSUYL.mjs} +0 -2
  12. package/dist/exports/index.d.mts +1 -1
  13. package/dist/exports/index.mjs +1 -1
  14. package/dist/{exports-I5Xkq-9_.mjs → exports-DoGQQtMQ.mjs} +96 -77
  15. package/dist/{fiscal-close-L631E3De.mjs → fiscal-close-DmPV82e4.mjs} +1000 -286
  16. package/dist/{idempotency.plugin-CPxPt4vX.d.mts → idempotency.plugin-zU-GKJ0-.d.mts} +19 -17
  17. package/dist/{index-ZnSiqHYV.d.mts → index-CxZqRaOU.d.mts} +20 -6
  18. package/dist/{index-BPukb3L8.d.mts → index-J-XIbXH-.d.mts} +7 -8
  19. package/dist/index.d.mts +280 -58
  20. package/dist/index.mjs +123 -25
  21. package/dist/journal-entry.schema-B1CzLwC3.d.mts +103 -0
  22. package/dist/{journals-oH-FK3g8.mjs → journals-BcMn71Cq.mjs} +27 -6
  23. package/dist/{currencies-4WAbFRlw.d.mts → journals-DTipb_rz.d.mts} +16 -8
  24. package/dist/logger-UbTdBb1x.d.mts +1 -2
  25. package/dist/money.d.mts +1 -2
  26. package/dist/money.mjs +5 -5
  27. package/dist/plugins/index.d.mts +38 -2
  28. package/dist/plugins/index.mjs +57 -2
  29. package/dist/reconciliation.repository-DEybU_Ok.d.mts +135 -0
  30. package/dist/{account.repository-kDKwDt0I.mjs → reconciliation.repository-DgJEDVS-.mjs} +361 -210
  31. package/dist/{fiscal-period.schema-BQ5wsAq3.mjs → reconciliation.schema-KScbsXbY.mjs} +235 -90
  32. package/dist/reports/index.d.mts +2 -2
  33. package/dist/reports/index.mjs +2 -2
  34. package/dist/repositories/index.d.mts +2 -2
  35. package/dist/repositories/index.mjs +2 -2
  36. package/dist/schemas/index.d.mts +71 -2
  37. package/dist/schemas/index.mjs +2 -2
  38. package/dist/tenant-guard-CAxXoWuS.mjs +13 -0
  39. package/dist/trial-balance-DcQ0xj_4.d.mts +530 -0
  40. package/docs/reports.md +1 -1
  41. package/package.json +14 -6
  42. package/dist/account.repository-C7gwFLfM.d.mts +0 -29
  43. package/dist/account.repository-C7gwFLfM.d.mts.map +0 -1
  44. package/dist/account.repository-kDKwDt0I.mjs.map +0 -1
  45. package/dist/categories-CclX7Q94.mjs.map +0 -1
  46. package/dist/core-8Xfnpn6g.d.mts.map +0 -1
  47. package/dist/country/index.mjs.map +0 -1
  48. package/dist/currencies-4WAbFRlw.d.mts.map +0 -1
  49. package/dist/currencies-W8kQAkm0.mjs.map +0 -1
  50. package/dist/engine-BzBMpWuy.d.mts.map +0 -1
  51. package/dist/errors-B7yC-Jfw.mjs.map +0 -1
  52. package/dist/exports-I5Xkq-9_.mjs.map +0 -1
  53. package/dist/fiscal-close-L631E3De.mjs.map +0 -1
  54. package/dist/fiscal-close-dNlzB37y.d.mts +0 -270
  55. package/dist/fiscal-close-dNlzB37y.d.mts.map +0 -1
  56. package/dist/fiscal-period.schema-BQ5wsAq3.mjs.map +0 -1
  57. package/dist/fiscal-period.schema-BRdKAjrr.d.mts +0 -38
  58. package/dist/fiscal-period.schema-BRdKAjrr.d.mts.map +0 -1
  59. package/dist/idempotency.plugin-CPxPt4vX.d.mts.map +0 -1
  60. package/dist/idempotency.plugin-v9NQ_ta-.mjs.map +0 -1
  61. package/dist/index-BPukb3L8.d.mts.map +0 -1
  62. package/dist/index-ZnSiqHYV.d.mts.map +0 -1
  63. package/dist/index.d.mts.map +0 -1
  64. package/dist/index.mjs.map +0 -1
  65. package/dist/journals-oH-FK3g8.mjs.map +0 -1
  66. package/dist/logger-UbTdBb1x.d.mts.map +0 -1
  67. package/dist/money.d.mts.map +0 -1
  68. package/dist/money.mjs.map +0 -1
  69. package/dist/session-Ba8E3Ufa.mjs +0 -84
  70. package/dist/session-Ba8E3Ufa.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { i as getJournalTypeCodes, t as JOURNAL_CODES } from "./journals-oH-FK3g8.mjs";
1
+ import { o as getJournalTypeCodes, r as _freezeJournalTypes, t as JOURNAL_CODES } from "./journals-BcMn71Cq.mjs";
2
2
  import mongoose from "mongoose";
3
3
  //#region src/schemas/currency-field.ts
4
4
  /**
@@ -70,9 +70,8 @@ function createAccountSchema(config, options = {}) {
70
70
  };
71
71
  const schema = new mongoose.Schema(fields, { timestamps: true });
72
72
  schema.pre("validate", function() {
73
- const doc = this;
74
- if (!doc.accountNumber && doc.accountTypeCode) doc.accountNumber = doc.accountTypeCode;
75
- if (!doc.name && doc.accountTypeCode) doc.name = country.getAccountType(doc.accountTypeCode)?.name ?? doc.accountTypeCode;
73
+ if (!this.accountNumber && this.accountTypeCode) this.accountNumber = this.accountTypeCode;
74
+ if (!this.name && this.accountTypeCode) this.name = country.getAccountType(this.accountTypeCode)?.name ?? this.accountTypeCode;
76
75
  });
77
76
  if (indexes) if (multiTenant) {
78
77
  const org = multiTenant.orgField;
@@ -97,6 +96,175 @@ function createAccountSchema(config, options = {}) {
97
96
  return schema;
98
97
  }
99
98
  //#endregion
99
+ //#region src/schemas/budget.schema.ts
100
+ /**
101
+ * Budget Schema Factory
102
+ *
103
+ * Creates a Mongoose schema for budget records.
104
+ * Each record represents a budgeted amount for an account over a specific period.
105
+ * All monetary amounts are in integer cents.
106
+ */
107
+ function createBudgetSchema(config, options = {}) {
108
+ const { multiTenant } = config;
109
+ const { indexes = true, extraFields = {}, extraIndexes = [] } = options;
110
+ const fields = {
111
+ account: {
112
+ type: mongoose.Schema.Types.ObjectId,
113
+ ref: "Account",
114
+ required: true
115
+ },
116
+ periodStart: {
117
+ type: Date,
118
+ required: true
119
+ },
120
+ periodEnd: {
121
+ type: Date,
122
+ required: true
123
+ },
124
+ amount: {
125
+ type: Number,
126
+ required: true,
127
+ validate: {
128
+ validator: (v) => Number.isInteger(v),
129
+ message: "amount must be an integer (cents)."
130
+ }
131
+ },
132
+ label: {
133
+ type: String,
134
+ default: null
135
+ },
136
+ ...extraFields
137
+ };
138
+ if (multiTenant) fields[multiTenant.orgField] = {
139
+ type: mongoose.Schema.Types.ObjectId,
140
+ ref: multiTenant.orgRef,
141
+ required: true
142
+ };
143
+ const schema = new mongoose.Schema(fields, { timestamps: true });
144
+ schema.pre("validate", function() {
145
+ const doc = this;
146
+ if (doc.periodStart && doc.periodEnd && doc.periodEnd <= doc.periodStart) doc.invalidate("periodEnd", "periodEnd must be after periodStart.", doc.periodEnd, "periodEnd");
147
+ });
148
+ if (indexes) if (multiTenant) {
149
+ const org = multiTenant.orgField;
150
+ schema.index({
151
+ [org]: 1,
152
+ account: 1,
153
+ periodStart: 1,
154
+ periodEnd: 1
155
+ }, { unique: true });
156
+ schema.index({
157
+ [org]: 1,
158
+ periodStart: 1,
159
+ periodEnd: 1
160
+ });
161
+ } else {
162
+ schema.index({
163
+ account: 1,
164
+ periodStart: 1,
165
+ periodEnd: 1
166
+ }, { unique: true });
167
+ schema.index({
168
+ periodStart: 1,
169
+ periodEnd: 1
170
+ });
171
+ }
172
+ for (const idx of extraIndexes) schema.index(idx.fields, idx.options);
173
+ return schema;
174
+ }
175
+ //#endregion
176
+ //#region src/schemas/fiscal-period.schema.ts
177
+ /**
178
+ * Fiscal Period Schema Factory
179
+ *
180
+ * Creates a Mongoose schema for tracking fiscal periods (months, quarters, years).
181
+ * Supports closing periods to lock entries.
182
+ */
183
+ function createFiscalPeriodSchema(config, options = {}) {
184
+ const { multiTenant } = config;
185
+ const { indexes = true, extraFields = {}, extraIndexes = [] } = options;
186
+ const fields = {
187
+ name: {
188
+ type: String,
189
+ required: true
190
+ },
191
+ startDate: {
192
+ type: Date,
193
+ required: true
194
+ },
195
+ endDate: {
196
+ type: Date,
197
+ required: true
198
+ },
199
+ closed: {
200
+ type: Boolean,
201
+ default: false
202
+ },
203
+ closedAt: {
204
+ type: Date,
205
+ default: null
206
+ },
207
+ closedBy: {
208
+ type: String,
209
+ default: null
210
+ },
211
+ closingEntryId: {
212
+ type: mongoose.Schema.Types.ObjectId,
213
+ default: null
214
+ },
215
+ reopenedAt: {
216
+ type: Date,
217
+ default: null
218
+ },
219
+ reopenedBy: {
220
+ type: String,
221
+ default: null
222
+ },
223
+ ...extraFields
224
+ };
225
+ if (multiTenant) fields[multiTenant.orgField] = {
226
+ type: mongoose.Schema.Types.ObjectId,
227
+ ref: multiTenant.orgRef,
228
+ required: true
229
+ };
230
+ const schema = new mongoose.Schema(fields, { timestamps: true });
231
+ if (indexes) if (multiTenant) {
232
+ const org = multiTenant.orgField;
233
+ schema.index({
234
+ [org]: 1,
235
+ startDate: 1,
236
+ endDate: 1
237
+ }, { unique: true });
238
+ schema.index({
239
+ [org]: 1,
240
+ closed: 1
241
+ });
242
+ } else {
243
+ schema.index({
244
+ startDate: 1,
245
+ endDate: 1
246
+ }, { unique: true });
247
+ schema.index({ closed: 1 });
248
+ }
249
+ for (const idx of extraIndexes) schema.index(idx.fields, idx.options);
250
+ schema.pre("validate", async function() {
251
+ const doc = this;
252
+ if (!doc.startDate || !doc.endDate) return;
253
+ const overlapQuery = {
254
+ _id: { $ne: doc._id },
255
+ startDate: { $lt: doc.endDate },
256
+ endDate: { $gt: doc.startDate }
257
+ };
258
+ if (multiTenant) overlapQuery[multiTenant.orgField] = doc[multiTenant.orgField];
259
+ const overlap = await doc.collection.findOne(overlapQuery);
260
+ if (overlap) {
261
+ const msg = `Fiscal period overlaps with existing period "${overlap.name}" (${new Date(overlap.startDate).toISOString().split("T")[0]} – ${new Date(overlap.endDate).toISOString().split("T")[0]}).`;
262
+ doc.invalidate("startDate", msg, doc.startDate, "overlap");
263
+ }
264
+ });
265
+ return schema;
266
+ }
267
+ //#endregion
100
268
  //#region src/schemas/journal-entry.schema.ts
101
269
  /**
102
270
  * Journal Entry Schema Factory
@@ -172,11 +340,12 @@ function createJournalEntrySchema(config, accountModelName, options = {}) {
172
340
  ...currencyItemFields,
173
341
  ...extraItemFields
174
342
  }, { _id: false });
343
+ _freezeJournalTypes();
175
344
  const fields = {
176
345
  journalType: {
177
346
  type: String,
178
347
  enum: getJournalTypeCodes(),
179
- default: JOURNAL_CODES["MISC"],
348
+ default: JOURNAL_CODES.MISC,
180
349
  required: true
181
350
  },
182
351
  referenceNumber: { type: String },
@@ -275,22 +444,21 @@ function createJournalEntrySchema(config, accountModelName, options = {}) {
275
444
  };
276
445
  const schema = new mongoose.Schema(fields, { timestamps: true });
277
446
  schema.pre("validate", function() {
278
- const doc = this;
279
- for (const item of doc.journalItems) if (!item.date) item.date = doc.date;
280
- for (let i = 0; i < doc.journalItems.length; i++) {
281
- const d = doc.journalItems[i].debit || 0;
282
- const c = doc.journalItems[i].credit || 0;
447
+ for (const item of this.journalItems) if (!item.date) item.date = this.date;
448
+ for (let i = 0; i < this.journalItems.length; i++) {
449
+ const d = this.journalItems[i].debit ?? 0;
450
+ const c = this.journalItems[i].credit ?? 0;
283
451
  if (d > 0 && c > 0) throw new Error(`Journal item at index ${i}: cannot have both debit (${d}) and credit (${c}) greater than zero`);
284
- if (doc.state === "posted" && d === 0 && c === 0) throw new Error(`Journal item at index ${i}: posted entries cannot have zero-value lines (both debit and credit are 0)`);
452
+ if (this.state === "posted" && d === 0 && c === 0) throw new Error(`Journal item at index ${i}: posted entries cannot have zero-value lines (both debit and credit are 0)`);
285
453
  }
286
- const totalDebit = doc.journalItems.reduce((s, i) => s + (i.debit || 0), 0);
287
- const totalCredit = doc.journalItems.reduce((s, i) => s + (i.credit || 0), 0);
288
- if (doc.state === "posted") {
289
- if (doc.journalItems.length < 2) throw new Error("Posted entries must have at least 2 journal items");
454
+ const totalDebit = this.journalItems.reduce((s, item) => s + (item.debit ?? 0), 0);
455
+ const totalCredit = this.journalItems.reduce((s, item) => s + (item.credit ?? 0), 0);
456
+ if (this.state === "posted") {
457
+ if (this.journalItems.length < 2) throw new Error("Posted entries must have at least 2 journal items");
290
458
  if (totalDebit !== totalCredit) throw new Error("Total debit must equal total credit for posted entries");
291
459
  }
292
- doc.totalDebit = totalDebit;
293
- doc.totalCredit = totalCredit;
460
+ this.totalDebit = totalDebit;
461
+ this.totalCredit = totalCredit;
294
462
  });
295
463
  if (autoReference) {
296
464
  const generateReferenceNumber = async (doc, Model, session) => {
@@ -312,16 +480,15 @@ function createJournalEntrySchema(config, accountModelName, options = {}) {
312
480
  return `${prefix}${String(seq).padStart(4, "0")}`;
313
481
  };
314
482
  schema.pre("save", async function() {
315
- const doc = this;
316
- if (doc.isModified("journalType")) doc.referenceNumber = void 0;
317
- if (!doc.referenceNumber) {
318
- const session = doc.$session?.() ?? null;
319
- const Model = doc.constructor;
320
- doc.referenceNumber = await generateReferenceNumber(doc, Model, session);
483
+ if (this.isModified("journalType")) this.referenceNumber = void 0;
484
+ if (!this.referenceNumber) {
485
+ const session = this.$session?.() ?? null;
486
+ const Model = this.constructor;
487
+ this.referenceNumber = await generateReferenceNumber(this, Model, session);
321
488
  }
322
489
  });
323
490
  const MAX_REF_RETRIES = 3;
324
- schema.post("save", async function(error, doc, next) {
491
+ schema.post("save", async (error, doc, next) => {
325
492
  const mongoError = error;
326
493
  if (mongoError.code === 11e3 && mongoError.keyPattern?.referenceNumber) {
327
494
  const entry = doc;
@@ -424,52 +591,51 @@ function createJournalEntrySchema(config, accountModelName, options = {}) {
424
591
  return schema;
425
592
  }
426
593
  //#endregion
427
- //#region src/schemas/fiscal-period.schema.ts
594
+ //#region src/schemas/reconciliation.schema.ts
428
595
  /**
429
- * Fiscal Period Schema Factory
596
+ * Reconciliation Schema Factory
430
597
  *
431
- * Creates a Mongoose schema for tracking fiscal periods (months, quarters, years).
432
- * Supports closing periods to lock entries.
598
+ * Creates a Mongoose schema for reconciliation records that link matched
599
+ * debit/credit journal items. Used to track which journal entries have been
600
+ * reconciled against each other for a given account.
433
601
  */
434
- function createFiscalPeriodSchema(config, options = {}) {
602
+ function createReconciliationSchema(config, accountModelName, journalEntryModelName, options = {}) {
435
603
  const { multiTenant } = config;
436
604
  const { indexes = true, extraFields = {}, extraIndexes = [] } = options;
437
605
  const fields = {
438
- name: {
439
- type: String,
606
+ account: {
607
+ type: mongoose.Schema.Types.ObjectId,
608
+ ref: accountModelName,
440
609
  required: true
441
610
  },
442
- startDate: {
443
- type: Date,
444
- required: true
611
+ journalEntryIds: {
612
+ type: [{
613
+ type: mongoose.Schema.Types.ObjectId,
614
+ ref: journalEntryModelName
615
+ }],
616
+ required: true,
617
+ validate: {
618
+ validator: (v) => Array.isArray(v) && v.length > 0,
619
+ message: "journalEntryIds must contain at least one entry."
620
+ }
445
621
  },
446
- endDate: {
447
- type: Date,
622
+ debitTotal: {
623
+ type: Number,
448
624
  required: true
449
625
  },
450
- closed: {
451
- type: Boolean,
452
- default: false
453
- },
454
- closedAt: {
455
- type: Date,
456
- default: null
457
- },
458
- closedBy: {
459
- type: String,
460
- default: null
626
+ creditTotal: {
627
+ type: Number,
628
+ required: true
461
629
  },
462
- closingEntryId: {
463
- type: mongoose.Schema.Types.ObjectId,
464
- default: null
630
+ difference: {
631
+ type: Number,
632
+ default: 0
465
633
  },
466
- reopenedAt: {
634
+ note: { type: String },
635
+ reconciledBy: { type: String },
636
+ reconciledAt: {
467
637
  type: Date,
468
- default: null
469
- },
470
- reopenedBy: {
471
- type: String,
472
- default: null
638
+ default: Date.now
473
639
  },
474
640
  ...extraFields
475
641
  };
@@ -479,43 +645,22 @@ function createFiscalPeriodSchema(config, options = {}) {
479
645
  required: true
480
646
  };
481
647
  const schema = new mongoose.Schema(fields, { timestamps: true });
482
- if (indexes) if (multiTenant) {
483
- const org = multiTenant.orgField;
484
- schema.index({
485
- [org]: 1,
486
- startDate: 1,
487
- endDate: 1
488
- }, { unique: true });
489
- schema.index({
490
- [org]: 1,
491
- closed: 1
648
+ if (indexes) {
649
+ if (multiTenant) {
650
+ const org = multiTenant.orgField;
651
+ schema.index({
652
+ [org]: 1,
653
+ account: 1,
654
+ reconciledAt: 1
655
+ });
656
+ } else schema.index({
657
+ account: 1,
658
+ reconciledAt: 1
492
659
  });
493
- } else {
494
- schema.index({
495
- startDate: 1,
496
- endDate: 1
497
- }, { unique: true });
498
- schema.index({ closed: 1 });
660
+ schema.index({ journalEntryIds: 1 });
499
661
  }
500
662
  for (const idx of extraIndexes) schema.index(idx.fields, idx.options);
501
- schema.pre("validate", async function() {
502
- const doc = this;
503
- if (!doc.startDate || !doc.endDate) return;
504
- const overlapQuery = {
505
- _id: { $ne: doc._id },
506
- startDate: { $lt: doc.endDate },
507
- endDate: { $gt: doc.startDate }
508
- };
509
- if (multiTenant) overlapQuery[multiTenant.orgField] = doc[multiTenant.orgField];
510
- const overlap = await doc.collection.findOne(overlapQuery);
511
- if (overlap) {
512
- const msg = `Fiscal period overlaps with existing period "${overlap.name}" (${new Date(overlap.startDate).toISOString().split("T")[0]} – ${new Date(overlap.endDate).toISOString().split("T")[0]}).`;
513
- doc.invalidate("startDate", msg, doc.startDate, "overlap");
514
- }
515
- });
516
663
  return schema;
517
664
  }
518
665
  //#endregion
519
- export { createJournalEntrySchema as n, createAccountSchema as r, createFiscalPeriodSchema as t };
520
-
521
- //# sourceMappingURL=fiscal-period.schema-BQ5wsAq3.mjs.map
666
+ export { createAccountSchema as a, createBudgetSchema as i, createJournalEntrySchema as n, createFiscalPeriodSchema as r, createReconciliationSchema as t };
@@ -1,2 +1,2 @@
1
- import { a as reopenFiscalPeriod, c as GeneralLedgerOptions, d as generateIncomeStatement, f as BalanceSheetOptions, h as generateTrialBalance, i as closeFiscalPeriod, l as generateGeneralLedger, m as TrialBalanceOptions, n as FiscalCloseResult, o as CashFlowOptions, p as generateBalanceSheet, r as FiscalReopenResult, s as generateCashFlow, t as FiscalCloseOptions, u as IncomeStatementOptions } from "../fiscal-close-dNlzB37y.mjs";
2
- export { type BalanceSheetOptions, type CashFlowOptions, type FiscalCloseOptions, type FiscalCloseResult, type FiscalReopenResult, type GeneralLedgerOptions, type IncomeStatementOptions, type TrialBalanceOptions, closeFiscalPeriod, generateBalanceSheet, generateCashFlow, generateGeneralLedger, generateIncomeStatement, generateTrialBalance, reopenFiscalPeriod };
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-DcQ0xj_4.mjs";
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 };
@@ -1,2 +1,2 @@
1
- import { a as generateIncomeStatement, d as generateTrialBalance, i as generateGeneralLedger, n as reopenFiscalPeriod, o as generateBalanceSheet, r as generateCashFlow, t as closeFiscalPeriod } from "../fiscal-close-L631E3De.mjs";
2
- export { closeFiscalPeriod, generateBalanceSheet, generateCashFlow, generateGeneralLedger, generateIncomeStatement, generateTrialBalance, reopenFiscalPeriod };
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-DmPV82e4.mjs";
2
+ export { DEFAULT_BUCKETS, closeFiscalPeriod, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generateRevaluation, generateTrialBalance, reopenFiscalPeriod };
@@ -1,2 +1,2 @@
1
- import { n as wireJournalEntryMethods, t as wireAccountMethods } from "../account.repository-C7gwFLfM.mjs";
2
- export { wireAccountMethods, wireJournalEntryMethods };
1
+ import { n as wireJournalEntryMethods, r as wireAccountMethods, t as wireReconciliationMethods } from "../reconciliation.repository-DEybU_Ok.mjs";
2
+ export { wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
@@ -1,2 +1,2 @@
1
- import { n as wireJournalEntryMethods, t as wireAccountMethods } from "../account.repository-kDKwDt0I.mjs";
2
- export { wireAccountMethods, wireJournalEntryMethods };
1
+ import { n as wireJournalEntryMethods, r as wireAccountMethods, t as wireReconciliationMethods } from "../reconciliation.repository-DgJEDVS-.mjs";
2
+ export { wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
@@ -1,2 +1,71 @@
1
- import { n as createJournalEntrySchema, r as createAccountSchema, t as createFiscalPeriodSchema } from "../fiscal-period.schema-BRdKAjrr.mjs";
2
- export { createAccountSchema, createFiscalPeriodSchema, createJournalEntrySchema };
1
+ import { o as SchemaOptions, t as AccountingEngineConfig } from "../engine-DF-MtsEr.mjs";
2
+ import { n as createFiscalPeriodSchema, r as createAccountSchema, t as createJournalEntrySchema } from "../journal-entry.schema-B1CzLwC3.mjs";
3
+ import mongoose from "mongoose";
4
+
5
+ //#region src/schemas/budget.schema.d.ts
6
+ declare function createBudgetSchema(config: AccountingEngineConfig, options?: SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
7
+ timestamps: true;
8
+ }, {
9
+ [x: number]: any;
10
+ [x: string]: any;
11
+ } & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
12
+ [x: number]: any;
13
+ [x: string]: any;
14
+ } & mongoose.DefaultTimestampProps, {
15
+ id: string;
16
+ }, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
17
+ timestamps: true;
18
+ }> & Omit<{
19
+ [x: number]: any;
20
+ [x: string]: any;
21
+ } & mongoose.DefaultTimestampProps & {
22
+ _id: mongoose.Types.ObjectId;
23
+ } & {
24
+ __v: number;
25
+ }, "id"> & {
26
+ id: string;
27
+ }, unknown, {
28
+ [x: number]: any;
29
+ [x: string]: any;
30
+ createdAt: NativeDate;
31
+ updatedAt: NativeDate;
32
+ } & {
33
+ _id: mongoose.Types.ObjectId;
34
+ } & {
35
+ __v: number;
36
+ }>;
37
+ //#endregion
38
+ //#region src/schemas/reconciliation.schema.d.ts
39
+ declare function createReconciliationSchema(config: AccountingEngineConfig, accountModelName: string, journalEntryModelName: string, options?: SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
40
+ timestamps: true;
41
+ }, {
42
+ [x: number]: any;
43
+ [x: string]: any;
44
+ } & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
45
+ [x: number]: any;
46
+ [x: string]: any;
47
+ } & mongoose.DefaultTimestampProps, {
48
+ id: string;
49
+ }, Omit<mongoose.DefaultSchemaOptions, "timestamps"> & {
50
+ timestamps: true;
51
+ }> & Omit<{
52
+ [x: number]: any;
53
+ [x: string]: any;
54
+ } & mongoose.DefaultTimestampProps & {
55
+ _id: mongoose.Types.ObjectId;
56
+ } & {
57
+ __v: number;
58
+ }, "id"> & {
59
+ id: string;
60
+ }, unknown, {
61
+ [x: number]: any;
62
+ [x: string]: any;
63
+ createdAt: NativeDate;
64
+ updatedAt: NativeDate;
65
+ } & {
66
+ _id: mongoose.Types.ObjectId;
67
+ } & {
68
+ __v: number;
69
+ }>;
70
+ //#endregion
71
+ export { createAccountSchema, createBudgetSchema, createFiscalPeriodSchema, createJournalEntrySchema, createReconciliationSchema };
@@ -1,2 +1,2 @@
1
- import { n as createJournalEntrySchema, r as createAccountSchema, t as createFiscalPeriodSchema } from "../fiscal-period.schema-BQ5wsAq3.mjs";
2
- export { createAccountSchema, createFiscalPeriodSchema, createJournalEntrySchema };
1
+ import { a as createAccountSchema, i as createBudgetSchema, n as createJournalEntrySchema, r as createFiscalPeriodSchema, t as createReconciliationSchema } from "../reconciliation.schema-KScbsXbY.mjs";
2
+ export { createAccountSchema, createBudgetSchema, createFiscalPeriodSchema, createJournalEntrySchema, createReconciliationSchema };
@@ -0,0 +1,13 @@
1
+ import { n as Errors } from "./errors-BoGUSUYL.mjs";
2
+ //#region src/utils/tenant-guard.ts
3
+ /**
4
+ * Multi-tenant scope guard.
5
+ *
6
+ * Throws when orgField is configured (multi-tenant mode active) but
7
+ * organizationId is missing — preventing unscoped cross-tenant queries.
8
+ */
9
+ function requireOrgScope(orgField, organizationId) {
10
+ if (orgField && !organizationId) throw Errors.validation("organizationId is required when multi-tenant mode is configured (orgField: \"" + orgField + "\"). Refusing to run unscoped query.");
11
+ }
12
+ //#endregion
13
+ export { requireOrgScope as t };