@happyvertical/smrt-commerce 0.62.6 → 0.62.7

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-commerce",
5
- "packageVersion": "0.62.6",
5
+ "packageVersion": "0.62.7",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-commerce:Payout": {
8
8
  "name": "payout",
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-commerce",
6
- "packageVersion": "0.62.6",
6
+ "packageVersion": "0.62.7",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "80fe80995cf120a16f84cc705b84b69a032f85b5f71c4333b3b8b99689f3165a",
11
- "packageJson": "5a0b112280bf126d35a8700d39546ab2978eb5f57197c5f7fec8f498c656f0ef",
10
+ "manifest": "dd9f6dc5d97f8ddac8396ed7dc75cc1a20479f57d4e6af99dca79a63bbd37bba",
11
+ "packageJson": "c2ba62611224729c896edcdb4a34059526577d2cfc118902ad46d4e24a90b1ca",
12
12
  "agents": "dab2392afacc78dba4b4d7b983bbc1852c1acec3de821b02220de5c6fda6f2fa",
13
13
  "moduleDoc:agents/customer-vendor-ui.md": "ee8cbe9b6c4334cb9d53c87258d20a6ec8abd042011135be75cb03d2198796cc",
14
14
  "moduleDoc:README.md": "06668f73dad1198089b4eef19a9a6ab8421825615c581cf66c593da32754f359",
@@ -17,7 +17,7 @@
17
17
  "moduleDoc:agents/accounting-connection.md": "f51b65f3995ed1173a4768ec6f03df7e5bca338d3a2e842770627690e6e51f0e",
18
18
  "moduleDoc:agents/accounting-mapping.md": "351e9ce6913a8ff9c5a90ccb76ac84c9022fcee574deeedcd2f7a08b959c8a41",
19
19
  "moduleDoc:agents/accounting-live-gate.md": "b2b27912d4154aa339272c3c0ffa3284ef9c4e35ec17fe2fe0925a18e359d288",
20
- "moduleDoc:agents/accounting-payment-sync.md": "b5d4e7ec5574bed90baa2878ca77f370aa69d5ad7233205eed2874983950d0ce",
20
+ "moduleDoc:agents/accounting-payment-sync.md": "ed7e1671be6da8ecf3972a52ab8d9bff778f828c5a996514d098833d5015a413",
21
21
  "moduleDoc:agents/historical-sales.md": "d7e68bb3a93495c91449b7406a5eefdcddb54fafea83d14d5ba8e2c8d6168de4",
22
22
  "moduleDoc:agents/payment-allocations.md": "679894f603f62522515bce338741bafda3f10d16ef0b817b105dc2e732471fdb",
23
23
  "moduleDoc:agents/tax-codes.md": "6b07282f0ac93db4fd42ddb4a9551d880e24ec2bd2fae9d06c06561313b3cb9f",
@@ -23669,7 +23669,7 @@
23669
23669
  {
23670
23670
  "path": "agents/accounting-payment-sync.md",
23671
23671
  "module": "accounting-payment-sync",
23672
- "content": "# Payment sync, readback and batches (#5139)\n\nSource: `src/accounting-payment-sync.ts`, `src/models/AccountingSyncRecords.ts`.\n\n## Payment push\n\n`syncPaymentToAccounting({ db, tenantId, paymentId, payments, provider? })` (run\ninside the tenant context) pushes one recorded payment to the connected company,\napplied to its synced invoice(s) and deposited to the mapped clearing account\n(`deposit_account:default`). It requires:\n\n- a `completed`, non-refund `Payment` fully applied (`PaymentAllocation`s sum to\n the amount) to invoices that are **synced to the same company and\n environment** (`INVOICE_NOT_SYNCED` otherwise), one customer, one currency;\n- the `customer` and `deposit_account:default` mappings (`MAPPING_INCOMPLETE`\n lists what is missing);\n- live mode in production (see [live-mode gate](accounting-live-gate.md)).\n\nExactly once, same shape as the invoice path: `AccountingPaymentSync` is unique\nper `(tenant, provider, realm, environment, payment)`. The request id\n(`smrt_pay_<hash of the exact facts>`) and the request JSON are persisted as\n`in_flight` **before** the provider call. A definite rejection\n(`error.outcome === 'rejected'`) or a dead grant (`REAUTH_REQUIRED`: nothing was\nsent) becomes `rejected` and may be retried (an atomic conditional takeover, so\ntwo retries cannot both push). Any other failure is `unknown`: retry throws\n`RECONCILIATION_REQUIRED` until `reconcileAccountingPaymentSync` is given the\nprovider's authoritative lookup of that request (`found` completes it,\n`absent` makes it retryable; an interrupted `in_flight` row also needs\n`confirmInterruptedOwnerStopped`). Two concurrent calls: one pushes, the other\ngets `SYNC_IN_PROGRESS`. A synced payment returns `unchanged`.\n\nThe local `Payment` row is not edited; `AccountingPaymentSync.externalId` is the\nprovider id. Payments cannot be un-applied by this module: if allocations change\nafter the push, readback reports drift.\n\n### SDK seam (sdk#1540)\n\n`AccountingPaymentPort.create(request)` is the provider call; the host adapts\nthe SDK's payment creation to it (`requestId` is the idempotency key; throw an\nerror with `outcome: 'rejected'` on a definite refusal). smrt tests use fakes.\n\n## Readback\n\n`readbackInvoice({ db, tenantId, invoiceId, reader })` reads the provider\ndocument (and linked transactions) through `AccountingInvoiceReader`, projects\nit with the pilot's `projectQuickBooksPilotEvidence` (balance, paid, credited,\nrefunded, state, transactions) and stores it in `AccountingInvoiceReadback`\n(unique per invoice) with a status:\n\n| status | when |\n|---|---|\n| `in_step` | provider paid amount equals Commerce's (completed allocations), no provider-only payment |\n| `drift` | `PAID_AMOUNT_DIFFERS`, `PROVIDER_ONLY_PAYMENT` (a payment recorded only in the provider; ids in `providerOnlyJson`), or `VOIDED_IN_PROVIDER` |\n| `needs_reconciliation` | evidence incomplete or inconsistent, scope or total mismatch, or the read failed |\n\nReads only; it never writes to the provider and never creates a Work payment\nfrom a provider-only one (Epic J decision J-e).\n\n## Batches\n\nBoth are bounded (`limit` default 25, max 100) and resumable (`cursor` in,\n`nextCursor` out; `null` at the end), so a job only schedules and locks:\n\n- `syncPending({ db, tenantId, provider, payments, limit?, cursor?, customers? })`:\n pushes pending frozen invoices and credit notes (built with\n `buildFrozenInvoiceMapping`), then payments whose invoices are synced. Items\n report `synced | unchanged | skipped | failed` with a code. A missing mapping\n or unsynced source skips the item; a closed live gate or dead connection stops\n the batch. `customers` (directory + describe) resolves missing customer\n mappings; an ambiguous match is skipped, never created.\n- `readbackDue({ db, tenantId, reader, limit?, olderThan?, cursor?, now? })`:\n reads synced invoices never read or last read before `olderThan` (default 15\n minutes).\n\nInvoices with retention or ordinary-accounting state keep their own commands and\nare not picked up by `syncPending`.\n"
23672
+ "content": "# Payment sync, readback and batches (#5139)\n\nSource: `src/accounting-payment-sync.ts`, `src/models/AccountingSyncRecords.ts`.\n\n## Payment push\n\n`syncPaymentToAccounting({ db, tenantId, paymentId, payments, provider? })` (run\ninside the tenant context) pushes one recorded payment to the connected company,\napplied to its synced invoice(s) and deposited to the mapped clearing account\n(`deposit_account:default`). It requires:\n\n- a `completed`, non-refund `Payment` fully applied (`PaymentAllocation`s sum to\n the amount) to invoices that are **synced to the same company and\n environment** (`INVOICE_NOT_SYNCED` otherwise), one customer, one currency;\n- the `customer` and `deposit_account:default` mappings (`MAPPING_INCOMPLETE`\n lists what is missing);\n- live mode in production (see [live-mode gate](accounting-live-gate.md)).\n\nExactly once, same shape as the invoice path: `AccountingPaymentSync` is unique\nper `(tenant, provider, realm, environment, payment)`. The request id\n(`smrt_pay_<hash of the exact facts>`) and the request JSON are persisted as\n`in_flight` **before** the provider call. A definite rejection\n(`error.outcome === 'rejected'`) or a dead grant (`REAUTH_REQUIRED`: nothing was\nsent) becomes `rejected` and may be retried (an atomic conditional takeover, so\ntwo retries cannot both push). Any other failure is `unknown`: retry throws\n`RECONCILIATION_REQUIRED` until `reconcileAccountingPaymentSync` is given the\nprovider's authoritative lookup of that request (`found` completes it,\n`absent` makes it retryable; an interrupted `in_flight` row also needs\n`confirmInterruptedOwnerStopped`). Two concurrent calls: one pushes, the other\ngets `SYNC_IN_PROGRESS`. A synced payment returns `unchanged`.\n\nThe local `Payment` row is not edited; `AccountingPaymentSync.externalId` is the\nprovider id. Payments cannot be un-applied by this module: if allocations change\nafter the push, readback reports drift.\n\n### SDK seam (sdk#1540)\n\n`AccountingPaymentPort.create(request)` is the provider call; the host adapts\nthe SDK's payment creation to it (`requestId` is the idempotency key; throw an\nerror with `outcome: 'rejected'` on a definite refusal). smrt tests use fakes.\n\n## Readback\n\n`readbackInvoice({ db, tenantId, invoiceId, reader })` reads the provider\ndocument (and linked transactions) through `AccountingInvoiceReader`, projects\nit with the pilot's `projectQuickBooksPilotEvidence` (balance, paid, credited,\nrefunded, state, transactions) and stores it in `AccountingInvoiceReadback`\n(unique per invoice) with a status:\n\n| status | when |\n|---|---|\n| `in_step` | provider paid amount equals Commerce's (completed allocations), no provider-only payment |\n| `drift` | `PAID_AMOUNT_DIFFERS`, `PROVIDER_ONLY_PAYMENT` (a payment recorded only in the provider; ids in `providerOnlyJson`), or `VOIDED_IN_PROVIDER` |\n| `needs_reconciliation` | evidence incomplete or inconsistent, scope or total mismatch, or the read failed |\n\nReads only; it never writes to the provider and never creates a Work payment\nfrom a provider-only one (Epic J decision J-e).\n\n## Batches\n\nBoth are bounded (`limit` default 25, max 100) and resumable (`cursor` in,\n`nextCursor` out; `null` at the end), so a job only schedules and locks:\n\n- `syncPending({ db, tenantId, provider, payments, limit?, cursor?, customers? })`:\n pushes pending frozen invoices and credit notes (built with\n `buildFrozenInvoiceMapping`), then payments whose invoices are synced. Items\n report `synced | unchanged | skipped | failed` with a code. A missing mapping\n or unsynced source skips the item; a closed live gate or dead connection stops\n the batch. `customers` (directory + describe) resolves missing customer\n mappings; an ambiguous match is skipped, never created.\n- `readbackDue({ db, tenantId, reader, limit?, olderThan?, cursor?, now? })`:\n reads synced invoices never read or last read before `olderThan` (default 15\n minutes).\n\nInvoices with retention or ordinary-accounting state keep their own commands and\nare not picked up by `syncPending`.\n\n## Provider adapters (#5154)\n\n`src/accounting-provider-adapters.ts` adapts the provider that\n`withTenantQuickBooksProvider` hands you to the injected ports, typed\nstructurally against the SDK operations (no SDK bump needed):\n`paymentPortFromProvider(provider)` (sdk#1540: minor to major units, `requestId`\nforwarded as the QuickBooks `requestid`, unknown currency refused, write errors\npass through), `invoiceReaderFromProvider(provider, tenantId)` (sdk#1548) and\n`customerDirectoryFromProvider(provider)` (sdk#1539; `create` never creates over\na match and throws `CUSTOMER_NEEDS_CONFIRMATION`). A provider without the\noperation fails the call with a plain error.\n"
23673
23673
  },
23674
23674
  {
23675
23675
  "path": "agents/historical-sales.md",
@@ -5,10 +5,10 @@ description: "Commerce models for the SMRT framework - contracts, fulfillments,
5
5
  status: "stable"
6
6
  generated:
7
7
  by: "smrt/scripts/generate-knowledge-okf.ts"
8
- at: "2026-11-18T09:43:42Z"
8
+ at: "2026-11-18T18:10:13Z"
9
9
  audience: "internal"
10
10
  evidence_level: "source-inspected"
11
- source_revision: "sha256:316610435f74d9d1b7dde18b7ba1e4d30e54db49d35d58315010e5463cec3b0d"
11
+ source_revision: "sha256:c5bf2c6463d7ffff0ac0d07deb88dfd5621288be912bf6f46962acad13851176"
12
12
  sources:
13
13
  - id: "manifest"
14
14
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/commerce/package.json"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-commerce",
3
- "version": "0.62.6",
3
+ "version": "0.62.7",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Commerce models for the SMRT framework - contracts, fulfillments, payments",
6
6
  "type": "module",
@@ -63,21 +63,21 @@
63
63
  "access": "public"
64
64
  },
65
65
  "dependencies": {
66
- "@happyvertical/accounting": "^0.113.0",
67
- "@happyvertical/payments": "^0.113.0",
68
- "@happyvertical/smrt-agents": "0.62.6",
69
- "@happyvertical/smrt-core": "0.62.6",
70
- "@happyvertical/smrt-jobs": "0.62.6",
71
- "@happyvertical/smrt-ledgers": "0.62.6",
72
- "@happyvertical/smrt-products": "0.62.6",
73
- "@happyvertical/smrt-profiles": "0.62.6",
74
- "@happyvertical/smrt-reports": "0.62.6",
75
- "@happyvertical/smrt-subscriptions": "0.62.6",
76
- "@happyvertical/smrt-svelte": "0.62.6",
77
- "@happyvertical/smrt-tenancy": "0.62.6",
78
- "@happyvertical/smrt-types": "0.62.6",
79
- "@happyvertical/smrt-ui": "0.62.6",
80
- "@happyvertical/sql": "^0.113.0"
66
+ "@happyvertical/accounting": "^0.114.0",
67
+ "@happyvertical/payments": "^0.114.0",
68
+ "@happyvertical/smrt-agents": "0.62.7",
69
+ "@happyvertical/smrt-core": "0.62.7",
70
+ "@happyvertical/smrt-jobs": "0.62.7",
71
+ "@happyvertical/smrt-ledgers": "0.62.7",
72
+ "@happyvertical/smrt-products": "0.62.7",
73
+ "@happyvertical/smrt-profiles": "0.62.7",
74
+ "@happyvertical/smrt-reports": "0.62.7",
75
+ "@happyvertical/smrt-subscriptions": "0.62.7",
76
+ "@happyvertical/smrt-svelte": "0.62.7",
77
+ "@happyvertical/smrt-tenancy": "0.62.7",
78
+ "@happyvertical/smrt-types": "0.62.7",
79
+ "@happyvertical/smrt-ui": "0.62.7",
80
+ "@happyvertical/sql": "^0.114.0"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "svelte": "^5.57.0"
@@ -88,7 +88,7 @@
88
88
  }
89
89
  },
90
90
  "devDependencies": {
91
- "@happyvertical/smrt-vitest": "0.62.6",
91
+ "@happyvertical/smrt-vitest": "0.62.7",
92
92
  "@sveltejs/package": "^2.5.8",
93
93
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
94
94
  "@testing-library/jest-dom": "^7.0.1",