@happyvertical/smrt-ledgers 0.57.15 → 0.57.17
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/AGENTS.md +3 -0
- package/README.md +4 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/postings.d.ts +3 -0
- package/dist/postings.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +6 -6
- package/package.json +6 -6
package/dist/manifest.json
CHANGED
package/dist/postings.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export interface LedgerPostingInput {
|
|
|
25
25
|
* Atomically records an exact-minor-unit double entry. `runOnce` scopes the
|
|
26
26
|
* key by tenant and ledger; its receipt binds the request digest so retries recover the
|
|
27
27
|
* original journal and a changed replay refuses instead of double-posting.
|
|
28
|
+
* Idempotency is permanent: once the receipt is pruned, the journal's unique
|
|
29
|
+
* `(tenantId, ledgerId, idempotencyKey)` row and its `requestDigest` answer the
|
|
30
|
+
* same replay.
|
|
28
31
|
*/
|
|
29
32
|
export declare function postLedgerEntry(input: LedgerPostingInput): Promise<Journal>;
|
|
30
33
|
export declare const postReceivable: typeof postLedgerEntry;
|
package/dist/postings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postings.d.ts","sourceRoot":"","sources":["../src/postings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAI7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAkB,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,iBAAiB,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAA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kBAAkB,GACxB,OAAO,CAAC,OAAO,CAAC,CAuHlB;AAED,eAAO,MAAM,cAAc,wBAAkB,CAAC;AAC9C,eAAO,MAAM,WAAW,wBAAkB,CAAC;AAC3C,eAAO,MAAM,cAAc,wBAAkB,CAAC"}
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-ledgers",
|
|
6
|
-
"packageVersion": "0.57.
|
|
6
|
+
"packageVersion": "0.57.17",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "879800f99882f3d529b110511f9b9c09b63c70ee513474df27dcce2c10ee1879",
|
|
11
|
+
"packageJson": "c02424049d450192ea560d6c231243a92ad1512753f6545bfc987d15d706f41f",
|
|
12
|
+
"agents": "f981081420e5141313cd5d31b9ac9258b121484cfef783cf03e29b0f229e44eb"
|
|
13
13
|
},
|
|
14
14
|
"exports": [
|
|
15
15
|
".",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@types/node": "24.13.6",
|
|
25
25
|
"fast-glob": "^3.3.3",
|
|
26
26
|
"typescript": "6.0.3",
|
|
27
|
-
"vite": "8.1.
|
|
27
|
+
"vite": "8.1.6",
|
|
28
28
|
"vitest": "4.1.10"
|
|
29
29
|
},
|
|
30
30
|
"smrtDependencies": [
|
|
@@ -3177,7 +3177,7 @@
|
|
|
3177
3177
|
"polymorphicAssociations": 0,
|
|
3178
3178
|
"uuidColumns": 26
|
|
3179
3179
|
},
|
|
3180
|
-
"agentDoc": "# @happyvertical/smrt-ledgers\n\nDouble-entry accounting with chart of accounts, journal lifecycle, and balance enforcement.\n\n## Models\n\n- **Account**: 5 types (asset/liability/equity/revenue/expense). Hierarchical via `parentId`. Debit-normal (asset, expense) vs credit-normal (liability, equity, revenue). Methods: `getAncestors()`, `getFullPath()`, `toTreeNode()`, `getBalance(asOfDate?)`. Stored in `ledger_accounts` (explicit `tableName`), never the derived `accounts`: smrt-messages declares an unrelated `Account` on that table (#3098). `src/migrations/ledger-accounts-table.ts` (`smrt db:migrate-ledger-accounts`) moves pre-#3098 rows; the README has the operator sequence.\n- **Journal**: lifecycle `draft → posted → voided`. **Immutable after posting** (can only void, not edit). `sourceModule`/`sourceRef` for cross-package attribution. Auto-numbered (e.g., \"JNL-0001\"). `summarize()` is AI-powered via the smrt-prompts registry (see Prompt Registry below).\n- **JournalEntry**: debit XOR credit (not both, validated on save). Multi-currency via `exchangeRate`. Non-negative amounts required.\n\n## Key Methods\n\n- **`Journal.summarize()`**: Generates a natural-language summary via the registered `smrtLedgers.journal.summarize` prompt, resolved through `@happyvertical/smrt-prompts`. Tenants can override the template, model, temperature, or other params via `_smrt_prompt_overrides` without code changes. Only non-PII fields (number, date, description, status, aggregate total, entry count, balanced flag) reach the AI provider.\n\n## Prompt Registry\n\nRegistered at module-load time via `definePrompt()` in `src/prompts.ts`. Side-effect imported from `src/index.ts` so consumers automatically see the prompts after importing any export from this package.\n\n| Key | Method | Variables |\n|-----|--------|-----------|\n| `smrtLedgers.journal.summarize` | `Journal.summarize()` | `journalNumber`, `journalDate`, `journalDescription`, `journalStatus`, `journalTotal`, `entryCount`, `journalBalanced` |\n\nPII-conscious variable selection: `tenantId`, `sourceRef` (may reference customer/vendor identifiers), per-entry `accountId`/`id`, and the extensible `metadata` blob are intentionally NOT exposed as prompt variables. Tenants who need richer context should override the template via `PromptOverride` and supply their own variables through a custom call site.\n\n## Balance Enforcement\n\nNamed `Ledger` scopes freeze owner, currency and balance mode at creation.\n`exact-integer` mode requires safe integer minor units and exact equality; assigned\naccounts freeze scope/owner/type and cannot be deleted. Posted scoped journals and\nlines are immutable, including void/delete; use compensating postings.\n`postReceivable`/`postPayable`/`postSettlement` require exact ledgers and use one\ntransactional claim per tenant/ledger/key with payload-digest replay validation.\nSee README for ownership, reversal, aging and dialect contracts.\n\n\n`journal.post()` validates `Math.abs(totalDebits - totalCredits) < BALANCE_EPSILON` where `BALANCE_EPSILON = 0.01` (float rounding tolerance). Unbalanced journals cannot be posted.\n\n**This package is unit-agnostic** — `debit` / `credit` are plain DECIMAL numbers and the balance check only compares the two sides, so it holds for whatever unit the posting module uses. As of #2401, journals posted from `@happyvertical/smrt-commerce` (`Payment.recordPayment()`, `Invoice.recognizeRevenue()`) carry **integer minor units**, which balance exactly rather than merely within the epsilon. A consumer mixing modules that post in different units will get arithmetically balanced but semantically meaningless journals; pick one unit per ledger.\n\n`JournalEntryCollection.listPostedMovements({ tenantId, accountIds, from, to,\ncurrency })` is the bounded reporting input. It joins only rows whose entry and\njournal share the requested tenant, includes every posted source (including\nmanual journals), and excludes drafts and voids. Its debit, credit, and\n`creditMinusDebit` values are raw ledger units; commerce must verify its\nminor-unit convention before using them in an exact tax report. Each returned\nmovement retains the requested `tenantId` so consumers can reject a fact that\ncrosses the reporting boundary.\n\n## Gotchas\n\n- **Float tolerance**: 0.01 epsilon for balance check — not exact equality\n- **Entry requires journalId**: save Journal first, then add entries\n- **Posted journals cannot be modified**: only voided (`voidReason`, `voidedAt`)\n- **Account types inherited by children**: child cannot differ from parent type\n- **getBalance() is async**: requires JournalEntryCollection query (not stored on Account)\n- **Optional tenancy** on all models\n- **Same-named `Account`**: reference the ledger model by constructor (`@foreignKey(Account)`) or qualified name (`@happyvertical/smrt-ledgers:Account`), never the bare string. The PostgreSQL lanes are `pnpm test:postgres` here (ledgers alone) and in smrt-messages (both packages loaded)\n",
|
|
3180
|
+
"agentDoc": "# @happyvertical/smrt-ledgers\n\nDouble-entry accounting with chart of accounts, journal lifecycle, and balance enforcement.\n\n## Models\n\n- **Account**: 5 types (asset/liability/equity/revenue/expense). Hierarchical via `parentId`. Debit-normal (asset, expense) vs credit-normal (liability, equity, revenue). Methods: `getAncestors()`, `getFullPath()`, `toTreeNode()`, `getBalance(asOfDate?)`. Stored in `ledger_accounts` (explicit `tableName`), never the derived `accounts`: smrt-messages declares an unrelated `Account` on that table (#3098). `src/migrations/ledger-accounts-table.ts` (`smrt db:migrate-ledger-accounts`) moves pre-#3098 rows; the README has the operator sequence.\n- **Journal**: lifecycle `draft → posted → voided`. **Immutable after posting** (can only void, not edit). `sourceModule`/`sourceRef` for cross-package attribution. Auto-numbered (e.g., \"JNL-0001\"). `summarize()` is AI-powered via the smrt-prompts registry (see Prompt Registry below).\n- **JournalEntry**: debit XOR credit (not both, validated on save). Multi-currency via `exchangeRate`. Non-negative amounts required.\n\n## Key Methods\n\n- **`Journal.summarize()`**: Generates a natural-language summary via the registered `smrtLedgers.journal.summarize` prompt, resolved through `@happyvertical/smrt-prompts`. Tenants can override the template, model, temperature, or other params via `_smrt_prompt_overrides` without code changes. Only non-PII fields (number, date, description, status, aggregate total, entry count, balanced flag) reach the AI provider.\n\n## Prompt Registry\n\nRegistered at module-load time via `definePrompt()` in `src/prompts.ts`. Side-effect imported from `src/index.ts` so consumers automatically see the prompts after importing any export from this package.\n\n| Key | Method | Variables |\n|-----|--------|-----------|\n| `smrtLedgers.journal.summarize` | `Journal.summarize()` | `journalNumber`, `journalDate`, `journalDescription`, `journalStatus`, `journalTotal`, `entryCount`, `journalBalanced` |\n\nPII-conscious variable selection: `tenantId`, `sourceRef` (may reference customer/vendor identifiers), per-entry `accountId`/`id`, and the extensible `metadata` blob are intentionally NOT exposed as prompt variables. Tenants who need richer context should override the template via `PromptOverride` and supply their own variables through a custom call site.\n\n## Balance Enforcement\n\nNamed `Ledger` scopes freeze owner, currency and balance mode at creation.\n`exact-integer` mode requires safe integer minor units and exact equality; assigned\naccounts freeze scope/owner/type and cannot be deleted. Posted scoped journals and\nlines are immutable, including void/delete; use compensating postings.\n`postReceivable`/`postPayable`/`postSettlement` require exact ledgers and use one\ntransactional claim per tenant/ledger/key with payload-digest replay validation.\nThe journal's unique `(tenantId, ledgerId, idempotencyKey)` row is the permanent\nrecord: a retry after the `runOnce` claim is pruned (#4067) returns the original\nposted journal on a digest match, and refuses a mismatch or a non-posted row.\nSee README for ownership, reversal, aging and dialect contracts.\n\n\n`journal.post()` validates `Math.abs(totalDebits - totalCredits) < BALANCE_EPSILON` where `BALANCE_EPSILON = 0.01` (float rounding tolerance). Unbalanced journals cannot be posted.\n\n**This package is unit-agnostic** — `debit` / `credit` are plain DECIMAL numbers and the balance check only compares the two sides, so it holds for whatever unit the posting module uses. As of #2401, journals posted from `@happyvertical/smrt-commerce` (`Payment.recordPayment()`, `Invoice.recognizeRevenue()`) carry **integer minor units**, which balance exactly rather than merely within the epsilon. A consumer mixing modules that post in different units will get arithmetically balanced but semantically meaningless journals; pick one unit per ledger.\n\n`JournalEntryCollection.listPostedMovements({ tenantId, accountIds, from, to,\ncurrency })` is the bounded reporting input. It joins only rows whose entry and\njournal share the requested tenant, includes every posted source (including\nmanual journals), and excludes drafts and voids. Its debit, credit, and\n`creditMinusDebit` values are raw ledger units; commerce must verify its\nminor-unit convention before using them in an exact tax report. Each returned\nmovement retains the requested `tenantId` so consumers can reject a fact that\ncrosses the reporting boundary.\n\n## Gotchas\n\n- **Float tolerance**: 0.01 epsilon for balance check — not exact equality\n- **Entry requires journalId**: save Journal first, then add entries\n- **Posted journals cannot be modified**: only voided (`voidReason`, `voidedAt`)\n- **Account types inherited by children**: child cannot differ from parent type\n- **getBalance() is async**: requires JournalEntryCollection query (not stored on Account)\n- **Optional tenancy** on all models\n- **Same-named `Account`**: reference the ledger model by constructor (`@foreignKey(Account)`) or qualified name (`@happyvertical/smrt-ledgers:Account`), never the bare string. The PostgreSQL lanes are `pnpm test:postgres` here (ledgers alone) and in smrt-messages (both packages loaded)\n",
|
|
3181
3181
|
"recipes": [
|
|
3182
3182
|
{
|
|
3183
3183
|
"id": "ledgers.bookkeeping",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-ledgers",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.17",
|
|
4
4
|
"description": "Double-entry accounting ledger for the SMRT framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@happyvertical/smrt-core": "0.57.
|
|
42
|
-
"@happyvertical/smrt-prompts": "0.57.
|
|
43
|
-
"@happyvertical/smrt-tenancy": "0.57.
|
|
41
|
+
"@happyvertical/smrt-core": "0.57.17",
|
|
42
|
+
"@happyvertical/smrt-prompts": "0.57.17",
|
|
43
|
+
"@happyvertical/smrt-tenancy": "0.57.17"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@happyvertical/smrt-vitest": "0.57.
|
|
46
|
+
"@happyvertical/smrt-vitest": "0.57.17",
|
|
47
47
|
"@types/node": "24.13.6",
|
|
48
48
|
"fast-glob": "^3.3.3",
|
|
49
49
|
"typescript": "6.0.3",
|
|
50
|
-
"vite": "8.1.
|
|
50
|
+
"vite": "8.1.6",
|
|
51
51
|
"vitest": "4.1.10"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|