@classytic/ledger 0.12.0 → 0.12.2
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/dist/index.d.mts +1 -1
- package/dist/index.mjs +20 -7
- package/dist/{partner-ledger-B0eym6Ss.mjs → partner-ledger-BvcE1gJp.mjs} +4 -1
- package/dist/reports/index.d.mts +1 -1
- package/dist/reports/index.mjs +1 -1
- package/dist/{trial-balance-CdslY4pl.d.mts → trial-balance-Dy_fAeJV.d.mts} +2 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { i as defineCountryPack, n as CountryPackInput, r as JournalTemplate, t
|
|
|
5
5
|
import { $ as ReconciliationUnmatchedPayload, A as LedgerEventDefinition, B as InProcessLedgerBusOptions, E as EntryUnposted, F as ReconciliationUnmatched, G as EntryArchivedPayload, H as createEvent, J as EntryPostedPayload, K as EntryCreatedPayload, L as ledgerEventDefinitions, M as LedgerEventSchema, N as ReconciliationMatched, O as JournalSeeded, Q as ReconciliationMatchedPayload, R as EventLogger, S as EntryPosted, U as AccountBulkCreatedPayload, V as EventContext, W as AccountSeededPayload, X as EntryUnpostedPayload, Y as EntryReversedPayload, Z as JournalSeededPayload, a as OutboxFailOptions, b as EntryDuplicated, c as OutboxFailurePolicy, d as OutboxWriteOptions, et as LEDGER_EVENTS, f as AccountBulkCreated, g as EntryArchived, i as OutboxErrorInfo, j as LedgerEventPayloadOf, l as OutboxOwnershipError, m as AccountSeeded, n as OutboxAcknowledgeOptions, o as OutboxFailureContext, q as EntryDuplicatedPayload, r as OutboxClaimOptions, s as OutboxFailureDecision, t as InvalidOutboxEventError, tt as LedgerEventName, u as OutboxStore, v as EntryCreated, w as EntryReversed, z as InProcessLedgerBus } from "./outbox-store-CPLeocPg.mjs";
|
|
6
6
|
import { _ as PopulatedJournalEntry, a as exportToCsv, h as FlatJournalRow, i as quickbooksFieldMap, m as ExportFieldMap, p as ExportField, r as universalFieldMap, t as flattenJournalEntries } from "./index-pRW5cZhF.mjs";
|
|
7
7
|
import { Money, abs, add, allocate, equals, format, formatPlain, fromDecimal, isNegative, isPositive, isValid, isZero, max, min, multiply, negate, parseCents, percentage, round, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal } from "./money.mjs";
|
|
8
|
-
import { $ as GeneralLedgerAccount, A as generateDimensionBreakdown, B as AgedBalanceOptions, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as DEFAULT_BUCKETS, H as AgedBalanceReport, I as BudgetVsActualRow, J as BalanceSheetReport, K as generateAgedBalance, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, Q as ComparativeMode, T as reopenFiscalPeriod, U as AgedBalanceRow, V as AgedBalanceParams, W as AgedBucketConfig, X as CashFlowReport, Y as BalanceSheetSection, Z as CashFlowSection, a as RevaluationReport, at as PeriodColumn, b as generateGeneralLedger, c as RevaluationRate, ct as ReportGroup, d as computeRevaluation, dt as TrialBalanceColumnRow, et as GeneralLedgerReport, f as PartnerLedgerLine, ft as TrialBalanceReport, g as generatePartnerLedger, h as PartnerLedgerReport, ht as defaultLogger, i as RevaluationParams, it as LedgerEntry, k as DimensionBreakdownRow, l as RevaluationResult, lt as ReportLine, m as PartnerLedgerParams, mt as Logger, n as generateTrialBalance, nt as IncomeStatementReport, o as generateRevaluation, ot as ReportAccount, p as PartnerLedgerOptions, pt as TrialBalanceRow, q as BalanceSheetLineSource, r as RevaluationOptions, rt as IncomeStatementSection, s as AccountForeignBalance, st as ReportCategory, tt as IncomeStatementLineSource, u as buildRevaluationEntry, ut as ReportSection, v as generateIncomeStatement, vt as DaybookParams, w as closeFiscalPeriod, yt as DaybookReport, z as generateBalanceSheet } from "./trial-balance-
|
|
8
|
+
import { $ as GeneralLedgerAccount, A as generateDimensionBreakdown, B as AgedBalanceOptions, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as DEFAULT_BUCKETS, H as AgedBalanceReport, I as BudgetVsActualRow, J as BalanceSheetReport, K as generateAgedBalance, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, Q as ComparativeMode, T as reopenFiscalPeriod, U as AgedBalanceRow, V as AgedBalanceParams, W as AgedBucketConfig, X as CashFlowReport, Y as BalanceSheetSection, Z as CashFlowSection, a as RevaluationReport, at as PeriodColumn, b as generateGeneralLedger, c as RevaluationRate, ct as ReportGroup, d as computeRevaluation, dt as TrialBalanceColumnRow, et as GeneralLedgerReport, f as PartnerLedgerLine, ft as TrialBalanceReport, g as generatePartnerLedger, h as PartnerLedgerReport, ht as defaultLogger, i as RevaluationParams, it as LedgerEntry, k as DimensionBreakdownRow, l as RevaluationResult, lt as ReportLine, m as PartnerLedgerParams, mt as Logger, n as generateTrialBalance, nt as IncomeStatementReport, o as generateRevaluation, ot as ReportAccount, p as PartnerLedgerOptions, pt as TrialBalanceRow, q as BalanceSheetLineSource, r as RevaluationOptions, rt as IncomeStatementSection, s as AccountForeignBalance, st as ReportCategory, tt as IncomeStatementLineSource, u as buildRevaluationEntry, ut as ReportSection, v as generateIncomeStatement, vt as DaybookParams, w as closeFiscalPeriod, yt as DaybookReport, z as generateBalanceSheet } from "./trial-balance-Dy_fAeJV.mjs";
|
|
9
9
|
import { A as OpenItem, C as AccountRepository, D as JournalItemRef, E as JournalEntryRepository, F as SeedOptions, I as SeedResult, M as ReconciliationRepository, N as ReverseOptions, O as JournalRepository, P as ReverseResult, S as creditLimitPlugin, T as BulkCreateResult, _ as FxRealizationPluginOptions, a as dailyLockPlugin, b as doubleEntryPlugin, c as periodResolver, d as LockAccountSelector, f as LockHit, g as idempotencyPlugin, i as FiscalLockPluginOptions, j as PostOptions, k as MatchInput, l as createLockPlugin, m as LockResolverContext, n as watermarkResolver, o as fiscalLockPlugin, p as LockResolver, r as DailyLockPluginOptions, s as PeriodResolverOptions, t as WatermarkResolverOptions, u as CreateLockPluginOptions, v as fxRealizationPlugin, w as BulkCreateInput, x as CreditLimitPluginOptions } from "./index-BFPFihTF.mjs";
|
|
10
10
|
import { DomainEvent, EventHandler, EventTransport, EventTransport as EventTransport$1, PublishManyResult } from "@classytic/primitives/events";
|
|
11
11
|
import { PaginationConfig, PluginFunction, PluginType, QueryParser, QueryParserOptions, Repository } from "@classytic/mongokit";
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { a as IdempotencyConflictError, i as Errors, n as ConcurrencyError, o as
|
|
|
3
3
|
import { a as watermarkResolver, c as idempotencyPlugin, i as fiscalLockPlugin, l as doubleEntryPlugin, n as creditLimitPlugin, o as periodResolver, r as dailyLockPlugin, s as createLockPlugin, t as fxRealizationPlugin, u as isReverseMarkClaim } from "./fx-realization.plugin-DY3pPxIi.mjs";
|
|
4
4
|
import { a as JOURNAL_CODES, c as getCustomJournalTypes, d as isValidJournalType, f as registerJournalType, i as isValidCurrency, l as getJournalType, n as getCurrency, o as JOURNAL_TYPES, r as getMinorUnit, s as _freezeJournalTypes, t as CURRENCIES, u as getJournalTypeCodes } from "./currencies-OuPHPyS2.mjs";
|
|
5
5
|
import { Money, add, allocate, format, formatPlain, fromDecimal, multiply, parseCents, percentage, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal } from "./money.mjs";
|
|
6
|
-
import { C as computeEndingBalance, D as requireOrgScope, E as generateAgedBalance, S as calculateTotal, T as DEFAULT_BUCKETS, _ as generateBalanceSheet, a as finalizeSession, b as getFiscalYearStart, c as generateRevaluation, d as generateIncomeStatement, f as generateGeneralLedger, g as generateBudgetVsActual, h as generateCashFlow, i as acquireSession, l as buildRevaluationEntry, m as generateDaybook, n as closeFiscalPeriod, o as defaultLogger, p as generateDimensionBreakdown, r as reopenFiscalPeriod, s as generateTrialBalance, t as generatePartnerLedger, u as computeRevaluation, v as buildItemFilters, w as isVirtualTaxAccount, x as buildAccountTypeMap, y as getDateRange } from "./partner-ledger-
|
|
6
|
+
import { C as computeEndingBalance, D as requireOrgScope, E as generateAgedBalance, S as calculateTotal, T as DEFAULT_BUCKETS, _ as generateBalanceSheet, a as finalizeSession, b as getFiscalYearStart, c as generateRevaluation, d as generateIncomeStatement, f as generateGeneralLedger, g as generateBudgetVsActual, h as generateCashFlow, i as acquireSession, l as buildRevaluationEntry, m as generateDaybook, n as closeFiscalPeriod, o as defaultLogger, p as generateDimensionBreakdown, r as reopenFiscalPeriod, s as generateTrialBalance, t as generatePartnerLedger, u as computeRevaluation, v as buildItemFilters, w as isVirtualTaxAccount, x as buildAccountTypeMap, y as getDateRange } from "./partner-ledger-BvcE1gJp.mjs";
|
|
7
7
|
import { c as getNormalBalance, d as isValidCategory, l as isBalanceSheet, n as CATEGORY_KEYS, t as CATEGORIES, u as isIncomeStatement } from "./categories-CclX7Q94.mjs";
|
|
8
8
|
import { defineCountryPack } from "./country/index.mjs";
|
|
9
9
|
import { a as exportToCsv, i as quickbooksFieldMap, r as universalFieldMap, t as flattenJournalEntries } from "./exports-B3whucXe.mjs";
|
|
@@ -1185,12 +1185,25 @@ function wireAccountMethods(repository, country, orgField, integrations = {}) {
|
|
|
1185
1185
|
});
|
|
1186
1186
|
try {
|
|
1187
1187
|
const inserted = await repository.createMany(docs, { ordered: false });
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1188
|
+
const insertedByNumber = /* @__PURE__ */ new Map();
|
|
1189
|
+
for (const doc of inserted) {
|
|
1190
|
+
const num = doc?.accountNumber;
|
|
1191
|
+
if (num) insertedByNumber.set(num, doc);
|
|
1192
|
+
}
|
|
1193
|
+
for (const item of toCreate) {
|
|
1194
|
+
const doc = insertedByNumber.get(item.accountNumber);
|
|
1195
|
+
if (doc) results.created.push({
|
|
1196
|
+
accountTypeCode: item.accountTypeCode,
|
|
1197
|
+
active: item.active,
|
|
1198
|
+
isCashAccount: item.isCashAccount,
|
|
1199
|
+
_id: doc._id
|
|
1200
|
+
});
|
|
1201
|
+
else results.skipped.push({
|
|
1202
|
+
index: item.index,
|
|
1203
|
+
accountTypeCode: item.accountTypeCode,
|
|
1204
|
+
reason: "Not returned by createMany (driver edge case)"
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1194
1207
|
} catch (err) {
|
|
1195
1208
|
if (!isDuplicateKeyBulkError(err)) throw err;
|
|
1196
1209
|
const insertedDocs = err.insertedDocs ?? [];
|
|
@@ -1512,7 +1512,7 @@ async function generateGeneralLedger(opts, params) {
|
|
|
1512
1512
|
"journalItems.account": { $in: allAccountIds },
|
|
1513
1513
|
...orgScope,
|
|
1514
1514
|
...itemFilters
|
|
1515
|
-
}).select("date referenceNumber label journalItems").sort({ date: 1 }).lean()
|
|
1515
|
+
}).select("_id date referenceNumber label journalItems").sort({ date: 1 }).lean()
|
|
1516
1516
|
]);
|
|
1517
1517
|
const openBalMap = /* @__PURE__ */ new Map();
|
|
1518
1518
|
for (const r of [...bsOpenResults, ...isOpenResults]) openBalMap.set(String(r._id), {
|
|
@@ -1522,6 +1522,7 @@ async function generateGeneralLedger(opts, params) {
|
|
|
1522
1522
|
const entryItemsByAccount = /* @__PURE__ */ new Map();
|
|
1523
1523
|
for (const entry of periodEntries) {
|
|
1524
1524
|
const items = entry.journalItems ?? [];
|
|
1525
|
+
const journalEntryId = String(entry._id);
|
|
1525
1526
|
for (const item of items) {
|
|
1526
1527
|
const accId = String(item.account);
|
|
1527
1528
|
const debit = item.debit ?? 0;
|
|
@@ -1532,6 +1533,7 @@ async function generateGeneralLedger(opts, params) {
|
|
|
1532
1533
|
entryItemsByAccount.set(accId, list);
|
|
1533
1534
|
}
|
|
1534
1535
|
list.push({
|
|
1536
|
+
journalEntryId,
|
|
1535
1537
|
date: entry.date,
|
|
1536
1538
|
referenceNumber: entry.referenceNumber ?? "",
|
|
1537
1539
|
label: entry.label ?? "",
|
|
@@ -1553,6 +1555,7 @@ async function generateGeneralLedger(opts, params) {
|
|
|
1553
1555
|
const delta = mainType === "Asset" || mainType === "Expense" ? item.debit - item.credit : item.credit - item.debit;
|
|
1554
1556
|
runningBalance += delta;
|
|
1555
1557
|
entries.push({
|
|
1558
|
+
journalEntryId: item.journalEntryId,
|
|
1556
1559
|
date: item.date,
|
|
1557
1560
|
referenceNumber: item.referenceNumber,
|
|
1558
1561
|
label: item.label,
|
package/dist/reports/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as generateDimensionBreakdown, B as AgedBalanceOptions, C as FiscalReopenResult, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as DEFAULT_BUCKETS, H as AgedBalanceReport, I as BudgetVsActualRow, K as generateAgedBalance, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, R as BalanceSheetOptions, S as FiscalCloseResult, T as reopenFiscalPeriod, U as AgedBalanceRow, V as AgedBalanceParams, W as AgedBucketConfig, _ as IncomeStatementOptions, _t as DaybookOptions, a as RevaluationReport, b as generateGeneralLedger, bt as generateDaybook, f as PartnerLedgerLine, g as generatePartnerLedger, gt as DaybookLine, h as PartnerLedgerReport, i as RevaluationParams, j as CashFlowOptions, k as DimensionBreakdownRow, m as PartnerLedgerParams, n as generateTrialBalance, o as generateRevaluation, p as PartnerLedgerOptions, r as RevaluationOptions, t as TrialBalanceOptions, v as generateIncomeStatement, vt as DaybookParams, w as closeFiscalPeriod, x as FiscalCloseOptions, y as GeneralLedgerOptions, yt as DaybookReport, z as generateBalanceSheet } from "../trial-balance-
|
|
1
|
+
import { A as generateDimensionBreakdown, B as AgedBalanceOptions, C as FiscalReopenResult, D as DimensionBreakdownParams, E as DimensionBreakdownOptions, F as BudgetVsActualReport, G as DEFAULT_BUCKETS, H as AgedBalanceReport, I as BudgetVsActualRow, K as generateAgedBalance, L as generateBudgetVsActual, M as generateCashFlow, N as BudgetVsActualOptions, O as DimensionBreakdownReport, P as BudgetVsActualParams, R as BalanceSheetOptions, S as FiscalCloseResult, T as reopenFiscalPeriod, U as AgedBalanceRow, V as AgedBalanceParams, W as AgedBucketConfig, _ as IncomeStatementOptions, _t as DaybookOptions, a as RevaluationReport, b as generateGeneralLedger, bt as generateDaybook, f as PartnerLedgerLine, g as generatePartnerLedger, gt as DaybookLine, h as PartnerLedgerReport, i as RevaluationParams, j as CashFlowOptions, k as DimensionBreakdownRow, m as PartnerLedgerParams, n as generateTrialBalance, o as generateRevaluation, p as PartnerLedgerOptions, r as RevaluationOptions, t as TrialBalanceOptions, v as generateIncomeStatement, vt as DaybookParams, w as closeFiscalPeriod, x as FiscalCloseOptions, y as GeneralLedgerOptions, yt as DaybookReport, z as generateBalanceSheet } from "../trial-balance-Dy_fAeJV.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 DaybookLine, type DaybookOptions, type DaybookParams, type DaybookReport, type DimensionBreakdownOptions, type DimensionBreakdownParams, type DimensionBreakdownReport, type DimensionBreakdownRow, type FiscalCloseOptions, type FiscalCloseResult, type FiscalReopenResult, type GeneralLedgerOptions, type IncomeStatementOptions, type PartnerLedgerLine, type PartnerLedgerOptions, type PartnerLedgerParams, type PartnerLedgerReport, type RevaluationOptions, type RevaluationParams, type RevaluationReport, type TrialBalanceOptions, closeFiscalPeriod, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDaybook, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generatePartnerLedger, generateRevaluation, generateTrialBalance, reopenFiscalPeriod };
|
package/dist/reports/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { E as generateAgedBalance, T as DEFAULT_BUCKETS, _ as generateBalanceSheet, c as generateRevaluation, d as generateIncomeStatement, f as generateGeneralLedger, g as generateBudgetVsActual, h as generateCashFlow, m as generateDaybook, n as closeFiscalPeriod, p as generateDimensionBreakdown, r as reopenFiscalPeriod, s as generateTrialBalance, t as generatePartnerLedger } from "../partner-ledger-
|
|
1
|
+
import { E as generateAgedBalance, T as DEFAULT_BUCKETS, _ as generateBalanceSheet, c as generateRevaluation, d as generateIncomeStatement, f as generateGeneralLedger, g as generateBudgetVsActual, h as generateCashFlow, m as generateDaybook, n as closeFiscalPeriod, p as generateDimensionBreakdown, r as reopenFiscalPeriod, s as generateTrialBalance, t as generatePartnerLedger } from "../partner-ledger-BvcE1gJp.mjs";
|
|
2
2
|
export { DEFAULT_BUCKETS, closeFiscalPeriod, generateAgedBalance, generateBalanceSheet, generateBudgetVsActual, generateCashFlow, generateDaybook, generateDimensionBreakdown, generateGeneralLedger, generateIncomeStatement, generatePartnerLedger, generateRevaluation, generateTrialBalance, reopenFiscalPeriod };
|
|
@@ -256,6 +256,8 @@ type IncomeStatementLineSource = {
|
|
|
256
256
|
};
|
|
257
257
|
type IncomeStatementSection = ReportSection<IncomeStatementLineSource>;
|
|
258
258
|
interface LedgerEntry {
|
|
259
|
+
/** Source journal-entry `_id` — lets the UI link a GL row to its JE. */
|
|
260
|
+
journalEntryId: string;
|
|
259
261
|
date: Date;
|
|
260
262
|
referenceNumber: string;
|
|
261
263
|
label: string;
|
package/package.json
CHANGED