@classytic/ledger 0.4.1 → 0.4.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 +16 -5
- package/dist/index.mjs +15 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ import { c as dateLockPlugin, i as fiscalLockPlugin, n as idempotencyPlugin, o a
|
|
|
11
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
|
-
import { PluginType, Repository } from "@classytic/mongokit";
|
|
14
|
+
import { PaginationConfig, PluginType, Repository } from "@classytic/mongokit";
|
|
15
15
|
|
|
16
16
|
//#region src/models/factory.d.ts
|
|
17
17
|
interface LedgerModels {
|
|
@@ -46,6 +46,17 @@ interface LedgerRepositoryPlugins {
|
|
|
46
46
|
budget?: PluginType[];
|
|
47
47
|
reconciliation?: PluginType[];
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Pagination config per repository. Defaults to `{ maxLimit: 1000 }` for accounts
|
|
51
|
+
* (typical chart of accounts size), 100 for everything else.
|
|
52
|
+
*/
|
|
53
|
+
interface LedgerPaginationConfig {
|
|
54
|
+
account?: PaginationConfig;
|
|
55
|
+
journalEntry?: PaginationConfig;
|
|
56
|
+
fiscalPeriod?: PaginationConfig;
|
|
57
|
+
budget?: PaginationConfig;
|
|
58
|
+
reconciliation?: PaginationConfig;
|
|
59
|
+
}
|
|
49
60
|
interface LedgerRepositories {
|
|
50
61
|
accounts: AccountRepository<unknown>;
|
|
51
62
|
journalEntries: JournalEntryRepository<unknown>;
|
|
@@ -62,7 +73,7 @@ interface LedgerRepositories {
|
|
|
62
73
|
* - `budgets` — plain CRUD
|
|
63
74
|
* - `reconciliations` — has reconcile(), unreconcile(), getUnreconciled()
|
|
64
75
|
*/
|
|
65
|
-
declare function createRepositories(models: LedgerModels, config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins): LedgerRepositories;
|
|
76
|
+
declare function createRepositories(models: LedgerModels, config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins, pagination?: LedgerPaginationConfig): LedgerRepositories;
|
|
66
77
|
//#endregion
|
|
67
78
|
//#region src/engine.d.ts
|
|
68
79
|
declare class AccountingEngine {
|
|
@@ -96,7 +107,7 @@ declare class AccountingEngine {
|
|
|
96
107
|
private _models?;
|
|
97
108
|
private _repositories?;
|
|
98
109
|
private _reports?;
|
|
99
|
-
constructor(config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins);
|
|
110
|
+
constructor(config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins, pagination?: LedgerPaginationConfig);
|
|
100
111
|
/**
|
|
101
112
|
* Auto-created Mongoose models. Requires `mongoose` in config.
|
|
102
113
|
*
|
|
@@ -487,7 +498,7 @@ declare class AccountingEngine {
|
|
|
487
498
|
*/
|
|
488
499
|
wireReconciliationRepository<TDoc = unknown>(repository: Repository<TDoc>, ReconciliationModel: Model<unknown>, JournalEntryModel: Model<unknown>): ReconciliationRepository<TDoc>;
|
|
489
500
|
}
|
|
490
|
-
declare function createAccountingEngine(config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins): AccountingEngine;
|
|
501
|
+
declare function createAccountingEngine(config: AccountingEngineConfig, plugins?: LedgerRepositoryPlugins, pagination?: LedgerPaginationConfig): AccountingEngine;
|
|
491
502
|
//#endregion
|
|
492
503
|
//#region src/utils/account-helpers.d.ts
|
|
493
504
|
/**
|
|
@@ -679,4 +690,4 @@ interface PostingResult {
|
|
|
679
690
|
idempotencyKeys?: string[];
|
|
680
691
|
}
|
|
681
692
|
//#endregion
|
|
682
|
-
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 LedgerModels, type LedgerRepositories, type LedgerRepositoryPlugins, type Logger, type MainType, type ModelNames, 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 ResolvedModelNames, 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, createModels, createRepositories, 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, resolveModelNames, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
|
|
693
|
+
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 LedgerModels, type LedgerPaginationConfig, type LedgerRepositories, type LedgerRepositoryPlugins, type Logger, type MainType, type ModelNames, 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 ResolvedModelNames, 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, createModels, createRepositories, 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, resolveModelNames, splitTaxExclusive, splitTaxInclusive, subtract, toDecimal, universalFieldMap, wireAccountMethods, wireJournalEntryMethods, wireReconciliationMethods };
|
package/dist/index.mjs
CHANGED
|
@@ -67,11 +67,16 @@ function createModels(connection, config) {
|
|
|
67
67
|
* - `budgets` — plain CRUD
|
|
68
68
|
* - `reconciliations` — has reconcile(), unreconcile(), getUnreconciled()
|
|
69
69
|
*/
|
|
70
|
-
function createRepositories(models, config, plugins = {}) {
|
|
70
|
+
function createRepositories(models, config, plugins = {}, pagination = {}) {
|
|
71
71
|
const orgField = config.multiTenant?.orgField;
|
|
72
72
|
const strictness = config.strictness;
|
|
73
73
|
const country = config.country;
|
|
74
|
-
const
|
|
74
|
+
const accountPagination = pagination.account ?? { maxLimit: 1e3 };
|
|
75
|
+
const jePagination = pagination.journalEntry ?? {};
|
|
76
|
+
const fpPagination = pagination.fiscalPeriod ?? {};
|
|
77
|
+
const budgetPagination = pagination.budget ?? {};
|
|
78
|
+
const reconPagination = pagination.reconciliation ?? {};
|
|
79
|
+
const accounts = wireAccountMethods(new Repository(models.Account, plugins.account ?? [], accountPagination), models.Account, country, orgField);
|
|
75
80
|
const jePlugins = [
|
|
76
81
|
...plugins.journalEntry ?? [],
|
|
77
82
|
doubleEntryPlugin({
|
|
@@ -91,10 +96,10 @@ function createRepositories(models, config, plugins = {}) {
|
|
|
91
96
|
}));
|
|
92
97
|
return {
|
|
93
98
|
accounts,
|
|
94
|
-
journalEntries: wireJournalEntryMethods(new Repository(models.JournalEntry, jePlugins), models.JournalEntry, orgField, strictness),
|
|
95
|
-
fiscalPeriods: new Repository(models.FiscalPeriod, plugins.fiscalPeriod ?? []),
|
|
96
|
-
budgets: new Repository(models.Budget, plugins.budget ?? []),
|
|
97
|
-
reconciliations: wireReconciliationMethods(new Repository(models.Reconciliation, plugins.reconciliation ?? []), models.Reconciliation, models.JournalEntry, orgField)
|
|
99
|
+
journalEntries: wireJournalEntryMethods(new Repository(models.JournalEntry, jePlugins, jePagination), models.JournalEntry, orgField, strictness),
|
|
100
|
+
fiscalPeriods: new Repository(models.FiscalPeriod, plugins.fiscalPeriod ?? [], fpPagination),
|
|
101
|
+
budgets: new Repository(models.Budget, plugins.budget ?? [], budgetPagination),
|
|
102
|
+
reconciliations: wireReconciliationMethods(new Repository(models.Reconciliation, plugins.reconciliation ?? [], reconPagination), models.Reconciliation, models.JournalEntry, orgField)
|
|
98
103
|
};
|
|
99
104
|
}
|
|
100
105
|
//#endregion
|
|
@@ -107,13 +112,13 @@ var AccountingEngine = class {
|
|
|
107
112
|
_models;
|
|
108
113
|
_repositories;
|
|
109
114
|
_reports;
|
|
110
|
-
constructor(config, plugins = {}) {
|
|
115
|
+
constructor(config, plugins = {}, pagination = {}) {
|
|
111
116
|
this.config = config;
|
|
112
117
|
this.country = config.country;
|
|
113
118
|
this.currency = config.currency;
|
|
114
119
|
if (config.mongoose) {
|
|
115
120
|
this._models = createModels(config.mongoose, config);
|
|
116
|
-
this._repositories = createRepositories(this._models, config, plugins);
|
|
121
|
+
this._repositories = createRepositories(this._models, config, plugins, pagination);
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
/**
|
|
@@ -339,8 +344,8 @@ var AccountingEngine = class {
|
|
|
339
344
|
return wireReconciliationMethods(repository, ReconciliationModel, JournalEntryModel, orgField);
|
|
340
345
|
}
|
|
341
346
|
};
|
|
342
|
-
function createAccountingEngine(config, plugins = {}) {
|
|
343
|
-
return new AccountingEngine(config, plugins);
|
|
347
|
+
function createAccountingEngine(config, plugins = {}, pagination = {}) {
|
|
348
|
+
return new AccountingEngine(config, plugins, pagination);
|
|
344
349
|
}
|
|
345
350
|
//#endregion
|
|
346
351
|
//#region src/utils/dimensions.ts
|