@happyvertical/smrt-ledgers 0.55.24 → 0.56.1

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.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-ledgers",
5
- "packageVersion": "0.55.24",
5
+ "packageVersion": "0.56.1",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-ledgers:AccountCollection": {
8
8
  "name": "accountcollection",
@@ -385,6 +385,20 @@
385
385
  "isStatic": false,
386
386
  "isPublic": true
387
387
  },
388
+ "listPostedMovements": {
389
+ "name": "listPostedMovements",
390
+ "async": true,
391
+ "parameters": [
392
+ {
393
+ "name": "options",
394
+ "type": "PostedJournalMovementOptions",
395
+ "optional": false
396
+ }
397
+ ],
398
+ "returnType": "Promise<PostedJournalMovement[]>",
399
+ "isStatic": false,
400
+ "isPublic": true
401
+ },
388
402
  "getAccountLedger": {
389
403
  "name": "getAccountLedger",
390
404
  "async": true,
@@ -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.55.24",
6
+ "packageVersion": "0.56.1",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "71a344f29b6d9392a438562fc02f4c0e0aa606e03f97797f5cccbbc438321767",
11
- "packageJson": "b66e1053d7f6906990965962908208742738dba277b2a9814fbfb531b1758d36",
12
- "agents": "ae2190496d153852ff73d18f871a829303927e1c65053b5325b02c0d9f470bfe"
10
+ "manifest": "356d94907bdd0df05ceee5597b4785fc30c5e49f666266e116d770c1e4635954",
11
+ "packageJson": "44d1f169b871e7ffe644bc0673af435c0e3ea839fb2a1661495886062f5b5d8c",
12
+ "agents": "a1bece3d7fcf3112b2b5193fdc51cf4438ba8446af146d1c8ac1c95c8ed2f0c8"
13
13
  },
14
14
  "exports": [
15
15
  ".",
@@ -421,7 +421,8 @@
421
421
  "getAccountBalance",
422
422
  "getAccountLedger",
423
423
  "getTotalsForDateRange",
424
- "getTrialBalance"
424
+ "getTrialBalance",
425
+ "listPostedMovements"
425
426
  ],
426
427
  "methodSignatures": [
427
428
  {
@@ -502,6 +503,14 @@
502
503
  "asOfDate?: Date"
503
504
  ],
504
505
  "returns": "Promise<TrialBalanceRow[]>"
506
+ },
507
+ {
508
+ "name": "listPostedMovements",
509
+ "async": true,
510
+ "params": [
511
+ "options: PostedJournalMovementOptions"
512
+ ],
513
+ "returns": "Promise<PostedJournalMovement[]>"
505
514
  }
506
515
  ],
507
516
  "surfaces": [
@@ -553,6 +562,14 @@
553
562
  "path": "/journalentries/findByAccounts",
554
563
  "method": "POST"
555
564
  },
565
+ {
566
+ "kind": "api",
567
+ "name": "journalentries.listPostedMovements",
568
+ "operation": "listPostedMovements",
569
+ "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection",
570
+ "path": "/journalentries/listPostedMovements",
571
+ "method": "POST"
572
+ },
556
573
  {
557
574
  "kind": "api",
558
575
  "name": "journalentries.getAccountLedger",
@@ -621,6 +638,12 @@
621
638
  "operation": "findByAccounts",
622
639
  "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
623
640
  },
641
+ {
642
+ "kind": "cli",
643
+ "name": "journalentrycollection_listPostedMovements",
644
+ "operation": "listPostedMovements",
645
+ "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
646
+ },
624
647
  {
625
648
  "kind": "cli",
626
649
  "name": "journalentrycollection_getAccountLedger",
@@ -681,6 +704,12 @@
681
704
  "operation": "findByAccounts",
682
705
  "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
683
706
  },
707
+ {
708
+ "kind": "mcp",
709
+ "name": "journalentrycollection_listpostedmovements",
710
+ "operation": "listPostedMovements",
711
+ "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
712
+ },
684
713
  {
685
714
  "kind": "mcp",
686
715
  "name": "journalentrycollection_getaccountledger",
@@ -2586,6 +2615,14 @@
2586
2615
  "path": "/journalentries/findByAccounts",
2587
2616
  "method": "POST"
2588
2617
  },
2618
+ {
2619
+ "kind": "api",
2620
+ "name": "journalentries.listPostedMovements",
2621
+ "operation": "listPostedMovements",
2622
+ "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection",
2623
+ "path": "/journalentries/listPostedMovements",
2624
+ "method": "POST"
2625
+ },
2589
2626
  {
2590
2627
  "kind": "api",
2591
2628
  "name": "journalentries.getAccountLedger",
@@ -2654,6 +2691,12 @@
2654
2691
  "operation": "findByAccounts",
2655
2692
  "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
2656
2693
  },
2694
+ {
2695
+ "kind": "cli",
2696
+ "name": "journalentrycollection_listPostedMovements",
2697
+ "operation": "listPostedMovements",
2698
+ "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
2699
+ },
2657
2700
  {
2658
2701
  "kind": "cli",
2659
2702
  "name": "journalentrycollection_getAccountLedger",
@@ -2714,6 +2757,12 @@
2714
2757
  "operation": "findByAccounts",
2715
2758
  "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
2716
2759
  },
2760
+ {
2761
+ "kind": "mcp",
2762
+ "name": "journalentrycollection_listpostedmovements",
2763
+ "operation": "listPostedMovements",
2764
+ "objectName": "@happyvertical/smrt-ledgers:JournalEntryCollection"
2765
+ },
2717
2766
  {
2718
2767
  "kind": "mcp",
2719
2768
  "name": "journalentrycollection_getaccountledger",
@@ -3442,7 +3491,7 @@
3442
3491
  "polymorphicAssociations": 0,
3443
3492
  "uuidColumns": 18
3444
3493
  },
3445
- "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\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## 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",
3494
+ "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\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",
3446
3495
  "recipes": [
3447
3496
  {
3448
3497
  "id": "ledgers.bookkeeping",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-ledgers",
3
- "version": "0.55.24",
3
+ "version": "0.56.1",
4
4
  "description": "Double-entry accounting ledger for the SMRT framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,12 +38,12 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@happyvertical/smrt-core": "0.55.24",
42
- "@happyvertical/smrt-prompts": "0.55.24",
43
- "@happyvertical/smrt-tenancy": "0.55.24"
41
+ "@happyvertical/smrt-core": "0.56.1",
42
+ "@happyvertical/smrt-prompts": "0.56.1",
43
+ "@happyvertical/smrt-tenancy": "0.56.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@happyvertical/smrt-vitest": "0.55.24",
46
+ "@happyvertical/smrt-vitest": "0.56.1",
47
47
  "@types/node": "24.13.6",
48
48
  "fast-glob": "^3.3.3",
49
49
  "typescript": "6.0.3",