@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.
- package/README.md +161 -64
- package/dist/{categories-CclX7Q94.mjs → categories-FJlrvzcl.mjs} +0 -2
- package/dist/constants/index.d.mts +2 -2
- package/dist/constants/index.mjs +3 -3
- package/dist/core-8Xfnpn6g.d.mts +1 -2
- package/dist/country/index.d.mts +1 -1
- package/dist/country/index.mjs +0 -2
- package/dist/currencies-W8kQAkm0.mjs +0 -2
- package/dist/{idempotency.plugin-v9NQ_ta-.mjs → date-lock.plugin-C8kqPBjh.mjs} +51 -11
- package/dist/{engine-BzBMpWuy.d.mts → engine-DF-MtsEr.d.mts} +10 -6
- package/dist/{errors-B7yC-Jfw.mjs → errors-BoGUSUYL.mjs} +0 -2
- package/dist/exports/index.d.mts +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/{exports-I5Xkq-9_.mjs → exports-DoGQQtMQ.mjs} +96 -77
- package/dist/{fiscal-close-L631E3De.mjs → fiscal-close-DmPV82e4.mjs} +1000 -286
- package/dist/{idempotency.plugin-CPxPt4vX.d.mts → idempotency.plugin-zU-GKJ0-.d.mts} +19 -17
- package/dist/{index-ZnSiqHYV.d.mts → index-CxZqRaOU.d.mts} +20 -6
- package/dist/{index-BPukb3L8.d.mts → index-J-XIbXH-.d.mts} +7 -8
- package/dist/index.d.mts +280 -58
- package/dist/index.mjs +123 -25
- package/dist/journal-entry.schema-B1CzLwC3.d.mts +103 -0
- package/dist/{journals-oH-FK3g8.mjs → journals-BcMn71Cq.mjs} +27 -6
- package/dist/{currencies-4WAbFRlw.d.mts → journals-DTipb_rz.d.mts} +16 -8
- package/dist/logger-UbTdBb1x.d.mts +1 -2
- package/dist/money.d.mts +1 -2
- package/dist/money.mjs +5 -5
- package/dist/plugins/index.d.mts +38 -2
- package/dist/plugins/index.mjs +57 -2
- package/dist/reconciliation.repository-DEybU_Ok.d.mts +135 -0
- package/dist/{account.repository-kDKwDt0I.mjs → reconciliation.repository-DgJEDVS-.mjs} +361 -210
- package/dist/{fiscal-period.schema-BQ5wsAq3.mjs → reconciliation.schema-KScbsXbY.mjs} +235 -90
- package/dist/reports/index.d.mts +2 -2
- package/dist/reports/index.mjs +2 -2
- package/dist/repositories/index.d.mts +2 -2
- package/dist/repositories/index.mjs +2 -2
- package/dist/schemas/index.d.mts +71 -2
- package/dist/schemas/index.mjs +2 -2
- package/dist/tenant-guard-CAxXoWuS.mjs +13 -0
- package/dist/trial-balance-DcQ0xj_4.d.mts +530 -0
- package/docs/reports.md +1 -1
- package/package.json +14 -6
- package/dist/account.repository-C7gwFLfM.d.mts +0 -29
- package/dist/account.repository-C7gwFLfM.d.mts.map +0 -1
- package/dist/account.repository-kDKwDt0I.mjs.map +0 -1
- package/dist/categories-CclX7Q94.mjs.map +0 -1
- package/dist/core-8Xfnpn6g.d.mts.map +0 -1
- package/dist/country/index.mjs.map +0 -1
- package/dist/currencies-4WAbFRlw.d.mts.map +0 -1
- package/dist/currencies-W8kQAkm0.mjs.map +0 -1
- package/dist/engine-BzBMpWuy.d.mts.map +0 -1
- package/dist/errors-B7yC-Jfw.mjs.map +0 -1
- package/dist/exports-I5Xkq-9_.mjs.map +0 -1
- package/dist/fiscal-close-L631E3De.mjs.map +0 -1
- package/dist/fiscal-close-dNlzB37y.d.mts +0 -270
- package/dist/fiscal-close-dNlzB37y.d.mts.map +0 -1
- package/dist/fiscal-period.schema-BQ5wsAq3.mjs.map +0 -1
- package/dist/fiscal-period.schema-BRdKAjrr.d.mts +0 -38
- package/dist/fiscal-period.schema-BRdKAjrr.d.mts.map +0 -1
- package/dist/idempotency.plugin-CPxPt4vX.d.mts.map +0 -1
- package/dist/idempotency.plugin-v9NQ_ta-.mjs.map +0 -1
- package/dist/index-BPukb3L8.d.mts.map +0 -1
- package/dist/index-ZnSiqHYV.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/journals-oH-FK3g8.mjs.map +0 -1
- package/dist/logger-UbTdBb1x.d.mts.map +0 -1
- package/dist/money.d.mts.map +0 -1
- package/dist/money.mjs.map +0 -1
- package/dist/session-Ba8E3Ufa.mjs +0 -84
- package/dist/session-Ba8E3Ufa.mjs.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { t as CountryPack } from "./index-CxZqRaOU.mjs";
|
|
2
|
+
import { s as StrictnessConfig } from "./engine-DF-MtsEr.mjs";
|
|
3
|
+
import { ClientSession, Model } from "mongoose";
|
|
4
|
+
import { Repository } from "@classytic/mongokit";
|
|
5
|
+
|
|
6
|
+
//#region src/types/repositories.d.ts
|
|
7
|
+
interface PostOptions {
|
|
8
|
+
session?: ClientSession | null;
|
|
9
|
+
/** Actor performing this operation (required when strictness.requireActor is enabled) */
|
|
10
|
+
actorId?: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface ReverseOptions extends PostOptions {
|
|
13
|
+
/** Date for the reversal entry (defaults to now) */
|
|
14
|
+
reversalDate?: Date;
|
|
15
|
+
}
|
|
16
|
+
interface SeedOptions {
|
|
17
|
+
session?: ClientSession | null;
|
|
18
|
+
}
|
|
19
|
+
interface SeedResult {
|
|
20
|
+
created: number;
|
|
21
|
+
skipped: number;
|
|
22
|
+
}
|
|
23
|
+
interface BulkCreateInput {
|
|
24
|
+
accountTypeCode?: string;
|
|
25
|
+
accountNumber?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
active?: boolean;
|
|
28
|
+
isCashAccount?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface BulkCreateResult {
|
|
31
|
+
summary: {
|
|
32
|
+
total: number;
|
|
33
|
+
created: number;
|
|
34
|
+
skipped: number;
|
|
35
|
+
errors: number;
|
|
36
|
+
};
|
|
37
|
+
created: Array<Record<string, unknown>>;
|
|
38
|
+
skipped: Array<Record<string, unknown>>;
|
|
39
|
+
errors: Array<Record<string, unknown>>;
|
|
40
|
+
}
|
|
41
|
+
interface ReverseResult {
|
|
42
|
+
original: Record<string, unknown>;
|
|
43
|
+
reversal: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
interface ReconcileParams {
|
|
46
|
+
accountId: unknown;
|
|
47
|
+
journalEntryIds: unknown[];
|
|
48
|
+
organizationId?: unknown;
|
|
49
|
+
note?: string;
|
|
50
|
+
session?: ClientSession;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Journal Entry Repository — extends mongokit Repository with accounting domain methods.
|
|
54
|
+
*
|
|
55
|
+
* Inherits ALL Repository<TDoc> methods: create, getById, getAll, update,
|
|
56
|
+
* delete, count, exists, distinct, aggregate, withTransaction, etc.
|
|
57
|
+
*/
|
|
58
|
+
interface JournalEntryRepository<TDoc = unknown> extends Repository<TDoc> {
|
|
59
|
+
/** Post an entry (draft → posted). Validates items, balance, and accounts. */
|
|
60
|
+
post(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
61
|
+
/** Unpost an entry (posted → draft). Resets state for re-editing. */
|
|
62
|
+
unpost(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
63
|
+
/** Archive a draft entry (draft → archived). Preserves audit trail. */
|
|
64
|
+
archive(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
65
|
+
/** Duplicate an entry as a new draft. Copies items, type, and label. */
|
|
66
|
+
duplicate(id: unknown, orgId?: unknown, options?: PostOptions): Promise<Record<string, unknown>>;
|
|
67
|
+
/** Reverse a posted entry. Creates mirror entry with flipped debits/credits. */
|
|
68
|
+
reverse(id: unknown, orgId?: unknown, options?: ReverseOptions): Promise<ReverseResult>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Account Repository — extends mongokit Repository with seed and bulk operations.
|
|
72
|
+
*/
|
|
73
|
+
interface AccountRepository<TDoc = unknown> extends Repository<TDoc> {
|
|
74
|
+
/** Seed standard posting accounts for an org from the country pack. */
|
|
75
|
+
seedAccounts(orgId: unknown, options?: SeedOptions): Promise<SeedResult>;
|
|
76
|
+
/** Bulk create accounts with validation and skip-if-exists logic. */
|
|
77
|
+
bulkCreate(accounts: BulkCreateInput[], orgId: unknown): Promise<BulkCreateResult>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Reconciliation Repository — extends mongokit Repository with bank reconciliation methods.
|
|
81
|
+
*/
|
|
82
|
+
interface ReconciliationRepository<TDoc = unknown> extends Repository<TDoc> {
|
|
83
|
+
/** Reconcile journal entries for a specific account. */
|
|
84
|
+
reconcile(params: ReconcileParams): Promise<Record<string, unknown>>;
|
|
85
|
+
/** Remove a reconciliation record. */
|
|
86
|
+
unreconcile(params: {
|
|
87
|
+
reconciliationId: unknown;
|
|
88
|
+
organizationId?: unknown;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
success: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
/** Get unreconciled journal entries for an account. */
|
|
93
|
+
getUnreconciled(params: {
|
|
94
|
+
accountId: unknown;
|
|
95
|
+
organizationId?: unknown;
|
|
96
|
+
}): Promise<Record<string, unknown>[]>;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/repositories/account.repository.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* Wire seedAccounts, bulkCreate and posting-account validation
|
|
102
|
+
* onto an existing mongokit Repository.
|
|
103
|
+
*
|
|
104
|
+
* @param repository - A mongokit Repository instance (already created)
|
|
105
|
+
* @param AccountModel - The Mongoose model for accounts
|
|
106
|
+
* @param country - The CountryPack for account type lookups
|
|
107
|
+
* @param orgField - The multi-tenant field name (e.g. 'business')
|
|
108
|
+
*/
|
|
109
|
+
declare function wireAccountMethods<TDoc = unknown>(repository: Repository<TDoc>, AccountModel: Model<unknown>, country: CountryPack, orgField?: string): AccountRepository<TDoc>;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/repositories/journal-entry.repository.d.ts
|
|
112
|
+
/**
|
|
113
|
+
* Wire post/reverse onto an existing mongokit Repository.
|
|
114
|
+
*
|
|
115
|
+
* All reads use `repository.getByQuery()` so registered plugins
|
|
116
|
+
* (multi-tenant, audit, cache) fire on every operation.
|
|
117
|
+
*
|
|
118
|
+
* @param repository - A mongokit Repository instance (already created)
|
|
119
|
+
* @param _JournalEntryModel - (Deprecated) The Mongoose model — no longer used internally; kept for API compat
|
|
120
|
+
* @param orgField - The multi-tenant field name (e.g. 'business')
|
|
121
|
+
* @param strictness - Strictness rules (immutable, requireActor, requireApproval)
|
|
122
|
+
*/
|
|
123
|
+
declare function wireJournalEntryMethods<TDoc = unknown>(repository: Repository<TDoc>, _JournalEntryModel: unknown, orgField?: string, strictness?: StrictnessConfig): JournalEntryRepository<TDoc>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/repositories/reconciliation.repository.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* Wire reconciliation methods onto an existing mongokit Repository.
|
|
128
|
+
*
|
|
129
|
+
* - reconcile() uses repository.create() so hooks (multi-tenant, audit) fire
|
|
130
|
+
* - unreconcile() uses repository.delete() so hooks fire
|
|
131
|
+
* - Cross-repo reads (JournalEntryModel) use direct Model access (acceptable)
|
|
132
|
+
*/
|
|
133
|
+
declare function wireReconciliationMethods<TDoc = unknown>(repository: Repository<TDoc>, _ReconciliationModel: Model<unknown>, JournalEntryModel: Model<unknown>, orgField?: string): ReconciliationRepository<TDoc>;
|
|
134
|
+
//#endregion
|
|
135
|
+
export { BulkCreateInput as a, PostOptions as c, ReverseOptions as d, ReverseResult as f, AccountRepository as i, ReconcileParams as l, SeedResult as m, wireJournalEntryMethods as n, BulkCreateResult as o, SeedOptions as p, wireAccountMethods as r, JournalEntryRepository as s, wireReconciliationMethods as t, ReconciliationRepository as u };
|