@happyvertical/smrt-commerce 0.62.4 → 0.62.6
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 +1 -0
- package/agents/accounting-connection.md +76 -0
- package/agents/accounting-live-gate.md +40 -0
- package/agents/accounting-mapping.md +60 -0
- package/agents/accounting-payment-sync.md +76 -0
- package/agents/ordinary-accounting.md +3 -0
- package/dist/accounting-connection.d.ts +179 -0
- package/dist/accounting-connection.d.ts.map +1 -0
- package/dist/accounting-live-gate.d.ts +50 -0
- package/dist/accounting-live-gate.d.ts.map +1 -0
- package/dist/accounting-mapping.d.ts +189 -0
- package/dist/accounting-mapping.d.ts.map +1 -0
- package/dist/accounting-payment-sync.d.ts +233 -0
- package/dist/accounting-payment-sync.d.ts.map +1 -0
- package/dist/chunks/{InvoiceCollection-Cc-fJrHy.js → InvoiceCollection-xooQnUwq.js} +10 -10
- package/dist/chunks/{InvoiceCollection-Cc-fJrHy.js.map → InvoiceCollection-xooQnUwq.js.map} +1 -1
- package/dist/chunks/{allocation-integrity-CvXQm3wK.js → allocation-integrity-C4SZJcao.js} +6 -6
- package/dist/chunks/{allocation-integrity-CvXQm3wK.js.map → allocation-integrity-C4SZJcao.js.map} +1 -1
- package/dist/chunks/{contract-money-BoKHNfV6.js → contract-money-ATacxU6t.js} +4 -7
- package/dist/chunks/{contract-money-BoKHNfV6.js.map → contract-money-ATacxU6t.js.map} +1 -1
- package/dist/chunks/{invoice-posting-DlR_-TG1.js → invoice-posting-CDfxug3Q.js} +4 -5
- package/dist/chunks/{invoice-posting-DlR_-TG1.js.map → invoice-posting-CDfxug3Q.js.map} +1 -1
- package/dist/chunks/retention-accounting-BA4wXUQc.js +8710 -0
- package/dist/chunks/retention-accounting-BA4wXUQc.js.map +1 -0
- package/dist/chunks/{tenant-money-barrier-Bmu4YiID.js → tenant-money-barrier-BdyXIVT5.js} +3 -3
- package/dist/chunks/{tenant-money-barrier-Bmu4YiID.js.map → tenant-money-barrier-BdyXIVT5.js.map} +1 -1
- package/dist/collections/AccountingConnectionCollection.d.ts +27 -0
- package/dist/collections/AccountingConnectionCollection.d.ts.map +1 -0
- package/dist/collections/AccountingMappingCollection.d.ts +24 -0
- package/dist/collections/AccountingMappingCollection.d.ts.map +1 -0
- package/dist/collections/AccountingSyncRecordCollections.d.ts +27 -0
- package/dist/collections/AccountingSyncRecordCollections.d.ts.map +1 -0
- package/dist/collections/index.d.ts +3 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1532 -21
- package/dist/index.js.map +1 -1
- package/dist/invoice-accounting-sync.d.ts +6 -0
- package/dist/invoice-accounting-sync.d.ts.map +1 -1
- package/dist/invoices.js +1 -1
- package/dist/manifest.json +6303 -3740
- package/dist/models/AccountingConnection.d.ts +101 -0
- package/dist/models/AccountingConnection.d.ts.map +1 -0
- package/dist/models/AccountingMapping.d.ts +85 -0
- package/dist/models/AccountingMapping.d.ts.map +1 -0
- package/dist/models/AccountingSyncRecords.d.ts +95 -0
- package/dist/models/AccountingSyncRecords.d.ts.map +1 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/ordinary-accounting.d.ts +1 -0
- package/dist/ordinary-accounting.d.ts.map +1 -1
- package/dist/recipes.d.ts +1 -1
- package/dist/retention-accounting.d.ts +1 -0
- package/dist/retention-accounting.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +1327 -99
- package/dist/smrt-knowledge.okf.md +55 -23
- package/package.json +15 -15
- package/dist/chunks/ContractLineItemCollection-BKHy-nR8.js +0 -260
- package/dist/chunks/ContractLineItemCollection-BKHy-nR8.js.map +0 -1
- package/dist/chunks/DocumentTaxCollection-BRebznXF.js +0 -4649
- package/dist/chunks/DocumentTaxCollection-BRebznXF.js.map +0 -1
- package/dist/chunks/TaxCodeCollection-BBqCugs5.js +0 -155
- package/dist/chunks/TaxCodeCollection-BBqCugs5.js.map +0 -1
- package/dist/chunks/TaxComponentCollection-BHJjbQxq.js +0 -134
- package/dist/chunks/TaxComponentCollection-BHJjbQxq.js.map +0 -1
- package/dist/chunks/credit-allocation-yspz0Lab.js +0 -121
- package/dist/chunks/credit-allocation-yspz0Lab.js.map +0 -1
- package/dist/chunks/retention-accounting-D0KzSw3f.js +0 -3069
- package/dist/chunks/retention-accounting-D0KzSw3f.js.map +0 -1
- package/dist/chunks/retention-accounting-internal-DNxLLVvK.js +0 -30
- package/dist/chunks/retention-accounting-internal-DNxLLVvK.js.map +0 -1
- package/dist/chunks/units-8ElbjVZK.js +0 -60
- package/dist/chunks/units-8ElbjVZK.js.map +0 -1
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-commerce",
|
|
6
|
-
"packageVersion": "0.62.
|
|
6
|
+
"packageVersion": "0.62.6",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "80fe80995cf120a16f84cc705b84b69a032f85b5f71c4333b3b8b99689f3165a",
|
|
11
|
+
"packageJson": "5a0b112280bf126d35a8700d39546ab2978eb5f57197c5f7fec8f498c656f0ef",
|
|
12
|
+
"agents": "dab2392afacc78dba4b4d7b983bbc1852c1acec3de821b02220de5c6fda6f2fa",
|
|
13
13
|
"moduleDoc:agents/customer-vendor-ui.md": "ee8cbe9b6c4334cb9d53c87258d20a6ec8abd042011135be75cb03d2198796cc",
|
|
14
14
|
"moduleDoc:README.md": "06668f73dad1198089b4eef19a9a6ab8421825615c581cf66c593da32754f359",
|
|
15
15
|
"moduleDoc:agents/invoice-quantity.md": "3a5fbb464c8fe63acc021b2259ba36f052bb22c49b29e503639c5316814e2028",
|
|
16
16
|
"moduleDoc:agents/connected-payments.md": "aa0f6c61179d5b8e780c447ac27c482e3475b57147169e4698dd8492940586c1",
|
|
17
|
+
"moduleDoc:agents/accounting-connection.md": "f51b65f3995ed1173a4768ec6f03df7e5bca338d3a2e842770627690e6e51f0e",
|
|
18
|
+
"moduleDoc:agents/accounting-mapping.md": "351e9ce6913a8ff9c5a90ccb76ac84c9022fcee574deeedcd2f7a08b959c8a41",
|
|
19
|
+
"moduleDoc:agents/accounting-live-gate.md": "b2b27912d4154aa339272c3c0ffa3284ef9c4e35ec17fe2fe0925a18e359d288",
|
|
20
|
+
"moduleDoc:agents/accounting-payment-sync.md": "b5d4e7ec5574bed90baa2878ca77f370aa69d5ad7233205eed2874983950d0ce",
|
|
17
21
|
"moduleDoc:agents/historical-sales.md": "d7e68bb3a93495c91449b7406a5eefdcddb54fafea83d14d5ba8e2c8d6168de4",
|
|
18
22
|
"moduleDoc:agents/payment-allocations.md": "679894f603f62522515bce338741bafda3f10d16ef0b817b105dc2e732471fdb",
|
|
19
23
|
"moduleDoc:agents/tax-codes.md": "6b07282f0ac93db4fd42ddb4a9551d880e24ec2bd2fae9d06c06561313b3cb9f",
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
"moduleDoc:agents/customer-funds.md": "e900764806f01d7bc53a48abbcb11f77afce4092de9c9c0d8707bbe6e9a2ed95",
|
|
32
36
|
"moduleDoc:agents/observed-purchase-prices.md": "e8e68d733b7b9453b4dbd54e1dcf11e1486b70ee855ac629bb4e6888eb90ca9c",
|
|
33
37
|
"moduleDoc:agents/received-sales-contract-money.md": "675d728c565346e5d808e8299a55f2543a423853be0ce9abc99dc7041af79570",
|
|
34
|
-
"moduleDoc:agents/ordinary-accounting.md": "
|
|
38
|
+
"moduleDoc:agents/ordinary-accounting.md": "5314be5199d84620b5ca0edff9c74a439d3acd0796c57850542d9742151eafd6",
|
|
35
39
|
"moduleDoc:agents/invoice-source-binding.md": "4e0546591e5ab63075164c7dfb1b4aae4fcbfe4bd2c73fa7141b8290e2752985"
|
|
36
40
|
},
|
|
37
41
|
"exports": [
|
|
@@ -2370,6 +2374,242 @@
|
|
|
2370
2374
|
"tags": [],
|
|
2371
2375
|
"risks": []
|
|
2372
2376
|
},
|
|
2377
|
+
{
|
|
2378
|
+
"name": "AccountingConnectionCollection",
|
|
2379
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingConnectionCollection",
|
|
2380
|
+
"collection": "accountingconnections",
|
|
2381
|
+
"tableName": "accounting_connections",
|
|
2382
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
2383
|
+
"extends": "SmrtCollection",
|
|
2384
|
+
"fields": [],
|
|
2385
|
+
"relationships": [],
|
|
2386
|
+
"methods": [
|
|
2387
|
+
"build",
|
|
2388
|
+
"findForTenant"
|
|
2389
|
+
],
|
|
2390
|
+
"methodSignatures": [
|
|
2391
|
+
{
|
|
2392
|
+
"name": "build",
|
|
2393
|
+
"async": true,
|
|
2394
|
+
"params": [
|
|
2395
|
+
"options: any"
|
|
2396
|
+
],
|
|
2397
|
+
"returns": "Promise<AccountingConnection>"
|
|
2398
|
+
},
|
|
2399
|
+
{
|
|
2400
|
+
"name": "findForTenant",
|
|
2401
|
+
"async": true,
|
|
2402
|
+
"params": [
|
|
2403
|
+
"args: object"
|
|
2404
|
+
],
|
|
2405
|
+
"returns": "Promise<AccountingConnection | null>"
|
|
2406
|
+
}
|
|
2407
|
+
],
|
|
2408
|
+
"surfaces": [],
|
|
2409
|
+
"withheldSurfaces": [
|
|
2410
|
+
{
|
|
2411
|
+
"kind": "api",
|
|
2412
|
+
"operation": "build",
|
|
2413
|
+
"code": "not-included",
|
|
2414
|
+
"reason": "not listed in api.include",
|
|
2415
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnectionCollection"
|
|
2416
|
+
},
|
|
2417
|
+
{
|
|
2418
|
+
"kind": "api",
|
|
2419
|
+
"operation": "findForTenant",
|
|
2420
|
+
"code": "not-included",
|
|
2421
|
+
"reason": "not listed in api.include",
|
|
2422
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnectionCollection"
|
|
2423
|
+
}
|
|
2424
|
+
],
|
|
2425
|
+
"relationshipFeatures": [
|
|
2426
|
+
"uuidColumns"
|
|
2427
|
+
],
|
|
2428
|
+
"tags": [],
|
|
2429
|
+
"risks": []
|
|
2430
|
+
},
|
|
2431
|
+
{
|
|
2432
|
+
"name": "AccountingMappingCollection",
|
|
2433
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingMappingCollection",
|
|
2434
|
+
"collection": "accountingmappings",
|
|
2435
|
+
"tableName": "accounting_mappings",
|
|
2436
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
2437
|
+
"extends": "SmrtCollection",
|
|
2438
|
+
"fields": [],
|
|
2439
|
+
"relationships": [],
|
|
2440
|
+
"methods": [
|
|
2441
|
+
"build",
|
|
2442
|
+
"findByKey",
|
|
2443
|
+
"listActive"
|
|
2444
|
+
],
|
|
2445
|
+
"methodSignatures": [
|
|
2446
|
+
{
|
|
2447
|
+
"name": "build",
|
|
2448
|
+
"async": true,
|
|
2449
|
+
"params": [
|
|
2450
|
+
"options: any"
|
|
2451
|
+
],
|
|
2452
|
+
"returns": "Promise<AccountingMapping>"
|
|
2453
|
+
},
|
|
2454
|
+
{
|
|
2455
|
+
"name": "findByKey",
|
|
2456
|
+
"async": true,
|
|
2457
|
+
"params": [
|
|
2458
|
+
"scope: AccountingMappingScope",
|
|
2459
|
+
"kind: AccountingMappingKind",
|
|
2460
|
+
"localId: string"
|
|
2461
|
+
],
|
|
2462
|
+
"returns": "Promise<AccountingMapping | null>"
|
|
2463
|
+
},
|
|
2464
|
+
{
|
|
2465
|
+
"name": "listActive",
|
|
2466
|
+
"async": true,
|
|
2467
|
+
"params": [
|
|
2468
|
+
"scope: AccountingMappingScope",
|
|
2469
|
+
"kind?: AccountingMappingKind"
|
|
2470
|
+
],
|
|
2471
|
+
"returns": "Promise<AccountingMapping[]>"
|
|
2472
|
+
}
|
|
2473
|
+
],
|
|
2474
|
+
"surfaces": [],
|
|
2475
|
+
"withheldSurfaces": [
|
|
2476
|
+
{
|
|
2477
|
+
"kind": "api",
|
|
2478
|
+
"operation": "build",
|
|
2479
|
+
"code": "not-included",
|
|
2480
|
+
"reason": "not listed in api.include",
|
|
2481
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMappingCollection"
|
|
2482
|
+
},
|
|
2483
|
+
{
|
|
2484
|
+
"kind": "api",
|
|
2485
|
+
"operation": "findByKey",
|
|
2486
|
+
"code": "not-included",
|
|
2487
|
+
"reason": "not listed in api.include",
|
|
2488
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMappingCollection"
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
"kind": "api",
|
|
2492
|
+
"operation": "listActive",
|
|
2493
|
+
"code": "not-included",
|
|
2494
|
+
"reason": "not listed in api.include",
|
|
2495
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMappingCollection"
|
|
2496
|
+
}
|
|
2497
|
+
],
|
|
2498
|
+
"relationshipFeatures": [
|
|
2499
|
+
"uuidColumns"
|
|
2500
|
+
],
|
|
2501
|
+
"tags": [],
|
|
2502
|
+
"risks": []
|
|
2503
|
+
},
|
|
2504
|
+
{
|
|
2505
|
+
"name": "AccountingPaymentSyncCollection",
|
|
2506
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingPaymentSyncCollection",
|
|
2507
|
+
"collection": "accountingpaymentsyncs",
|
|
2508
|
+
"tableName": "accounting_payment_syncs",
|
|
2509
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
2510
|
+
"extends": "SmrtCollection",
|
|
2511
|
+
"fields": [],
|
|
2512
|
+
"relationships": [],
|
|
2513
|
+
"methods": [
|
|
2514
|
+
"build",
|
|
2515
|
+
"findForPayment"
|
|
2516
|
+
],
|
|
2517
|
+
"methodSignatures": [
|
|
2518
|
+
{
|
|
2519
|
+
"name": "build",
|
|
2520
|
+
"async": true,
|
|
2521
|
+
"params": [
|
|
2522
|
+
"options: any"
|
|
2523
|
+
],
|
|
2524
|
+
"returns": "Promise<AccountingPaymentSync>"
|
|
2525
|
+
},
|
|
2526
|
+
{
|
|
2527
|
+
"name": "findForPayment",
|
|
2528
|
+
"async": true,
|
|
2529
|
+
"params": [
|
|
2530
|
+
"args: object"
|
|
2531
|
+
],
|
|
2532
|
+
"returns": "Promise<AccountingPaymentSync | null>"
|
|
2533
|
+
}
|
|
2534
|
+
],
|
|
2535
|
+
"surfaces": [],
|
|
2536
|
+
"withheldSurfaces": [
|
|
2537
|
+
{
|
|
2538
|
+
"kind": "api",
|
|
2539
|
+
"operation": "build",
|
|
2540
|
+
"code": "not-included",
|
|
2541
|
+
"reason": "not listed in api.include",
|
|
2542
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSyncCollection"
|
|
2543
|
+
},
|
|
2544
|
+
{
|
|
2545
|
+
"kind": "api",
|
|
2546
|
+
"operation": "findForPayment",
|
|
2547
|
+
"code": "not-included",
|
|
2548
|
+
"reason": "not listed in api.include",
|
|
2549
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSyncCollection"
|
|
2550
|
+
}
|
|
2551
|
+
],
|
|
2552
|
+
"relationshipFeatures": [
|
|
2553
|
+
"uuidColumns"
|
|
2554
|
+
],
|
|
2555
|
+
"tags": [],
|
|
2556
|
+
"risks": []
|
|
2557
|
+
},
|
|
2558
|
+
{
|
|
2559
|
+
"name": "AccountingInvoiceReadbackCollection",
|
|
2560
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingInvoiceReadbackCollection",
|
|
2561
|
+
"collection": "accountinginvoicereadbacks",
|
|
2562
|
+
"tableName": "accounting_invoice_readbacks",
|
|
2563
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
2564
|
+
"extends": "SmrtCollection",
|
|
2565
|
+
"fields": [],
|
|
2566
|
+
"relationships": [],
|
|
2567
|
+
"methods": [
|
|
2568
|
+
"build",
|
|
2569
|
+
"findForInvoice"
|
|
2570
|
+
],
|
|
2571
|
+
"methodSignatures": [
|
|
2572
|
+
{
|
|
2573
|
+
"name": "build",
|
|
2574
|
+
"async": true,
|
|
2575
|
+
"params": [
|
|
2576
|
+
"options: any"
|
|
2577
|
+
],
|
|
2578
|
+
"returns": "Promise<AccountingInvoiceReadback>"
|
|
2579
|
+
},
|
|
2580
|
+
{
|
|
2581
|
+
"name": "findForInvoice",
|
|
2582
|
+
"async": true,
|
|
2583
|
+
"params": [
|
|
2584
|
+
"tenantId: string",
|
|
2585
|
+
"invoiceId: string"
|
|
2586
|
+
],
|
|
2587
|
+
"returns": "Promise<AccountingInvoiceReadback | null>"
|
|
2588
|
+
}
|
|
2589
|
+
],
|
|
2590
|
+
"surfaces": [],
|
|
2591
|
+
"withheldSurfaces": [
|
|
2592
|
+
{
|
|
2593
|
+
"kind": "api",
|
|
2594
|
+
"operation": "build",
|
|
2595
|
+
"code": "not-included",
|
|
2596
|
+
"reason": "not listed in api.include",
|
|
2597
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadbackCollection"
|
|
2598
|
+
},
|
|
2599
|
+
{
|
|
2600
|
+
"kind": "api",
|
|
2601
|
+
"operation": "findForInvoice",
|
|
2602
|
+
"code": "not-included",
|
|
2603
|
+
"reason": "not listed in api.include",
|
|
2604
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadbackCollection"
|
|
2605
|
+
}
|
|
2606
|
+
],
|
|
2607
|
+
"relationshipFeatures": [
|
|
2608
|
+
"uuidColumns"
|
|
2609
|
+
],
|
|
2610
|
+
"tags": [],
|
|
2611
|
+
"risks": []
|
|
2612
|
+
},
|
|
2373
2613
|
{
|
|
2374
2614
|
"name": "ContractCollection",
|
|
2375
2615
|
"qualifiedName": "@happyvertical/smrt-commerce:ContractCollection",
|
|
@@ -5763,129 +6003,925 @@
|
|
|
5763
6003
|
"returns": "Promise<Vendor[]>"
|
|
5764
6004
|
},
|
|
5765
6005
|
{
|
|
5766
|
-
"name": "findByTenant",
|
|
5767
|
-
"async": true,
|
|
5768
|
-
"params": [
|
|
5769
|
-
"tenantId: string"
|
|
5770
|
-
],
|
|
5771
|
-
"returns": "Promise<Vendor[]>"
|
|
6006
|
+
"name": "findByTenant",
|
|
6007
|
+
"async": true,
|
|
6008
|
+
"params": [
|
|
6009
|
+
"tenantId: string"
|
|
6010
|
+
],
|
|
6011
|
+
"returns": "Promise<Vendor[]>"
|
|
6012
|
+
},
|
|
6013
|
+
{
|
|
6014
|
+
"name": "findGlobal",
|
|
6015
|
+
"async": true,
|
|
6016
|
+
"returns": "Promise<Vendor[]>"
|
|
6017
|
+
},
|
|
6018
|
+
{
|
|
6019
|
+
"name": "findWithGlobals",
|
|
6020
|
+
"async": true,
|
|
6021
|
+
"params": [
|
|
6022
|
+
"tenantId: string"
|
|
6023
|
+
],
|
|
6024
|
+
"returns": "Promise<Vendor[]>"
|
|
6025
|
+
},
|
|
6026
|
+
{
|
|
6027
|
+
"name": "getOrCreateForProfile",
|
|
6028
|
+
"async": true,
|
|
6029
|
+
"params": [
|
|
6030
|
+
"profileId: string",
|
|
6031
|
+
"defaults?: Partial<object>"
|
|
6032
|
+
],
|
|
6033
|
+
"returns": "Promise<Vendor>"
|
|
6034
|
+
}
|
|
6035
|
+
],
|
|
6036
|
+
"surfaces": [
|
|
6037
|
+
{
|
|
6038
|
+
"kind": "cli",
|
|
6039
|
+
"name": "vendorcollection_findByProfile",
|
|
6040
|
+
"operation": "findByProfile",
|
|
6041
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6042
|
+
},
|
|
6043
|
+
{
|
|
6044
|
+
"kind": "cli",
|
|
6045
|
+
"name": "vendorcollection_findActive",
|
|
6046
|
+
"operation": "findActive",
|
|
6047
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6048
|
+
},
|
|
6049
|
+
{
|
|
6050
|
+
"kind": "cli",
|
|
6051
|
+
"name": "vendorcollection_findByStatus",
|
|
6052
|
+
"operation": "findByStatus",
|
|
6053
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6054
|
+
},
|
|
6055
|
+
{
|
|
6056
|
+
"kind": "cli",
|
|
6057
|
+
"name": "vendorcollection_getOrCreateForProfile",
|
|
6058
|
+
"operation": "getOrCreateForProfile",
|
|
6059
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6060
|
+
},
|
|
6061
|
+
{
|
|
6062
|
+
"kind": "cli",
|
|
6063
|
+
"name": "vendorcollection_findByTenant",
|
|
6064
|
+
"operation": "findByTenant",
|
|
6065
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6066
|
+
},
|
|
6067
|
+
{
|
|
6068
|
+
"kind": "cli",
|
|
6069
|
+
"name": "vendorcollection_findGlobal",
|
|
6070
|
+
"operation": "findGlobal",
|
|
6071
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6072
|
+
},
|
|
6073
|
+
{
|
|
6074
|
+
"kind": "cli",
|
|
6075
|
+
"name": "vendorcollection_findWithGlobals",
|
|
6076
|
+
"operation": "findWithGlobals",
|
|
6077
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6078
|
+
}
|
|
6079
|
+
],
|
|
6080
|
+
"withheldSurfaces": [
|
|
6081
|
+
{
|
|
6082
|
+
"kind": "api",
|
|
6083
|
+
"operation": "findActive",
|
|
6084
|
+
"code": "not-included",
|
|
6085
|
+
"reason": "not listed in api.include",
|
|
6086
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6087
|
+
},
|
|
6088
|
+
{
|
|
6089
|
+
"kind": "api",
|
|
6090
|
+
"operation": "findByProfile",
|
|
6091
|
+
"code": "not-included",
|
|
6092
|
+
"reason": "not listed in api.include",
|
|
6093
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6094
|
+
},
|
|
6095
|
+
{
|
|
6096
|
+
"kind": "api",
|
|
6097
|
+
"operation": "findByStatus",
|
|
6098
|
+
"code": "not-included",
|
|
6099
|
+
"reason": "not listed in api.include",
|
|
6100
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6101
|
+
},
|
|
6102
|
+
{
|
|
6103
|
+
"kind": "api",
|
|
6104
|
+
"operation": "findByTenant",
|
|
6105
|
+
"code": "not-included",
|
|
6106
|
+
"reason": "not listed in api.include",
|
|
6107
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6108
|
+
},
|
|
6109
|
+
{
|
|
6110
|
+
"kind": "api",
|
|
6111
|
+
"operation": "findGlobal",
|
|
6112
|
+
"code": "not-included",
|
|
6113
|
+
"reason": "not listed in api.include",
|
|
6114
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6115
|
+
},
|
|
6116
|
+
{
|
|
6117
|
+
"kind": "api",
|
|
6118
|
+
"operation": "findWithGlobals",
|
|
6119
|
+
"code": "not-included",
|
|
6120
|
+
"reason": "not listed in api.include",
|
|
6121
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6122
|
+
},
|
|
6123
|
+
{
|
|
6124
|
+
"kind": "api",
|
|
6125
|
+
"operation": "getOrCreateForProfile",
|
|
6126
|
+
"code": "not-included",
|
|
6127
|
+
"reason": "not listed in api.include",
|
|
6128
|
+
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6129
|
+
}
|
|
6130
|
+
],
|
|
6131
|
+
"relationshipFeatures": [
|
|
6132
|
+
"uuidColumns"
|
|
6133
|
+
],
|
|
6134
|
+
"tags": [],
|
|
6135
|
+
"risks": []
|
|
6136
|
+
},
|
|
6137
|
+
{
|
|
6138
|
+
"name": "AccountingConnection",
|
|
6139
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingConnection",
|
|
6140
|
+
"collection": "accountingconnections",
|
|
6141
|
+
"description": "A tenant's connection to an accounting provider.",
|
|
6142
|
+
"tableName": "accounting_connections",
|
|
6143
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
6144
|
+
"extends": "SmrtObject",
|
|
6145
|
+
"fields": [
|
|
6146
|
+
{
|
|
6147
|
+
"name": "tenantId",
|
|
6148
|
+
"type": "text",
|
|
6149
|
+
"required": true,
|
|
6150
|
+
"columnType": "UUID"
|
|
6151
|
+
},
|
|
6152
|
+
{
|
|
6153
|
+
"name": "provider",
|
|
6154
|
+
"type": "text",
|
|
6155
|
+
"required": false,
|
|
6156
|
+
"columnType": "TEXT",
|
|
6157
|
+
"default": "quickbooks"
|
|
6158
|
+
},
|
|
6159
|
+
{
|
|
6160
|
+
"name": "realmId",
|
|
6161
|
+
"type": "text",
|
|
6162
|
+
"required": false,
|
|
6163
|
+
"columnType": "TEXT",
|
|
6164
|
+
"default": ""
|
|
6165
|
+
},
|
|
6166
|
+
{
|
|
6167
|
+
"name": "environment",
|
|
6168
|
+
"type": "text",
|
|
6169
|
+
"required": false,
|
|
6170
|
+
"columnType": "TEXT",
|
|
6171
|
+
"default": "sandbox"
|
|
6172
|
+
},
|
|
6173
|
+
{
|
|
6174
|
+
"name": "status",
|
|
6175
|
+
"type": "text",
|
|
6176
|
+
"required": false,
|
|
6177
|
+
"columnType": "TEXT",
|
|
6178
|
+
"default": "disconnected"
|
|
6179
|
+
},
|
|
6180
|
+
{
|
|
6181
|
+
"name": "lastError",
|
|
6182
|
+
"type": "text",
|
|
6183
|
+
"required": false,
|
|
6184
|
+
"columnType": "TEXT",
|
|
6185
|
+
"default": ""
|
|
6186
|
+
},
|
|
6187
|
+
{
|
|
6188
|
+
"name": "lastErrorAt",
|
|
6189
|
+
"type": "datetime",
|
|
6190
|
+
"required": false,
|
|
6191
|
+
"columnType": "TIMESTAMP"
|
|
6192
|
+
},
|
|
6193
|
+
{
|
|
6194
|
+
"name": "connectedBy",
|
|
6195
|
+
"type": "text",
|
|
6196
|
+
"required": false,
|
|
6197
|
+
"columnType": "TEXT",
|
|
6198
|
+
"default": ""
|
|
6199
|
+
},
|
|
6200
|
+
{
|
|
6201
|
+
"name": "connectedAt",
|
|
6202
|
+
"type": "datetime",
|
|
6203
|
+
"required": false,
|
|
6204
|
+
"columnType": "TIMESTAMP"
|
|
6205
|
+
},
|
|
6206
|
+
{
|
|
6207
|
+
"name": "disconnectedAt",
|
|
6208
|
+
"type": "datetime",
|
|
6209
|
+
"required": false,
|
|
6210
|
+
"columnType": "TIMESTAMP"
|
|
6211
|
+
},
|
|
6212
|
+
{
|
|
6213
|
+
"name": "tokenVersion",
|
|
6214
|
+
"type": "integer",
|
|
6215
|
+
"required": false,
|
|
6216
|
+
"columnType": "INTEGER",
|
|
6217
|
+
"default": 0
|
|
6218
|
+
},
|
|
6219
|
+
{
|
|
6220
|
+
"name": "lastRefreshedAt",
|
|
6221
|
+
"type": "datetime",
|
|
6222
|
+
"required": false,
|
|
6223
|
+
"columnType": "TIMESTAMP"
|
|
6224
|
+
},
|
|
6225
|
+
{
|
|
6226
|
+
"name": "liveEnabledRealmId",
|
|
6227
|
+
"type": "text",
|
|
6228
|
+
"required": false,
|
|
6229
|
+
"columnType": "TEXT",
|
|
6230
|
+
"default": ""
|
|
6231
|
+
},
|
|
6232
|
+
{
|
|
6233
|
+
"name": "liveEnabledAt",
|
|
6234
|
+
"type": "datetime",
|
|
6235
|
+
"required": false,
|
|
6236
|
+
"columnType": "TIMESTAMP"
|
|
6237
|
+
},
|
|
6238
|
+
{
|
|
6239
|
+
"name": "liveEnabledBy",
|
|
6240
|
+
"type": "text",
|
|
6241
|
+
"required": false,
|
|
6242
|
+
"columnType": "TEXT",
|
|
6243
|
+
"default": ""
|
|
6244
|
+
},
|
|
6245
|
+
{
|
|
6246
|
+
"name": "liveEnabledEvidenceRef",
|
|
6247
|
+
"type": "text",
|
|
6248
|
+
"required": false,
|
|
6249
|
+
"columnType": "TEXT",
|
|
6250
|
+
"default": ""
|
|
6251
|
+
}
|
|
6252
|
+
],
|
|
6253
|
+
"relationships": [],
|
|
6254
|
+
"methods": [
|
|
6255
|
+
"delete",
|
|
6256
|
+
"isConnected",
|
|
6257
|
+
"isLiveEnabled",
|
|
6258
|
+
"save"
|
|
6259
|
+
],
|
|
6260
|
+
"methodSignatures": [
|
|
6261
|
+
{
|
|
6262
|
+
"name": "delete",
|
|
6263
|
+
"async": true,
|
|
6264
|
+
"params": [
|
|
6265
|
+
"_options?: SmrtDeleteOptions"
|
|
6266
|
+
],
|
|
6267
|
+
"returns": "Promise<void>"
|
|
6268
|
+
},
|
|
6269
|
+
{
|
|
6270
|
+
"name": "isConnected",
|
|
6271
|
+
"returns": "boolean"
|
|
6272
|
+
},
|
|
6273
|
+
{
|
|
6274
|
+
"name": "isLiveEnabled",
|
|
6275
|
+
"returns": "boolean"
|
|
6276
|
+
},
|
|
6277
|
+
{
|
|
6278
|
+
"name": "save",
|
|
6279
|
+
"async": true,
|
|
6280
|
+
"params": [
|
|
6281
|
+
"options?: SmrtSaveOptions"
|
|
6282
|
+
],
|
|
6283
|
+
"returns": "Promise<this>"
|
|
6284
|
+
}
|
|
6285
|
+
],
|
|
6286
|
+
"tenant": {
|
|
6287
|
+
"scoped": true,
|
|
6288
|
+
"mode": "required",
|
|
6289
|
+
"field": "tenantId"
|
|
6290
|
+
},
|
|
6291
|
+
"conflictColumns": [
|
|
6292
|
+
"tenant_id",
|
|
6293
|
+
"slug",
|
|
6294
|
+
"context"
|
|
6295
|
+
],
|
|
6296
|
+
"surfaces": [
|
|
6297
|
+
{
|
|
6298
|
+
"kind": "api",
|
|
6299
|
+
"name": "accountingconnections.list",
|
|
6300
|
+
"operation": "list",
|
|
6301
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection",
|
|
6302
|
+
"path": "/accountingconnections",
|
|
6303
|
+
"method": "GET"
|
|
6304
|
+
},
|
|
6305
|
+
{
|
|
6306
|
+
"kind": "api",
|
|
6307
|
+
"name": "accountingconnections.get",
|
|
6308
|
+
"operation": "get",
|
|
6309
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection",
|
|
6310
|
+
"path": "/accountingconnections/[id]",
|
|
6311
|
+
"method": "GET"
|
|
6312
|
+
},
|
|
6313
|
+
{
|
|
6314
|
+
"kind": "cli",
|
|
6315
|
+
"name": "accountingconnection_list",
|
|
6316
|
+
"operation": "list",
|
|
6317
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6318
|
+
},
|
|
6319
|
+
{
|
|
6320
|
+
"kind": "cli",
|
|
6321
|
+
"name": "accountingconnection_get",
|
|
6322
|
+
"operation": "get",
|
|
6323
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6324
|
+
},
|
|
6325
|
+
{
|
|
6326
|
+
"kind": "cli",
|
|
6327
|
+
"name": "accountingconnection_isLiveEnabled",
|
|
6328
|
+
"operation": "isLiveEnabled",
|
|
6329
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6330
|
+
},
|
|
6331
|
+
{
|
|
6332
|
+
"kind": "cli",
|
|
6333
|
+
"name": "accountingconnection_isConnected",
|
|
6334
|
+
"operation": "isConnected",
|
|
6335
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6336
|
+
},
|
|
6337
|
+
{
|
|
6338
|
+
"kind": "mcp",
|
|
6339
|
+
"name": "accountingconnection_list",
|
|
6340
|
+
"operation": "list",
|
|
6341
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6342
|
+
},
|
|
6343
|
+
{
|
|
6344
|
+
"kind": "mcp",
|
|
6345
|
+
"name": "accountingconnection_get",
|
|
6346
|
+
"operation": "get",
|
|
6347
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6348
|
+
}
|
|
6349
|
+
],
|
|
6350
|
+
"withheldSurfaces": [
|
|
6351
|
+
{
|
|
6352
|
+
"kind": "api",
|
|
6353
|
+
"operation": "isConnected",
|
|
6354
|
+
"code": "not-included",
|
|
6355
|
+
"reason": "not listed in api.include",
|
|
6356
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6357
|
+
},
|
|
6358
|
+
{
|
|
6359
|
+
"kind": "api",
|
|
6360
|
+
"operation": "isLiveEnabled",
|
|
6361
|
+
"code": "not-included",
|
|
6362
|
+
"reason": "not listed in api.include",
|
|
6363
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6364
|
+
},
|
|
6365
|
+
{
|
|
6366
|
+
"kind": "api",
|
|
6367
|
+
"operation": "save",
|
|
6368
|
+
"code": "lifecycle-method",
|
|
6369
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
6370
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
6371
|
+
}
|
|
6372
|
+
],
|
|
6373
|
+
"relationshipFeatures": [
|
|
6374
|
+
"uuidColumns"
|
|
6375
|
+
],
|
|
6376
|
+
"tags": [],
|
|
6377
|
+
"risks": []
|
|
6378
|
+
},
|
|
6379
|
+
{
|
|
6380
|
+
"name": "AccountingMapping",
|
|
6381
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingMapping",
|
|
6382
|
+
"collection": "accountingmappings",
|
|
6383
|
+
"description": "A mapping of one local record to one provider record.",
|
|
6384
|
+
"tableName": "accounting_mappings",
|
|
6385
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
6386
|
+
"extends": "SmrtObject",
|
|
6387
|
+
"fields": [
|
|
6388
|
+
{
|
|
6389
|
+
"name": "tenantId",
|
|
6390
|
+
"type": "text",
|
|
6391
|
+
"required": true,
|
|
6392
|
+
"columnType": "UUID"
|
|
6393
|
+
},
|
|
6394
|
+
{
|
|
6395
|
+
"name": "provider",
|
|
6396
|
+
"type": "text",
|
|
6397
|
+
"required": false,
|
|
6398
|
+
"columnType": "TEXT",
|
|
6399
|
+
"default": "quickbooks"
|
|
6400
|
+
},
|
|
6401
|
+
{
|
|
6402
|
+
"name": "realmId",
|
|
6403
|
+
"type": "text",
|
|
6404
|
+
"required": false,
|
|
6405
|
+
"columnType": "TEXT",
|
|
6406
|
+
"default": ""
|
|
6407
|
+
},
|
|
6408
|
+
{
|
|
6409
|
+
"name": "environment",
|
|
6410
|
+
"type": "text",
|
|
6411
|
+
"required": false,
|
|
6412
|
+
"columnType": "TEXT",
|
|
6413
|
+
"default": "sandbox"
|
|
6414
|
+
},
|
|
6415
|
+
{
|
|
6416
|
+
"name": "kind",
|
|
6417
|
+
"type": "text",
|
|
6418
|
+
"required": false,
|
|
6419
|
+
"columnType": "TEXT",
|
|
6420
|
+
"default": "customer"
|
|
6421
|
+
},
|
|
6422
|
+
{
|
|
6423
|
+
"name": "localId",
|
|
6424
|
+
"type": "text",
|
|
6425
|
+
"required": false,
|
|
6426
|
+
"columnType": "TEXT",
|
|
6427
|
+
"default": ""
|
|
6428
|
+
},
|
|
6429
|
+
{
|
|
6430
|
+
"name": "externalId",
|
|
6431
|
+
"type": "text",
|
|
6432
|
+
"required": false,
|
|
6433
|
+
"columnType": "TEXT",
|
|
6434
|
+
"default": ""
|
|
6435
|
+
},
|
|
6436
|
+
{
|
|
6437
|
+
"name": "externalName",
|
|
6438
|
+
"type": "text",
|
|
6439
|
+
"required": false,
|
|
6440
|
+
"columnType": "TEXT",
|
|
6441
|
+
"default": ""
|
|
6442
|
+
},
|
|
6443
|
+
{
|
|
6444
|
+
"name": "detailsJson",
|
|
6445
|
+
"type": "text",
|
|
6446
|
+
"required": false,
|
|
6447
|
+
"columnType": "TEXT"
|
|
6448
|
+
},
|
|
6449
|
+
{
|
|
6450
|
+
"name": "status",
|
|
6451
|
+
"type": "text",
|
|
6452
|
+
"required": false,
|
|
6453
|
+
"columnType": "TEXT",
|
|
6454
|
+
"default": "active"
|
|
6455
|
+
},
|
|
6456
|
+
{
|
|
6457
|
+
"name": "confirmedBy",
|
|
6458
|
+
"type": "text",
|
|
6459
|
+
"required": false,
|
|
6460
|
+
"columnType": "TEXT",
|
|
6461
|
+
"default": ""
|
|
6462
|
+
},
|
|
6463
|
+
{
|
|
6464
|
+
"name": "confirmedAt",
|
|
6465
|
+
"type": "datetime",
|
|
6466
|
+
"required": false,
|
|
6467
|
+
"columnType": "TIMESTAMP"
|
|
6468
|
+
},
|
|
6469
|
+
{
|
|
6470
|
+
"name": "invalidatedAt",
|
|
6471
|
+
"type": "datetime",
|
|
6472
|
+
"required": false,
|
|
6473
|
+
"columnType": "TIMESTAMP"
|
|
6474
|
+
}
|
|
6475
|
+
],
|
|
6476
|
+
"relationships": [],
|
|
6477
|
+
"methods": [
|
|
6478
|
+
"delete",
|
|
6479
|
+
"save"
|
|
6480
|
+
],
|
|
6481
|
+
"methodSignatures": [
|
|
6482
|
+
{
|
|
6483
|
+
"name": "delete",
|
|
6484
|
+
"async": true,
|
|
6485
|
+
"params": [
|
|
6486
|
+
"options?: SmrtDeleteOptions"
|
|
6487
|
+
],
|
|
6488
|
+
"returns": "Promise<void>"
|
|
6489
|
+
},
|
|
6490
|
+
{
|
|
6491
|
+
"name": "save",
|
|
6492
|
+
"async": true,
|
|
6493
|
+
"params": [
|
|
6494
|
+
"options?: SmrtSaveOptions"
|
|
6495
|
+
],
|
|
6496
|
+
"returns": "Promise<this>"
|
|
6497
|
+
}
|
|
6498
|
+
],
|
|
6499
|
+
"tenant": {
|
|
6500
|
+
"scoped": true,
|
|
6501
|
+
"mode": "required",
|
|
6502
|
+
"field": "tenantId"
|
|
6503
|
+
},
|
|
6504
|
+
"conflictColumns": [
|
|
6505
|
+
"tenant_id",
|
|
6506
|
+
"slug",
|
|
6507
|
+
"context"
|
|
6508
|
+
],
|
|
6509
|
+
"surfaces": [
|
|
6510
|
+
{
|
|
6511
|
+
"kind": "api",
|
|
6512
|
+
"name": "accountingmappings.list",
|
|
6513
|
+
"operation": "list",
|
|
6514
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping",
|
|
6515
|
+
"path": "/accountingmappings",
|
|
6516
|
+
"method": "GET"
|
|
6517
|
+
},
|
|
6518
|
+
{
|
|
6519
|
+
"kind": "api",
|
|
6520
|
+
"name": "accountingmappings.get",
|
|
6521
|
+
"operation": "get",
|
|
6522
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping",
|
|
6523
|
+
"path": "/accountingmappings/[id]",
|
|
6524
|
+
"method": "GET"
|
|
6525
|
+
},
|
|
6526
|
+
{
|
|
6527
|
+
"kind": "cli",
|
|
6528
|
+
"name": "accountingmapping_list",
|
|
6529
|
+
"operation": "list",
|
|
6530
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
6531
|
+
},
|
|
6532
|
+
{
|
|
6533
|
+
"kind": "cli",
|
|
6534
|
+
"name": "accountingmapping_get",
|
|
6535
|
+
"operation": "get",
|
|
6536
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
6537
|
+
},
|
|
6538
|
+
{
|
|
6539
|
+
"kind": "mcp",
|
|
6540
|
+
"name": "accountingmapping_list",
|
|
6541
|
+
"operation": "list",
|
|
6542
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
6543
|
+
},
|
|
6544
|
+
{
|
|
6545
|
+
"kind": "mcp",
|
|
6546
|
+
"name": "accountingmapping_get",
|
|
6547
|
+
"operation": "get",
|
|
6548
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
6549
|
+
}
|
|
6550
|
+
],
|
|
6551
|
+
"withheldSurfaces": [
|
|
6552
|
+
{
|
|
6553
|
+
"kind": "api",
|
|
6554
|
+
"operation": "save",
|
|
6555
|
+
"code": "lifecycle-method",
|
|
6556
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
6557
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
6558
|
+
}
|
|
6559
|
+
],
|
|
6560
|
+
"relationshipFeatures": [
|
|
6561
|
+
"uuidColumns"
|
|
6562
|
+
],
|
|
6563
|
+
"tags": [],
|
|
6564
|
+
"risks": []
|
|
6565
|
+
},
|
|
6566
|
+
{
|
|
6567
|
+
"name": "AccountingPaymentSync",
|
|
6568
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingPaymentSync",
|
|
6569
|
+
"collection": "accountingpaymentsyncs",
|
|
6570
|
+
"description": "One recorded payment's push to the accounting provider.",
|
|
6571
|
+
"tableName": "accounting_payment_syncs",
|
|
6572
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
6573
|
+
"extends": "SmrtObject",
|
|
6574
|
+
"fields": [
|
|
6575
|
+
{
|
|
6576
|
+
"name": "tenantId",
|
|
6577
|
+
"type": "text",
|
|
6578
|
+
"required": true,
|
|
6579
|
+
"columnType": "UUID"
|
|
6580
|
+
},
|
|
6581
|
+
{
|
|
6582
|
+
"name": "provider",
|
|
6583
|
+
"type": "text",
|
|
6584
|
+
"required": false,
|
|
6585
|
+
"columnType": "TEXT",
|
|
6586
|
+
"default": "quickbooks"
|
|
6587
|
+
},
|
|
6588
|
+
{
|
|
6589
|
+
"name": "realmId",
|
|
6590
|
+
"type": "text",
|
|
6591
|
+
"required": false,
|
|
6592
|
+
"columnType": "TEXT",
|
|
6593
|
+
"default": ""
|
|
6594
|
+
},
|
|
6595
|
+
{
|
|
6596
|
+
"name": "environment",
|
|
6597
|
+
"type": "text",
|
|
6598
|
+
"required": false,
|
|
6599
|
+
"columnType": "TEXT",
|
|
6600
|
+
"default": "sandbox"
|
|
6601
|
+
},
|
|
6602
|
+
{
|
|
6603
|
+
"name": "paymentId",
|
|
6604
|
+
"type": "text",
|
|
6605
|
+
"required": false,
|
|
6606
|
+
"columnType": "TEXT",
|
|
6607
|
+
"default": ""
|
|
6608
|
+
},
|
|
6609
|
+
{
|
|
6610
|
+
"name": "status",
|
|
6611
|
+
"type": "text",
|
|
6612
|
+
"required": false,
|
|
6613
|
+
"columnType": "TEXT",
|
|
6614
|
+
"default": "in_flight"
|
|
6615
|
+
},
|
|
6616
|
+
{
|
|
6617
|
+
"name": "requestId",
|
|
6618
|
+
"type": "text",
|
|
6619
|
+
"required": false,
|
|
6620
|
+
"columnType": "TEXT",
|
|
6621
|
+
"default": ""
|
|
6622
|
+
},
|
|
6623
|
+
{
|
|
6624
|
+
"name": "attemptId",
|
|
6625
|
+
"type": "text",
|
|
6626
|
+
"required": false,
|
|
6627
|
+
"columnType": "TEXT",
|
|
6628
|
+
"default": ""
|
|
6629
|
+
},
|
|
6630
|
+
{
|
|
6631
|
+
"name": "payloadHash",
|
|
6632
|
+
"type": "text",
|
|
6633
|
+
"required": false,
|
|
6634
|
+
"columnType": "TEXT",
|
|
6635
|
+
"default": ""
|
|
6636
|
+
},
|
|
6637
|
+
{
|
|
6638
|
+
"name": "requestJson",
|
|
6639
|
+
"type": "text",
|
|
6640
|
+
"required": false,
|
|
6641
|
+
"columnType": "TEXT"
|
|
6642
|
+
},
|
|
6643
|
+
{
|
|
6644
|
+
"name": "externalId",
|
|
6645
|
+
"type": "text",
|
|
6646
|
+
"required": false,
|
|
6647
|
+
"columnType": "TEXT",
|
|
6648
|
+
"default": ""
|
|
6649
|
+
},
|
|
6650
|
+
{
|
|
6651
|
+
"name": "syncedAt",
|
|
6652
|
+
"type": "datetime",
|
|
6653
|
+
"required": false,
|
|
6654
|
+
"columnType": "TIMESTAMP"
|
|
6655
|
+
},
|
|
6656
|
+
{
|
|
6657
|
+
"name": "startedAt",
|
|
6658
|
+
"type": "datetime",
|
|
6659
|
+
"required": false,
|
|
6660
|
+
"columnType": "TIMESTAMP"
|
|
6661
|
+
},
|
|
6662
|
+
{
|
|
6663
|
+
"name": "lastError",
|
|
6664
|
+
"type": "text",
|
|
6665
|
+
"required": false,
|
|
6666
|
+
"columnType": "TEXT",
|
|
6667
|
+
"default": ""
|
|
6668
|
+
}
|
|
6669
|
+
],
|
|
6670
|
+
"relationships": [],
|
|
6671
|
+
"methods": [
|
|
6672
|
+
"delete",
|
|
6673
|
+
"save"
|
|
6674
|
+
],
|
|
6675
|
+
"methodSignatures": [
|
|
6676
|
+
{
|
|
6677
|
+
"name": "delete",
|
|
6678
|
+
"async": true,
|
|
6679
|
+
"params": [
|
|
6680
|
+
"_options?: SmrtDeleteOptions"
|
|
6681
|
+
],
|
|
6682
|
+
"returns": "Promise<void>"
|
|
6683
|
+
},
|
|
6684
|
+
{
|
|
6685
|
+
"name": "save",
|
|
6686
|
+
"async": true,
|
|
6687
|
+
"params": [
|
|
6688
|
+
"options?: SmrtSaveOptions"
|
|
6689
|
+
],
|
|
6690
|
+
"returns": "Promise<this>"
|
|
6691
|
+
}
|
|
6692
|
+
],
|
|
6693
|
+
"tenant": {
|
|
6694
|
+
"scoped": true,
|
|
6695
|
+
"mode": "required",
|
|
6696
|
+
"field": "tenantId"
|
|
6697
|
+
},
|
|
6698
|
+
"conflictColumns": [
|
|
6699
|
+
"tenant_id",
|
|
6700
|
+
"slug",
|
|
6701
|
+
"context"
|
|
6702
|
+
],
|
|
6703
|
+
"surfaces": [
|
|
6704
|
+
{
|
|
6705
|
+
"kind": "api",
|
|
6706
|
+
"name": "accountingpaymentsyncs.list",
|
|
6707
|
+
"operation": "list",
|
|
6708
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync",
|
|
6709
|
+
"path": "/accountingpaymentsyncs",
|
|
6710
|
+
"method": "GET"
|
|
6711
|
+
},
|
|
6712
|
+
{
|
|
6713
|
+
"kind": "api",
|
|
6714
|
+
"name": "accountingpaymentsyncs.get",
|
|
6715
|
+
"operation": "get",
|
|
6716
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync",
|
|
6717
|
+
"path": "/accountingpaymentsyncs/[id]",
|
|
6718
|
+
"method": "GET"
|
|
6719
|
+
},
|
|
6720
|
+
{
|
|
6721
|
+
"kind": "cli",
|
|
6722
|
+
"name": "accountingpaymentsync_list",
|
|
6723
|
+
"operation": "list",
|
|
6724
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
6725
|
+
},
|
|
6726
|
+
{
|
|
6727
|
+
"kind": "cli",
|
|
6728
|
+
"name": "accountingpaymentsync_get",
|
|
6729
|
+
"operation": "get",
|
|
6730
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
6731
|
+
},
|
|
6732
|
+
{
|
|
6733
|
+
"kind": "mcp",
|
|
6734
|
+
"name": "accountingpaymentsync_list",
|
|
6735
|
+
"operation": "list",
|
|
6736
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
6737
|
+
},
|
|
6738
|
+
{
|
|
6739
|
+
"kind": "mcp",
|
|
6740
|
+
"name": "accountingpaymentsync_get",
|
|
6741
|
+
"operation": "get",
|
|
6742
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
6743
|
+
}
|
|
6744
|
+
],
|
|
6745
|
+
"withheldSurfaces": [
|
|
6746
|
+
{
|
|
6747
|
+
"kind": "api",
|
|
6748
|
+
"operation": "save",
|
|
6749
|
+
"code": "lifecycle-method",
|
|
6750
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
6751
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
6752
|
+
}
|
|
6753
|
+
],
|
|
6754
|
+
"relationshipFeatures": [
|
|
6755
|
+
"uuidColumns"
|
|
6756
|
+
],
|
|
6757
|
+
"tags": [],
|
|
6758
|
+
"risks": []
|
|
6759
|
+
},
|
|
6760
|
+
{
|
|
6761
|
+
"name": "AccountingInvoiceReadback",
|
|
6762
|
+
"qualifiedName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback",
|
|
6763
|
+
"collection": "accountinginvoicereadbacks",
|
|
6764
|
+
"description": "The stored provider readback of one synced invoice.",
|
|
6765
|
+
"tableName": "accounting_invoice_readbacks",
|
|
6766
|
+
"packageName": "@happyvertical/smrt-commerce",
|
|
6767
|
+
"extends": "SmrtObject",
|
|
6768
|
+
"fields": [
|
|
6769
|
+
{
|
|
6770
|
+
"name": "tenantId",
|
|
6771
|
+
"type": "text",
|
|
6772
|
+
"required": true,
|
|
6773
|
+
"columnType": "UUID"
|
|
6774
|
+
},
|
|
6775
|
+
{
|
|
6776
|
+
"name": "invoiceId",
|
|
6777
|
+
"type": "text",
|
|
6778
|
+
"required": false,
|
|
6779
|
+
"columnType": "TEXT",
|
|
6780
|
+
"default": ""
|
|
6781
|
+
},
|
|
6782
|
+
{
|
|
6783
|
+
"name": "realmId",
|
|
6784
|
+
"type": "text",
|
|
6785
|
+
"required": false,
|
|
6786
|
+
"columnType": "TEXT",
|
|
6787
|
+
"default": ""
|
|
6788
|
+
},
|
|
6789
|
+
{
|
|
6790
|
+
"name": "environment",
|
|
6791
|
+
"type": "text",
|
|
6792
|
+
"required": false,
|
|
6793
|
+
"columnType": "TEXT",
|
|
6794
|
+
"default": "sandbox"
|
|
6795
|
+
},
|
|
6796
|
+
{
|
|
6797
|
+
"name": "externalId",
|
|
6798
|
+
"type": "text",
|
|
6799
|
+
"required": false,
|
|
6800
|
+
"columnType": "TEXT",
|
|
6801
|
+
"default": ""
|
|
6802
|
+
},
|
|
6803
|
+
{
|
|
6804
|
+
"name": "status",
|
|
6805
|
+
"type": "text",
|
|
6806
|
+
"required": false,
|
|
6807
|
+
"columnType": "TEXT",
|
|
6808
|
+
"default": "needs_reconciliation"
|
|
6809
|
+
},
|
|
6810
|
+
{
|
|
6811
|
+
"name": "projectionJson",
|
|
6812
|
+
"type": "text",
|
|
6813
|
+
"required": false,
|
|
6814
|
+
"columnType": "TEXT"
|
|
6815
|
+
},
|
|
6816
|
+
{
|
|
6817
|
+
"name": "localPaidMinor",
|
|
6818
|
+
"type": "integer",
|
|
6819
|
+
"required": false,
|
|
6820
|
+
"columnType": "INTEGER",
|
|
6821
|
+
"default": 0
|
|
6822
|
+
},
|
|
6823
|
+
{
|
|
6824
|
+
"name": "providerOnlyJson",
|
|
6825
|
+
"type": "text",
|
|
6826
|
+
"required": false,
|
|
6827
|
+
"columnType": "TEXT"
|
|
6828
|
+
},
|
|
6829
|
+
{
|
|
6830
|
+
"name": "observedAt",
|
|
6831
|
+
"type": "datetime",
|
|
6832
|
+
"required": false,
|
|
6833
|
+
"columnType": "TIMESTAMP"
|
|
5772
6834
|
},
|
|
5773
6835
|
{
|
|
5774
|
-
"name": "
|
|
5775
|
-
"
|
|
5776
|
-
"
|
|
5777
|
-
|
|
6836
|
+
"name": "lastError",
|
|
6837
|
+
"type": "text",
|
|
6838
|
+
"required": false,
|
|
6839
|
+
"columnType": "TEXT",
|
|
6840
|
+
"default": ""
|
|
6841
|
+
}
|
|
6842
|
+
],
|
|
6843
|
+
"relationships": [],
|
|
6844
|
+
"methods": [
|
|
6845
|
+
"delete",
|
|
6846
|
+
"save"
|
|
6847
|
+
],
|
|
6848
|
+
"methodSignatures": [
|
|
5778
6849
|
{
|
|
5779
|
-
"name": "
|
|
6850
|
+
"name": "delete",
|
|
5780
6851
|
"async": true,
|
|
5781
6852
|
"params": [
|
|
5782
|
-
"
|
|
6853
|
+
"_options?: SmrtDeleteOptions"
|
|
5783
6854
|
],
|
|
5784
|
-
"returns": "Promise<
|
|
6855
|
+
"returns": "Promise<void>"
|
|
5785
6856
|
},
|
|
5786
6857
|
{
|
|
5787
|
-
"name": "
|
|
6858
|
+
"name": "save",
|
|
5788
6859
|
"async": true,
|
|
5789
6860
|
"params": [
|
|
5790
|
-
"
|
|
5791
|
-
"defaults?: Partial<object>"
|
|
6861
|
+
"options?: SmrtSaveOptions"
|
|
5792
6862
|
],
|
|
5793
|
-
"returns": "Promise<
|
|
6863
|
+
"returns": "Promise<this>"
|
|
5794
6864
|
}
|
|
5795
6865
|
],
|
|
6866
|
+
"tenant": {
|
|
6867
|
+
"scoped": true,
|
|
6868
|
+
"mode": "required",
|
|
6869
|
+
"field": "tenantId"
|
|
6870
|
+
},
|
|
6871
|
+
"conflictColumns": [
|
|
6872
|
+
"tenant_id",
|
|
6873
|
+
"slug",
|
|
6874
|
+
"context"
|
|
6875
|
+
],
|
|
5796
6876
|
"surfaces": [
|
|
5797
6877
|
{
|
|
5798
|
-
"kind": "
|
|
5799
|
-
"name": "
|
|
5800
|
-
"operation": "
|
|
5801
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
"kind": "cli",
|
|
5805
|
-
"name": "vendorcollection_findActive",
|
|
5806
|
-
"operation": "findActive",
|
|
5807
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6878
|
+
"kind": "api",
|
|
6879
|
+
"name": "accountinginvoicereadbacks.list",
|
|
6880
|
+
"operation": "list",
|
|
6881
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback",
|
|
6882
|
+
"path": "/accountinginvoicereadbacks",
|
|
6883
|
+
"method": "GET"
|
|
5808
6884
|
},
|
|
5809
6885
|
{
|
|
5810
|
-
"kind": "
|
|
5811
|
-
"name": "
|
|
5812
|
-
"operation": "
|
|
5813
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
6886
|
+
"kind": "api",
|
|
6887
|
+
"name": "accountinginvoicereadbacks.get",
|
|
6888
|
+
"operation": "get",
|
|
6889
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback",
|
|
6890
|
+
"path": "/accountinginvoicereadbacks/[id]",
|
|
6891
|
+
"method": "GET"
|
|
5814
6892
|
},
|
|
5815
6893
|
{
|
|
5816
6894
|
"kind": "cli",
|
|
5817
|
-
"name": "
|
|
5818
|
-
"operation": "
|
|
5819
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
6895
|
+
"name": "accountinginvoicereadback_list",
|
|
6896
|
+
"operation": "list",
|
|
6897
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
5820
6898
|
},
|
|
5821
6899
|
{
|
|
5822
6900
|
"kind": "cli",
|
|
5823
|
-
"name": "
|
|
5824
|
-
"operation": "
|
|
5825
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
6901
|
+
"name": "accountinginvoicereadback_get",
|
|
6902
|
+
"operation": "get",
|
|
6903
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
5826
6904
|
},
|
|
5827
6905
|
{
|
|
5828
|
-
"kind": "
|
|
5829
|
-
"name": "
|
|
5830
|
-
"operation": "
|
|
5831
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
6906
|
+
"kind": "mcp",
|
|
6907
|
+
"name": "accountinginvoicereadback_list",
|
|
6908
|
+
"operation": "list",
|
|
6909
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
5832
6910
|
},
|
|
5833
6911
|
{
|
|
5834
|
-
"kind": "
|
|
5835
|
-
"name": "
|
|
5836
|
-
"operation": "
|
|
5837
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
6912
|
+
"kind": "mcp",
|
|
6913
|
+
"name": "accountinginvoicereadback_get",
|
|
6914
|
+
"operation": "get",
|
|
6915
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
5838
6916
|
}
|
|
5839
6917
|
],
|
|
5840
6918
|
"withheldSurfaces": [
|
|
5841
6919
|
{
|
|
5842
6920
|
"kind": "api",
|
|
5843
|
-
"operation": "
|
|
5844
|
-
"code": "
|
|
5845
|
-
"reason": "not
|
|
5846
|
-
"objectName": "@happyvertical/smrt-commerce:
|
|
5847
|
-
},
|
|
5848
|
-
{
|
|
5849
|
-
"kind": "api",
|
|
5850
|
-
"operation": "findByProfile",
|
|
5851
|
-
"code": "not-included",
|
|
5852
|
-
"reason": "not listed in api.include",
|
|
5853
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
5854
|
-
},
|
|
5855
|
-
{
|
|
5856
|
-
"kind": "api",
|
|
5857
|
-
"operation": "findByStatus",
|
|
5858
|
-
"code": "not-included",
|
|
5859
|
-
"reason": "not listed in api.include",
|
|
5860
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
5861
|
-
},
|
|
5862
|
-
{
|
|
5863
|
-
"kind": "api",
|
|
5864
|
-
"operation": "findByTenant",
|
|
5865
|
-
"code": "not-included",
|
|
5866
|
-
"reason": "not listed in api.include",
|
|
5867
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
5868
|
-
},
|
|
5869
|
-
{
|
|
5870
|
-
"kind": "api",
|
|
5871
|
-
"operation": "findGlobal",
|
|
5872
|
-
"code": "not-included",
|
|
5873
|
-
"reason": "not listed in api.include",
|
|
5874
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
5875
|
-
},
|
|
5876
|
-
{
|
|
5877
|
-
"kind": "api",
|
|
5878
|
-
"operation": "findWithGlobals",
|
|
5879
|
-
"code": "not-included",
|
|
5880
|
-
"reason": "not listed in api.include",
|
|
5881
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
5882
|
-
},
|
|
5883
|
-
{
|
|
5884
|
-
"kind": "api",
|
|
5885
|
-
"operation": "getOrCreateForProfile",
|
|
5886
|
-
"code": "not-included",
|
|
5887
|
-
"reason": "not listed in api.include",
|
|
5888
|
-
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
6921
|
+
"operation": "save",
|
|
6922
|
+
"code": "lifecycle-method",
|
|
6923
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
6924
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
5889
6925
|
}
|
|
5890
6926
|
],
|
|
5891
6927
|
"relationshipFeatures": [
|
|
@@ -19573,6 +20609,178 @@
|
|
|
19573
20609
|
"operation": "findWithGlobals",
|
|
19574
20610
|
"objectName": "@happyvertical/smrt-commerce:VendorCollection"
|
|
19575
20611
|
},
|
|
20612
|
+
{
|
|
20613
|
+
"kind": "api",
|
|
20614
|
+
"name": "accountingconnections.list",
|
|
20615
|
+
"operation": "list",
|
|
20616
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection",
|
|
20617
|
+
"path": "/accountingconnections",
|
|
20618
|
+
"method": "GET"
|
|
20619
|
+
},
|
|
20620
|
+
{
|
|
20621
|
+
"kind": "api",
|
|
20622
|
+
"name": "accountingconnections.get",
|
|
20623
|
+
"operation": "get",
|
|
20624
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection",
|
|
20625
|
+
"path": "/accountingconnections/[id]",
|
|
20626
|
+
"method": "GET"
|
|
20627
|
+
},
|
|
20628
|
+
{
|
|
20629
|
+
"kind": "cli",
|
|
20630
|
+
"name": "accountingconnection_list",
|
|
20631
|
+
"operation": "list",
|
|
20632
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
20633
|
+
},
|
|
20634
|
+
{
|
|
20635
|
+
"kind": "cli",
|
|
20636
|
+
"name": "accountingconnection_get",
|
|
20637
|
+
"operation": "get",
|
|
20638
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
20639
|
+
},
|
|
20640
|
+
{
|
|
20641
|
+
"kind": "cli",
|
|
20642
|
+
"name": "accountingconnection_isLiveEnabled",
|
|
20643
|
+
"operation": "isLiveEnabled",
|
|
20644
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
20645
|
+
},
|
|
20646
|
+
{
|
|
20647
|
+
"kind": "cli",
|
|
20648
|
+
"name": "accountingconnection_isConnected",
|
|
20649
|
+
"operation": "isConnected",
|
|
20650
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
20651
|
+
},
|
|
20652
|
+
{
|
|
20653
|
+
"kind": "mcp",
|
|
20654
|
+
"name": "accountingconnection_list",
|
|
20655
|
+
"operation": "list",
|
|
20656
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
20657
|
+
},
|
|
20658
|
+
{
|
|
20659
|
+
"kind": "mcp",
|
|
20660
|
+
"name": "accountingconnection_get",
|
|
20661
|
+
"operation": "get",
|
|
20662
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingConnection"
|
|
20663
|
+
},
|
|
20664
|
+
{
|
|
20665
|
+
"kind": "api",
|
|
20666
|
+
"name": "accountingmappings.list",
|
|
20667
|
+
"operation": "list",
|
|
20668
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping",
|
|
20669
|
+
"path": "/accountingmappings",
|
|
20670
|
+
"method": "GET"
|
|
20671
|
+
},
|
|
20672
|
+
{
|
|
20673
|
+
"kind": "api",
|
|
20674
|
+
"name": "accountingmappings.get",
|
|
20675
|
+
"operation": "get",
|
|
20676
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping",
|
|
20677
|
+
"path": "/accountingmappings/[id]",
|
|
20678
|
+
"method": "GET"
|
|
20679
|
+
},
|
|
20680
|
+
{
|
|
20681
|
+
"kind": "cli",
|
|
20682
|
+
"name": "accountingmapping_list",
|
|
20683
|
+
"operation": "list",
|
|
20684
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
20685
|
+
},
|
|
20686
|
+
{
|
|
20687
|
+
"kind": "cli",
|
|
20688
|
+
"name": "accountingmapping_get",
|
|
20689
|
+
"operation": "get",
|
|
20690
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
20691
|
+
},
|
|
20692
|
+
{
|
|
20693
|
+
"kind": "mcp",
|
|
20694
|
+
"name": "accountingmapping_list",
|
|
20695
|
+
"operation": "list",
|
|
20696
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
20697
|
+
},
|
|
20698
|
+
{
|
|
20699
|
+
"kind": "mcp",
|
|
20700
|
+
"name": "accountingmapping_get",
|
|
20701
|
+
"operation": "get",
|
|
20702
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingMapping"
|
|
20703
|
+
},
|
|
20704
|
+
{
|
|
20705
|
+
"kind": "api",
|
|
20706
|
+
"name": "accountingpaymentsyncs.list",
|
|
20707
|
+
"operation": "list",
|
|
20708
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync",
|
|
20709
|
+
"path": "/accountingpaymentsyncs",
|
|
20710
|
+
"method": "GET"
|
|
20711
|
+
},
|
|
20712
|
+
{
|
|
20713
|
+
"kind": "api",
|
|
20714
|
+
"name": "accountingpaymentsyncs.get",
|
|
20715
|
+
"operation": "get",
|
|
20716
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync",
|
|
20717
|
+
"path": "/accountingpaymentsyncs/[id]",
|
|
20718
|
+
"method": "GET"
|
|
20719
|
+
},
|
|
20720
|
+
{
|
|
20721
|
+
"kind": "cli",
|
|
20722
|
+
"name": "accountingpaymentsync_list",
|
|
20723
|
+
"operation": "list",
|
|
20724
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
20725
|
+
},
|
|
20726
|
+
{
|
|
20727
|
+
"kind": "cli",
|
|
20728
|
+
"name": "accountingpaymentsync_get",
|
|
20729
|
+
"operation": "get",
|
|
20730
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
20731
|
+
},
|
|
20732
|
+
{
|
|
20733
|
+
"kind": "mcp",
|
|
20734
|
+
"name": "accountingpaymentsync_list",
|
|
20735
|
+
"operation": "list",
|
|
20736
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
20737
|
+
},
|
|
20738
|
+
{
|
|
20739
|
+
"kind": "mcp",
|
|
20740
|
+
"name": "accountingpaymentsync_get",
|
|
20741
|
+
"operation": "get",
|
|
20742
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingPaymentSync"
|
|
20743
|
+
},
|
|
20744
|
+
{
|
|
20745
|
+
"kind": "api",
|
|
20746
|
+
"name": "accountinginvoicereadbacks.list",
|
|
20747
|
+
"operation": "list",
|
|
20748
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback",
|
|
20749
|
+
"path": "/accountinginvoicereadbacks",
|
|
20750
|
+
"method": "GET"
|
|
20751
|
+
},
|
|
20752
|
+
{
|
|
20753
|
+
"kind": "api",
|
|
20754
|
+
"name": "accountinginvoicereadbacks.get",
|
|
20755
|
+
"operation": "get",
|
|
20756
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback",
|
|
20757
|
+
"path": "/accountinginvoicereadbacks/[id]",
|
|
20758
|
+
"method": "GET"
|
|
20759
|
+
},
|
|
20760
|
+
{
|
|
20761
|
+
"kind": "cli",
|
|
20762
|
+
"name": "accountinginvoicereadback_list",
|
|
20763
|
+
"operation": "list",
|
|
20764
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
20765
|
+
},
|
|
20766
|
+
{
|
|
20767
|
+
"kind": "cli",
|
|
20768
|
+
"name": "accountinginvoicereadback_get",
|
|
20769
|
+
"operation": "get",
|
|
20770
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
20771
|
+
},
|
|
20772
|
+
{
|
|
20773
|
+
"kind": "mcp",
|
|
20774
|
+
"name": "accountinginvoicereadback_list",
|
|
20775
|
+
"operation": "list",
|
|
20776
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
20777
|
+
},
|
|
20778
|
+
{
|
|
20779
|
+
"kind": "mcp",
|
|
20780
|
+
"name": "accountinginvoicereadback_get",
|
|
20781
|
+
"operation": "get",
|
|
20782
|
+
"objectName": "@happyvertical/smrt-commerce:AccountingInvoiceReadback"
|
|
20783
|
+
},
|
|
19576
20784
|
{
|
|
19577
20785
|
"kind": "api",
|
|
19578
20786
|
"name": "contracts.list",
|
|
@@ -22419,9 +23627,9 @@
|
|
|
22419
23627
|
"junctionCollections": 0,
|
|
22420
23628
|
"hierarchicalObjects": 0,
|
|
22421
23629
|
"polymorphicAssociations": 0,
|
|
22422
|
-
"uuidColumns":
|
|
23630
|
+
"uuidColumns": 292
|
|
22423
23631
|
},
|
|
22424
|
-
"agentDoc": "# @happyvertical/smrt-commerce\n\nE-commerce with Contract STI hierarchy, invoice lifecycle, payment tracking, payout remittance, and optional ledger integration.\n\n## Models\n\n- **Customer** / **Vendor**: linked to Profile via string ID (not FK). `contacts` (JSON) is written via [`savePartyContacts()`](agents/customer-vendor-ui.md#contact-rows-3501). Customer has creditLimit, paymentTerms, customerType (DTC / WHOLESALE / RETAIL). Vendor has leadTimeDays, minimumOrder, and `payoutAddresses: Record<string, string>` — a flat map from payout-rail-qualified currency code (`USDC-base`, `BTC`, `USD-stripe`, ...) to destination string (EVM address, BTC address, Stripe Connect account id, IBAN). Use `getPayoutAddress(currency)` for a `Map.get`-style lookup; missing entries return `undefined` (caller decides skip-vs-error).\n- **Contract**: concrete STI base. Abstract **SalesContract** owns `customerId`; **PurchaseContract** owns `vendorId`. `channelId` is open-ended. Before upgrade, run `preflightCommercePartyLinks(db)` and repair linked base rows, stray parties, and wrong-branch links. See [README](README.md).\n- **WholesaleOrder**: B2B order. Conventional pairing — customer has `customerType: 'wholesale'`, NET-30/60 terms, delivered via wholesale-portal channel.\n- **ProductionOrder**: manufacturing equivalent of a PurchaseOrder — commission your factory to make finished goods. Consumes raw materials per BOM (`@happyvertical/smrt-manufacturing`) and produces SKU stock (`@happyvertical/smrt-inventory`).\n- **Cart**: transient order-in-progress. Same shape as Order; the application promotes the row from `_meta_type: Cart` to `_meta_type: Order` at checkout instead of copying data between tables.\n- **LicenseSale**: industry-neutral licensing primitive. Carries an *immutable* rights snapshot (`rightsMedium`, `rightsDistributionScope`, `rightsExclusivity`, `rightsDuration`, `rightsTerritory`, `rightsSublicensing`, `rightsDerivatives` — typed `Meta<T>` fields), licensee identity (`licenseeEmail`, optional `licenseeLegalEntity` / `licenseeJurisdiction`), and a signed-PDF reference (`pdfUrl`, `pdfHash`, optional `onChainHashRegistryRef`). Once saved at `ContractStatus.ACCEPTED`, the rights snapshot is frozen — mutating any of the seven rights fields and re-saving throws. The only legal transition out of ACCEPTED is `revoke()` (moves to CANCELLED without touching rights). Useful for stock media, music licensing, code-asset marketplaces, license keys, anywhere rights are sold for a fee.\n- **ContractLineItem**: items on contracts.\n- **Invoice**: status machine `DRAFT → SENT → VIEWED → PARTIAL → PAID` (also OVERDUE, CANCELLED, WRITTEN_OFF). `recognizeRevenue()` creates balanced AR journal entry (DR: Accounts Receivable, CR: Revenue, CR: Tax Payable).\n- **InvoiceLineItem**: fractional-quantity line items with safe minor-unit validation/recalculation on save; the existing-column migration is documented in [invoice quantity persistence](agents/invoice-quantity.md).\n- **Payment** / **PaymentAllocation**: tracks payments against invoices (status: see Gotchas). Carries optional backend-adapter fields for PaymentBackend-routed flows: `backendId` (rail adapter id — `base-usdc`, `btc`, `stripe`, distinct from `externalProvider` which names an accounting sync destination), `backendTxRef` (chain tx hash or gateway settlement id), `nativeAmount` / `nativeCurrency` (what actually arrived), `usdAtQuote` / `usdAtConfirmation` (drift accounting for volatile-currency rails). `Payment.usdDrift()` returns the confirmation - quote delta, or `0` when either side is unset.\n- **PaymentInstrument**: reusable saved payment method (\"card on file\"). Stores only provider references and non-sensitive display metadata (`providerCustomerId`, `providerPaymentMethodId`, brand / last4 / expiry), never raw card data. `isDefault` is domain-managed, not API-writable: `PaymentInstrumentCollection.setDefaultForCustomer(customerId, instrumentId)` validates the target and clears the customer's other defaults (one per customer).\n- **PaymentIntent**: short-lived pre-payment commitment with multi-option semantics. Locks a USD price for a fixed window (default 15 minutes) and lists one or more `PaymentOption`s describing different rails (`backendId`, `currency`, `payTo`, `nativeAmount`, optional `chain` / `memo` / `x402Capable` / `expiresAt`). First option to receive payment wins; the others are implicitly retired. State machine `awaiting_payment → paid → (issued | retired)` plus `expired` and `cancelled`. Mutate via dedicated `markPaid` / `markIssued` / `expire` / `cancel` / `retire` helpers — direct status assignment bypasses the invariant checks. Idempotency: see the natural-key Gotcha.\n- **TenantPaymentAccount**: tenant-owned Stripe Connect account; direct charges with an application fee, account→tenant webhook routing, refunds, no platform fallback. Write only through `connected-payments.ts`; see [connected payments](agents/connected-payments.md).\n- **Payout**: operator-to-supplier remittance. Distinct from Payment because direction, status machine, and chain semantics differ. Status machine `pending → sent → confirmed → failed` (failed is terminal but resettable via `resetFromFailed()` after fixing the underlying problem). References source `paymentId` (plain string) and destination `vendorId` (foreign key). Amount invariant `supplierNet === grossAmount - operatorFee` enforced exactly on save (integer minor units, no tolerance — #2401). `PayoutCollection.createFromPayment()` is the typical entry point; it pulls native amount / currency from the source Payment.\n- **Fulfillment** / **FulfillmentLineItem**: shipment/delivery tracking.\n\n## Recipes (#3590)\n\n`src/recipes.ts` declares four minimal `SmrtRecipe`s, emitted into the built\n`manifest.json` and `smrt-knowledge.json` `recipes`: `commerce.customers`\n(Customer), `commerce.vendors` (Vendor), `commerce.sales` (Order, requires\ncustomers), `commerce.purchases` (PurchaseOrder, requires vendors). Headers\nonly; line items, fulfilment, invoices, and payments are later recipes. Each\nhas user-facing help in `src/<name>.recipe.md` (#3591), and the fields those\nrecipes show carry `@field({ description })` text; keep both in plain\nlanguage for end users and update them when a recipe's fields change. See\n[core recipes](../core/agents/recipes.md).\n\nSee [historical issued sales](agents/historical-sales.md) for exact original source\nmoney, immutable source children and combined historical/live customer funds.\nSee [payment allocation integrity](agents/payment-allocations.md) for atomic splits,\nretry identity, parent corrections and supported dialects.\nSee [tax codes](agents/tax-codes.md) for tenant-owned rate components, default codes,\nand the standard codes every tenant gets.\nSee [document money persistence](agents/document-money.md) for the one money\nmodel: tax-code resolution, atomic aggregate writes, issued snapshots, and\nfrozen fields. Every Invoice and Contract money write needs a tenant. Host\nbootstrap is `ensureCommerceTenant(db, tenantId, { cookbook })`, which returns\n`{ tenantId }`. Money data written by an earlier version is refused with\n`COMMERCE_DATA_NEEDS_UPGRADE` until `smrt db:upgrade-commerce-money` converts\nit; see [money data upgrade](agents/money-upgrade.md).\nSee [Contract money persistence](agents/contract-money.md) for the Contract\naggregate and purchase recoverability.\n\n## Ledger Integration\n\n`@happyvertical/smrt-ledgers` is a regular dependency, loaded lazily via dynamic `import()` (never a static import) so the package graph stays a DAG (#1582). Invoice stores `arJournalId` and `revenueJournalId` as string references. `recognizeRevenue()` creates a balanced AR journal entry; `getArJournal()` returns null when no journal has been recognized yet.\n\n## Billing-period close (#3060)\n\n`src/billing/` closes periods from smrt-subscriptions charges; see the README\nfor usage.\n\n- **Port, not provider.** Period close, events, and credit checkout call only\n the `BillingProvider` port (integer minor units). `stripe.ts` adapts\n `@happyvertical/accounting`, which takes currency *major* units; convert with\n `units.ts` and never hand-roll a Stripe call here. `units.ts` exponents are\n an explicit ISO 4217 table matching the SDK's, never `Intl` display digits\n (CLDR differs for IQD, MGA, … and drifts by ICU release). The SDK's\n `*Minor` fields are already ISO minor units. Capabilities a rail may lack\n (`chargeSavedPaymentMethod`, `createSetupCheckout`, `getCheckout`,\n `setDefaultPaymentMethod`, `markInvoiceUncollectible`) are optional port\n methods: detect them by presence, and keep additions optional (#3139).\n `sendAndReconcile` refuses a provider invoice whose subtotal or total\n disagrees with the local invoice.\n- **Replay safety is identity.** Close, invoice, line, payment, allocation,\n and claim ids are `deterministicId()`s; `BillingLineSource` (conflict key\n `source_type, source_id`) is the only double-billing guard, so never bill a\n source without claiming it, and never widen that key. Each close step is\n persisted before the next; `acquireCloseLease()` serializes workers. A\n close that nets to a credit keeps its claims and ends `carried_forward`;\n its subtotal is a `credit_carry_forward` source for the payer's next billed\n close, which marks the carried close `completed`.\n- **Cycles and flat-plan coverage (#3116).** `cycles.ts` is the schedule\n (pure; `BillingAccount.billingAnchorAt`, null = calendar months). A close\n with no period closes each payer's `lastEndedBillingPeriod()`. Flat-plan\n claims are the exception to \"id from the source\": their `sourceId` is\n `<subscriptionId>:seq:<chainSequence>` and their `periodStart/End` is the\n exact time they bill. `claimFlatWindow()` reads the last number, then the\n coverage (claims ending after the window start), claims one gap as number\n n + 1, and retries on conflict; reading in that order is what makes it\n safe. That numbering, not the period, stops overlaps when schedules or\n payers change — never claim a flat plan outside it, and keep both reads\n bounded (no whole-history scans). Each numbered claim is its own invoice\n line keyed `lineKey|periodStart` (a function of the claim alone, so a\n resumed close rebuilds the same line ids). Proration is\n `prorateMinorUnits()` (half up, BigInt) against the period's full cycle.\n- **System tables.** `BillingAccount`, `BillingPeriodClose`, and\n `BillingLineSource` are not tenant-scoped and have no generated surface.\n Collections stay unexported; models are root exports (#3082). Invoices,\n payments, and journals are written in the seller's tenant; payer-owned\n subscriptions and credit grants in a system context, only after\n verification.\n- **Events** use smrt-jobs' delivery inbox under provider\n `<name>-billing:<sellerTenantId>` and a provider-filtered\n `ForgeProjectionRuntime`, so a runtime never claims another seller's\n events; any other runtime sharing the inbox must pass `providers` too. Only\n events this package acts on are stored: foreign checkouts are `ignored`,\n and only `smrt_*` checkout metadata is kept; it is\n HMAC-signed with the webhook secret at creation (empty values are omitted:\n Stripe drops them), so another integration on the same account cannot forge\n a credit purchase or a card setup; credit is granted only when the\n collected total equals it plus provider tax. Checkout amounts come from the\n re-read session (`getCheckout()`), never the Stripe event, whose amounts are\n in Stripe's unit. Rotating the webhook secret strands in-flight checkouts\n (up to 24 h). `observe()` re-reads provider state, so ordering never depends\n on delivery order; the only provider writes in `observe()` are idempotent\n (making a saved card the default). The standing hook runs inside the event\n transaction and must be idempotent.\n- **Card on file and top-ups (#3139).** A saved card is the payer customer's\n default `PaymentInstrument` (seller tenant, id from the provider method).\n `autoChargeInvoices` bills such payers `charge_automatically`, decided once\n and saved as `Invoice.collectionMethod` before the first push, which every\n retry reuses (never recompute it: a lost push response would record a\n method the provider was not asked for, #3190); activation follows `paid`, never send. An auto top-up attempt\n is a `PENDING` `Payment` (`reference` `auto-top-up:<policyId>`, id from the\n policy and `count()` of its attempts) inserted before the charge, so racing\n evaluations derive one id and one charge; the charge key is derived from\n that id. `applyAutoTopUpOutcome()` must run in a transaction and starts with\n a conditional `UPDATE … WHERE status = 'pending'` row lock, so the hook and\n the `payment` webhook settle once; the grant is keyed by the charge key.\n Never settle an attempt outside that function. Taxed accounts are charged\n with provider tax by default (#3194): the attempt row holds the credit\n (the charge subtotal), the tax is journaled to tax payable at settlement,\n and the attempt's tax decision is recorded in its `notes` so a re-drive\n repeats the same charge request (the provider refuses a key reused with\n different tax). `claimAttempt()` is the only place that decides a\n skip and reports it (`onAutoTopUpSkipped`); `cardOnFile()` and period close\n use `defaultCardInstrument()` — never copy that predicate. A provider write-off moves the local invoice to\n `WRITTEN_OFF` (a later payment, by card or on a rail (#3188), is recorded\n and reinstates the payer; the status stays, so \"paid in full\" for a\n written-off invoice is read from its allocations).\n- **Billing invoices are money-model invoices.** The provider taxes them\n (`providerTaxAmount`, server-managed, not API-writable, added to line tax),\n so every billing line is an explicit `taxMode: 'override'` to the seller's\n `out-of-scope` code. Charges are written before credits so the running\n subtotal never goes negative, and provider tax is written in the save that\n issues the invoice. Revenue posting is idempotent. `ledger.bookCurrency` is\n required (ISO 4217, validated by `BillingRuntime`) and must equal the\n billing currency. `toAccountingInput({ mapping })` emits major units.\n- **Payment rails (#3138).** A runtime has one issuing `provider` and any\n number of `paymentProviders` (unique names, one inbox namespace each; a\n provider with `capabilities.issuesInvoices === false` can never issue).\n `observe()` resolves the provider from the delivery namespace, never the\n payload. Crypto rails implement the port over `@happyvertical/payments`'\n `CryptoCheckoutGateway`; never call BTCPay (or any gateway) from here.\n Settlement is decided by the pure `decideAttempt()` from gateway state and\n `paymentPolicy` — the gateway's `settled` is authoritative and nothing here\n counts confirmations. A `BillingPaymentAttempt` (`(provider, checkout_id)`\n deterministic id) records every state and settles once; grants and payments\n are keyed by checkout id. Invoice payments close the issuer's invoice out of\n band in `observe()` (idempotent) before `project()` records the payment, and\n `settlePaidInvoice` skips (records nothing for) a `paidOutOfBand` invoice\n the rail latched with `outOfBandRequestedAt`; other out-of-band closes are\n recorded as `OTHER` payments. Rails never save cards or charge tax: a taxed\n credit purchase on a rail needs an explicit `automaticTax: false`. Exceptions are flags for operators;\n nothing reverses or refunds automatically.\n- **Known limits**: write-offs post no bad-debt journal (AR stays until paid\n or journaled by an operator); discounts still reach Stripe as negative lines (the SDK's\n line `discount` would change the lines a replayed push reconciles, so it\n needs its own migration); `RetailCharge` has no adjustment ledger. Flat\n plans are monthly, in arrears; plan changes are not prorated (#3119).\n\n## Cross-Package References\n\n- `customerId` → `@foreignKey('Customer')` (hard reference within package)\n- `vendorId` → `@foreignKey('Vendor')` on PurchaseContract only\n- `profileId` → plain string to smrt-profiles\n- `arJournalId`, `revenueJournalId` → plain string to smrt-ledgers\n- `skuId` (on `PaymentIntent`, `LicenseSale`) → plain string to smrt-products\n- `paymentId` (on `PaymentIntent`, `Payout`, `LicenseSale`) → plain string to `Payment` (same package, but kept as plain string for cross-model consistency)\n- `vendorId` on `Payout` → `@foreignKey(Vendor)` (hard reference within package)\n- Billing records reference tenants with `@crossPackageRef('@happyvertical/smrt-users:Tenant')` and charges, plan periods, and adjustments by plain `sourceId`\n\n## Gotchas\n\n- **Optional tenancy**: all models `@TenantScoped({ mode: 'optional' })` + nullable tenantId\n- **Money units and arithmetic**: money fields use signed integer minor units; rates and quantities remain decimal where their contracts require them. Exact rounding, tax-code resolution, safe-integer validation, and journal units are defined in the [commercial money model](agents/money-model.md) and [money calculator](agents/money-calculator.md). Do not reintroduce floating-point tolerances on money paths.\n- **Money documents need a tenant**: models are optionally tenant-scoped, but every Invoice and Contract money write requires one (`MoneyValidationError` `INVALID_MONEY_INPUT`, `Commerce money documents require a tenant`).\n- **Earlier-version money data is refused**: never add a read or conversion path for it. Detection and the one-shot upgrade are in [money data upgrade](agents/money-upgrade.md).\n- **Book currency is required**: `recognizeRevenue()` and `cancelWithRevenueReversal()` take a required `bookCurrency`, which must equal the invoice currency.\n- **Asset-native amounts stay outside line rescales**: `Payment.nativeAmount` and `PaymentIntent.paymentOptions[].nativeAmount` are per-asset values identified by `nativeCurrency`; normalize each asset to its own minor unit before any type conversion, and never apply the commerce ×100 line-money rescale to them.\n- **Invoice controls payment status**: not the Payment model — use `Invoice.updatePaymentStatus()`\n- **Tax comes from tax codes**: the server resolves each line's code and computes line tax and header totals; client totals and a line's stored `taxRate` are never inputs\n- **Profile linking**: separate `ProfileCollection.create()` needed to fetch actual Profile object\n- **PaymentIntent natural key**: `conflictColumns: ['tenant_id', 'offering_ref', 'licensee_email', 'idempotency_key']` — a retried `create` with the same tuple upserts the existing row. Use `PaymentIntentCollection.getOrCreateByIdempotencyKey()` to branch on `{ intent, created }`. Empty natural-key inputs (e.g. blank `idempotencyKey`) disable dedup by design.\n- **Payout state-machine guards**: `markSent` requires a non-empty `backendTxRef`; `markConfirmed` only valid from `SENT`; `markFailed` only valid from `PENDING` / `SENT` (a confirmed payout can't fail — that path is a refund). `resetFromFailed()` is the dedicated escape hatch from `FAILED` back to `PENDING` after an operator fixes the underlying problem; it clears `backendTxRef` so the next attempt picks up a fresh one.\n- **LicenseSale immutability**: rights snapshot freezes on save-with-status-ACCEPTED. The captured snapshot lives in a module-scoped `WeakMap<LicenseSale, string>` so it doesn't interact with the schema or round-trip through `_meta_data`. Drafts (status != ACCEPTED) remain mutable. To \"change\" an issued license: `revoke()` it, then issue a new `LicenseSale` row.\n- **Vendor.payoutAddresses normalization**: the constructor accepts either a `Record<string, string>` or a pre-serialized JSON string. `initialize()` re-normalizes after the framework's option-override pass; `save()` re-normalizes defensively against direct field assignment. Non-string values inside the input map are silently dropped to preserve the typed invariant downstream.\n\n## Commercial UI\n\n`CustomerSelect`/`VendorSelect` are the registered selectors for Customer and\nVendor (`selects` in `src/ui.ts`); models carry `ui.widget` / `ui.format` hints. See\n[customer/vendor UI](agents/customer-vendor-ui.md#selectors-3602).\n\nSee [commercial UI composition](agents/commercial-ui.md) for native form recovery, amount compatibility and backend ownership. Package-owned guides under `agents/` ship with the package.\n\n## Quote and estimate UI\n\n`src/svelte/quote-types.ts` separates unparsed draft strings from explicit\nminor-unit revision DTOs. Native row submitters, caller-owned retry identity and\nextension conventions are documented in [agents/quote-ui.md](agents/quote-ui.md).\n\n## Purchasing UI\n\n`PurchaseOrderEditor` preserves allocation IDs and explicit zeroes, including\nretained reduction rows; the server validates review fingerprints before recording.\nSee [agents/purchasing-ui.md](agents/purchasing-ui.md) for caller responsibilities.\n\n## Exact cost billing\n\nPure signed cost billing and explicit tax rounding are available through the\nindependent `cost-billing` subpath; see [contract](agents/cost-billing.md).\n\nSee [contract billing schedules](agents/contract-billing-schedules.md) for exact\napproved milestone capacity, immutable amendments and atomic canonical invoice issue.\n\nSee [estimate conversion](agents/estimate-conversion.md) for turning an accepted\nEstimate into an idempotent Order with copied lines and lineage.\n\n## Customer funds (#4079)\n\nSee [customer advances](agents/customer-funds.md) for explicitly configured\nunapplied-AR/deposit-liability receipts, conserved application/refund capacity,\nreal liability reclassification, final-invoice attestation and mutation guards.\nUse the public commands; `Payment.customerFundsJson` is command-owned.\n\nSee [observed purchase prices](agents/observed-purchase-prices.md) for incomplete\noriginal supplier prices, explicit unknown totals and reviewed completion.\nSee [received sales agreement money](agents/received-sales-contract-money.md) for\nexact complete source Order/Agreement evidence without synthetic lines or tax recognition.\n\nSee [ordinary invoice accounting adjustments](agents/ordinary-accounting.md) for\nnon-retained provider credit applications, recorded refunds and durable recovery.\n\n## Protected billable sources (#4746)\n\n`invoice-source-binding.ts` is the generic pointer/guard contract for an owning\npackage's existing capacity reservation. It creates no capacity ledger. Trusted\npackages register qualified `billable:` source handlers; missing handlers and\nunbound protected lines fail closed at issue. `InvoiceLineItem.sourceReservationId`\nis command-owned; line save/delete, collection deletion, invoice cascade deletion\nand issue validate persisted identities. Release/unbind must share the owning\nreservation transaction. See [source binding](agents/invoice-source-binding.md).\n",
|
|
23632
|
+
"agentDoc": "# @happyvertical/smrt-commerce\n\nE-commerce with Contract STI hierarchy, invoice lifecycle, payment tracking, payout remittance, and optional ledger integration.\n\n## Models\n\n- **Customer** / **Vendor**: linked to Profile via string ID (not FK). `contacts` (JSON) is written via [`savePartyContacts()`](agents/customer-vendor-ui.md#contact-rows-3501). Customer has creditLimit, paymentTerms, customerType (DTC / WHOLESALE / RETAIL). Vendor has leadTimeDays, minimumOrder, and `payoutAddresses: Record<string, string>` — a flat map from payout-rail-qualified currency code (`USDC-base`, `BTC`, `USD-stripe`, ...) to destination string (EVM address, BTC address, Stripe Connect account id, IBAN). Use `getPayoutAddress(currency)` for a `Map.get`-style lookup; missing entries return `undefined` (caller decides skip-vs-error).\n- **Contract**: concrete STI base. Abstract **SalesContract** owns `customerId`; **PurchaseContract** owns `vendorId`. `channelId` is open-ended. Before upgrade, run `preflightCommercePartyLinks(db)` and repair linked base rows, stray parties, and wrong-branch links. See [README](README.md).\n- **WholesaleOrder**: B2B order. Conventional pairing — customer has `customerType: 'wholesale'`, NET-30/60 terms, delivered via wholesale-portal channel.\n- **ProductionOrder**: manufacturing equivalent of a PurchaseOrder — commission your factory to make finished goods. Consumes raw materials per BOM (`@happyvertical/smrt-manufacturing`) and produces SKU stock (`@happyvertical/smrt-inventory`).\n- **Cart**: transient order-in-progress. Same shape as Order; the application promotes the row from `_meta_type: Cart` to `_meta_type: Order` at checkout instead of copying data between tables.\n- **LicenseSale**: industry-neutral licensing primitive. Carries an *immutable* rights snapshot (`rightsMedium`, `rightsDistributionScope`, `rightsExclusivity`, `rightsDuration`, `rightsTerritory`, `rightsSublicensing`, `rightsDerivatives` — typed `Meta<T>` fields), licensee identity (`licenseeEmail`, optional `licenseeLegalEntity` / `licenseeJurisdiction`), and a signed-PDF reference (`pdfUrl`, `pdfHash`, optional `onChainHashRegistryRef`). Once saved at `ContractStatus.ACCEPTED`, the rights snapshot is frozen — mutating any of the seven rights fields and re-saving throws. The only legal transition out of ACCEPTED is `revoke()` (moves to CANCELLED without touching rights). Useful for stock media, music licensing, code-asset marketplaces, license keys, anywhere rights are sold for a fee.\n- **ContractLineItem**: items on contracts.\n- **Invoice**: status machine `DRAFT → SENT → VIEWED → PARTIAL → PAID` (also OVERDUE, CANCELLED, WRITTEN_OFF). `recognizeRevenue()` creates balanced AR journal entry (DR: Accounts Receivable, CR: Revenue, CR: Tax Payable).\n- **InvoiceLineItem**: fractional-quantity line items with safe minor-unit validation/recalculation on save; the existing-column migration is documented in [invoice quantity persistence](agents/invoice-quantity.md).\n- **Payment** / **PaymentAllocation**: tracks payments against invoices (status: see Gotchas). Carries optional backend-adapter fields for PaymentBackend-routed flows: `backendId` (rail adapter id — `base-usdc`, `btc`, `stripe`, distinct from `externalProvider` which names an accounting sync destination), `backendTxRef` (chain tx hash or gateway settlement id), `nativeAmount` / `nativeCurrency` (what actually arrived), `usdAtQuote` / `usdAtConfirmation` (drift accounting for volatile-currency rails). `Payment.usdDrift()` returns the confirmation - quote delta, or `0` when either side is unset.\n- **PaymentInstrument**: reusable saved payment method (\"card on file\"). Stores only provider references and non-sensitive display metadata (`providerCustomerId`, `providerPaymentMethodId`, brand / last4 / expiry), never raw card data. `isDefault` is domain-managed, not API-writable: `PaymentInstrumentCollection.setDefaultForCustomer(customerId, instrumentId)` validates the target and clears the customer's other defaults (one per customer).\n- **PaymentIntent**: short-lived pre-payment commitment with multi-option semantics. Locks a USD price for a fixed window (default 15 minutes) and lists one or more `PaymentOption`s describing different rails (`backendId`, `currency`, `payTo`, `nativeAmount`, optional `chain` / `memo` / `x402Capable` / `expiresAt`). First option to receive payment wins; the others are implicitly retired. State machine `awaiting_payment → paid → (issued | retired)` plus `expired` and `cancelled`. Mutate via dedicated `markPaid` / `markIssued` / `expire` / `cancel` / `retire` helpers — direct status assignment bypasses the invariant checks. Idempotency: see the natural-key Gotcha.\n- **TenantPaymentAccount**: tenant-owned Stripe Connect account; direct charges with an application fee, account→tenant webhook routing, refunds, no platform fallback. Write only through `connected-payments.ts`; see [connected payments](agents/connected-payments.md).\n- **Payout**: operator-to-supplier remittance. Distinct from Payment because direction, status machine, and chain semantics differ. Status machine `pending → sent → confirmed → failed` (failed is terminal but resettable via `resetFromFailed()` after fixing the underlying problem). References source `paymentId` (plain string) and destination `vendorId` (foreign key). Amount invariant `supplierNet === grossAmount - operatorFee` enforced exactly on save (integer minor units, no tolerance — #2401). `PayoutCollection.createFromPayment()` is the typical entry point; it pulls native amount / currency from the source Payment.\n- **Fulfillment** / **FulfillmentLineItem**: shipment/delivery tracking.\n\n## Recipes (#3590)\n\n`src/recipes.ts` declares four minimal `SmrtRecipe`s, emitted into the built\n`manifest.json` and `smrt-knowledge.json` `recipes`: `commerce.customers`\n(Customer), `commerce.vendors` (Vendor), `commerce.sales` (Order, requires\ncustomers), `commerce.purchases` (PurchaseOrder, requires vendors). Headers\nonly; line items, fulfilment, invoices, and payments are later recipes. Each\nhas user-facing help in `src/<name>.recipe.md` (#3591), and the fields those\nrecipes show carry `@field({ description })` text; keep both in plain\nlanguage for end users and update them when a recipe's fields change. See\n[core recipes](../core/agents/recipes.md).\n\nQuickBooks for tenants (#5136-#5139): [connection](agents/accounting-connection.md), [mappings](agents/accounting-mapping.md), [live gate](agents/accounting-live-gate.md), [payment sync](agents/accounting-payment-sync.md).\nSee [historical issued sales](agents/historical-sales.md) for exact original source\nmoney, immutable source children and combined historical/live customer funds.\nSee [payment allocation integrity](agents/payment-allocations.md) for atomic splits,\nretry identity, parent corrections and supported dialects.\nSee [tax codes](agents/tax-codes.md) for tenant-owned rate components, default codes,\nand the standard codes every tenant gets.\nSee [document money persistence](agents/document-money.md) for the one money\nmodel: tax-code resolution, atomic aggregate writes, issued snapshots, and\nfrozen fields. Every Invoice and Contract money write needs a tenant. Host\nbootstrap is `ensureCommerceTenant(db, tenantId, { cookbook })`, which returns\n`{ tenantId }`. Money data written by an earlier version is refused with\n`COMMERCE_DATA_NEEDS_UPGRADE` until `smrt db:upgrade-commerce-money` converts\nit; see [money data upgrade](agents/money-upgrade.md).\nSee [Contract money persistence](agents/contract-money.md) for the Contract\naggregate and purchase recoverability.\n\n## Ledger Integration\n\n`@happyvertical/smrt-ledgers` is a regular dependency, loaded lazily via dynamic `import()` (never a static import) so the package graph stays a DAG (#1582). Invoice stores `arJournalId` and `revenueJournalId` as string references. `recognizeRevenue()` creates a balanced AR journal entry; `getArJournal()` returns null when no journal has been recognized yet.\n\n## Billing-period close (#3060)\n\n`src/billing/` closes periods from smrt-subscriptions charges; see the README\nfor usage.\n\n- **Port, not provider.** Period close, events, and credit checkout call only\n the `BillingProvider` port (integer minor units). `stripe.ts` adapts\n `@happyvertical/accounting`, which takes currency *major* units; convert with\n `units.ts` and never hand-roll a Stripe call here. `units.ts` exponents are\n an explicit ISO 4217 table matching the SDK's, never `Intl` display digits\n (CLDR differs for IQD, MGA, … and drifts by ICU release). The SDK's\n `*Minor` fields are already ISO minor units. Capabilities a rail may lack\n (`chargeSavedPaymentMethod`, `createSetupCheckout`, `getCheckout`,\n `setDefaultPaymentMethod`, `markInvoiceUncollectible`) are optional port\n methods: detect them by presence, and keep additions optional (#3139).\n `sendAndReconcile` refuses a provider invoice whose subtotal or total\n disagrees with the local invoice.\n- **Replay safety is identity.** Close, invoice, line, payment, allocation,\n and claim ids are `deterministicId()`s; `BillingLineSource` (conflict key\n `source_type, source_id`) is the only double-billing guard, so never bill a\n source without claiming it, and never widen that key. Each close step is\n persisted before the next; `acquireCloseLease()` serializes workers. A\n close that nets to a credit keeps its claims and ends `carried_forward`;\n its subtotal is a `credit_carry_forward` source for the payer's next billed\n close, which marks the carried close `completed`.\n- **Cycles and flat-plan coverage (#3116).** `cycles.ts` is the schedule\n (pure; `BillingAccount.billingAnchorAt`, null = calendar months). A close\n with no period closes each payer's `lastEndedBillingPeriod()`. Flat-plan\n claims are the exception to \"id from the source\": their `sourceId` is\n `<subscriptionId>:seq:<chainSequence>` and their `periodStart/End` is the\n exact time they bill. `claimFlatWindow()` reads the last number, then the\n coverage (claims ending after the window start), claims one gap as number\n n + 1, and retries on conflict; reading in that order is what makes it\n safe. That numbering, not the period, stops overlaps when schedules or\n payers change — never claim a flat plan outside it, and keep both reads\n bounded (no whole-history scans). Each numbered claim is its own invoice\n line keyed `lineKey|periodStart` (a function of the claim alone, so a\n resumed close rebuilds the same line ids). Proration is\n `prorateMinorUnits()` (half up, BigInt) against the period's full cycle.\n- **System tables.** `BillingAccount`, `BillingPeriodClose`, and\n `BillingLineSource` are not tenant-scoped and have no generated surface.\n Collections stay unexported; models are root exports (#3082). Invoices,\n payments, and journals are written in the seller's tenant; payer-owned\n subscriptions and credit grants in a system context, only after\n verification.\n- **Events** use smrt-jobs' delivery inbox under provider\n `<name>-billing:<sellerTenantId>` and a provider-filtered\n `ForgeProjectionRuntime`, so a runtime never claims another seller's\n events; any other runtime sharing the inbox must pass `providers` too. Only\n events this package acts on are stored: foreign checkouts are `ignored`,\n and only `smrt_*` checkout metadata is kept; it is\n HMAC-signed with the webhook secret at creation (empty values are omitted:\n Stripe drops them), so another integration on the same account cannot forge\n a credit purchase or a card setup; credit is granted only when the\n collected total equals it plus provider tax. Checkout amounts come from the\n re-read session (`getCheckout()`), never the Stripe event, whose amounts are\n in Stripe's unit. Rotating the webhook secret strands in-flight checkouts\n (up to 24 h). `observe()` re-reads provider state, so ordering never depends\n on delivery order; the only provider writes in `observe()` are idempotent\n (making a saved card the default). The standing hook runs inside the event\n transaction and must be idempotent.\n- **Card on file and top-ups (#3139).** A saved card is the payer customer's\n default `PaymentInstrument` (seller tenant, id from the provider method).\n `autoChargeInvoices` bills such payers `charge_automatically`, decided once\n and saved as `Invoice.collectionMethod` before the first push, which every\n retry reuses (never recompute it: a lost push response would record a\n method the provider was not asked for, #3190); activation follows `paid`, never send. An auto top-up attempt\n is a `PENDING` `Payment` (`reference` `auto-top-up:<policyId>`, id from the\n policy and `count()` of its attempts) inserted before the charge, so racing\n evaluations derive one id and one charge; the charge key is derived from\n that id. `applyAutoTopUpOutcome()` must run in a transaction and starts with\n a conditional `UPDATE … WHERE status = 'pending'` row lock, so the hook and\n the `payment` webhook settle once; the grant is keyed by the charge key.\n Never settle an attempt outside that function. Taxed accounts are charged\n with provider tax by default (#3194): the attempt row holds the credit\n (the charge subtotal), the tax is journaled to tax payable at settlement,\n and the attempt's tax decision is recorded in its `notes` so a re-drive\n repeats the same charge request (the provider refuses a key reused with\n different tax). `claimAttempt()` is the only place that decides a\n skip and reports it (`onAutoTopUpSkipped`); `cardOnFile()` and period close\n use `defaultCardInstrument()` — never copy that predicate. A provider write-off moves the local invoice to\n `WRITTEN_OFF` (a later payment, by card or on a rail (#3188), is recorded\n and reinstates the payer; the status stays, so \"paid in full\" for a\n written-off invoice is read from its allocations).\n- **Billing invoices are money-model invoices.** The provider taxes them\n (`providerTaxAmount`, server-managed, not API-writable, added to line tax),\n so every billing line is an explicit `taxMode: 'override'` to the seller's\n `out-of-scope` code. Charges are written before credits so the running\n subtotal never goes negative, and provider tax is written in the save that\n issues the invoice. Revenue posting is idempotent. `ledger.bookCurrency` is\n required (ISO 4217, validated by `BillingRuntime`) and must equal the\n billing currency. `toAccountingInput({ mapping })` emits major units.\n- **Payment rails (#3138).** A runtime has one issuing `provider` and any\n number of `paymentProviders` (unique names, one inbox namespace each; a\n provider with `capabilities.issuesInvoices === false` can never issue).\n `observe()` resolves the provider from the delivery namespace, never the\n payload. Crypto rails implement the port over `@happyvertical/payments`'\n `CryptoCheckoutGateway`; never call BTCPay (or any gateway) from here.\n Settlement is decided by the pure `decideAttempt()` from gateway state and\n `paymentPolicy` — the gateway's `settled` is authoritative and nothing here\n counts confirmations. A `BillingPaymentAttempt` (`(provider, checkout_id)`\n deterministic id) records every state and settles once; grants and payments\n are keyed by checkout id. Invoice payments close the issuer's invoice out of\n band in `observe()` (idempotent) before `project()` records the payment, and\n `settlePaidInvoice` skips (records nothing for) a `paidOutOfBand` invoice\n the rail latched with `outOfBandRequestedAt`; other out-of-band closes are\n recorded as `OTHER` payments. Rails never save cards or charge tax: a taxed\n credit purchase on a rail needs an explicit `automaticTax: false`. Exceptions are flags for operators;\n nothing reverses or refunds automatically.\n- **Known limits**: write-offs post no bad-debt journal (AR stays until paid\n or journaled by an operator); discounts still reach Stripe as negative lines (the SDK's\n line `discount` would change the lines a replayed push reconciles, so it\n needs its own migration); `RetailCharge` has no adjustment ledger. Flat\n plans are monthly, in arrears; plan changes are not prorated (#3119).\n\n## Cross-Package References\n\n- `customerId` → `@foreignKey('Customer')` (hard reference within package)\n- `vendorId` → `@foreignKey('Vendor')` on PurchaseContract only\n- `profileId` → plain string to smrt-profiles\n- `arJournalId`, `revenueJournalId` → plain string to smrt-ledgers\n- `skuId` (on `PaymentIntent`, `LicenseSale`) → plain string to smrt-products\n- `paymentId` (on `PaymentIntent`, `Payout`, `LicenseSale`) → plain string to `Payment` (same package, but kept as plain string for cross-model consistency)\n- `vendorId` on `Payout` → `@foreignKey(Vendor)` (hard reference within package)\n- Billing records reference tenants with `@crossPackageRef('@happyvertical/smrt-users:Tenant')` and charges, plan periods, and adjustments by plain `sourceId`\n\n## Gotchas\n\n- **Optional tenancy**: all models `@TenantScoped({ mode: 'optional' })` + nullable tenantId\n- **Money units and arithmetic**: money fields use signed integer minor units; rates and quantities remain decimal where their contracts require them. Exact rounding, tax-code resolution, safe-integer validation, and journal units are defined in the [commercial money model](agents/money-model.md) and [money calculator](agents/money-calculator.md). Do not reintroduce floating-point tolerances on money paths.\n- **Money documents need a tenant**: models are optionally tenant-scoped, but every Invoice and Contract money write requires one (`MoneyValidationError` `INVALID_MONEY_INPUT`, `Commerce money documents require a tenant`).\n- **Earlier-version money data is refused**: never add a read or conversion path for it. Detection and the one-shot upgrade are in [money data upgrade](agents/money-upgrade.md).\n- **Book currency is required**: `recognizeRevenue()` and `cancelWithRevenueReversal()` take a required `bookCurrency`, which must equal the invoice currency.\n- **Asset-native amounts stay outside line rescales**: `Payment.nativeAmount` and `PaymentIntent.paymentOptions[].nativeAmount` are per-asset values identified by `nativeCurrency`; normalize each asset to its own minor unit before any type conversion, and never apply the commerce ×100 line-money rescale to them.\n- **Invoice controls payment status**: not the Payment model — use `Invoice.updatePaymentStatus()`\n- **Tax comes from tax codes**: the server resolves each line's code and computes line tax and header totals; client totals and a line's stored `taxRate` are never inputs\n- **Profile linking**: separate `ProfileCollection.create()` needed to fetch actual Profile object\n- **PaymentIntent natural key**: `conflictColumns: ['tenant_id', 'offering_ref', 'licensee_email', 'idempotency_key']` — a retried `create` with the same tuple upserts the existing row. Use `PaymentIntentCollection.getOrCreateByIdempotencyKey()` to branch on `{ intent, created }`. Empty natural-key inputs (e.g. blank `idempotencyKey`) disable dedup by design.\n- **Payout state-machine guards**: `markSent` requires a non-empty `backendTxRef`; `markConfirmed` only valid from `SENT`; `markFailed` only valid from `PENDING` / `SENT` (a confirmed payout can't fail — that path is a refund). `resetFromFailed()` is the dedicated escape hatch from `FAILED` back to `PENDING` after an operator fixes the underlying problem; it clears `backendTxRef` so the next attempt picks up a fresh one.\n- **LicenseSale immutability**: rights snapshot freezes on save-with-status-ACCEPTED. The captured snapshot lives in a module-scoped `WeakMap<LicenseSale, string>` so it doesn't interact with the schema or round-trip through `_meta_data`. Drafts (status != ACCEPTED) remain mutable. To \"change\" an issued license: `revoke()` it, then issue a new `LicenseSale` row.\n- **Vendor.payoutAddresses normalization**: the constructor accepts either a `Record<string, string>` or a pre-serialized JSON string. `initialize()` re-normalizes after the framework's option-override pass; `save()` re-normalizes defensively against direct field assignment. Non-string values inside the input map are silently dropped to preserve the typed invariant downstream.\n\n## Commercial UI\n\n`CustomerSelect`/`VendorSelect` are the registered selectors for Customer and\nVendor (`selects` in `src/ui.ts`); models carry `ui.widget` / `ui.format` hints. See\n[customer/vendor UI](agents/customer-vendor-ui.md#selectors-3602).\n\nSee [commercial UI composition](agents/commercial-ui.md) for native form recovery, amount compatibility and backend ownership. Package-owned guides under `agents/` ship with the package.\n\n## Quote and estimate UI\n\n`src/svelte/quote-types.ts` separates unparsed draft strings from explicit\nminor-unit revision DTOs. Native row submitters, caller-owned retry identity and\nextension conventions are documented in [agents/quote-ui.md](agents/quote-ui.md).\n\n## Purchasing UI\n\n`PurchaseOrderEditor` preserves allocation IDs and explicit zeroes, including\nretained reduction rows; the server validates review fingerprints before recording.\nSee [agents/purchasing-ui.md](agents/purchasing-ui.md) for caller responsibilities.\n\n## Exact cost billing\n\nPure signed cost billing and explicit tax rounding are available through the\nindependent `cost-billing` subpath; see [contract](agents/cost-billing.md).\n\nSee [contract billing schedules](agents/contract-billing-schedules.md) for exact\napproved milestone capacity, immutable amendments and atomic canonical invoice issue.\n\nSee [estimate conversion](agents/estimate-conversion.md) for turning an accepted\nEstimate into an idempotent Order with copied lines and lineage.\n\n## Customer funds (#4079)\n\nSee [customer advances](agents/customer-funds.md) for explicitly configured\nunapplied-AR/deposit-liability receipts, conserved application/refund capacity,\nreal liability reclassification, final-invoice attestation and mutation guards.\nUse the public commands; `Payment.customerFundsJson` is command-owned.\n\nSee [observed purchase prices](agents/observed-purchase-prices.md) for incomplete\noriginal supplier prices, explicit unknown totals and reviewed completion.\nSee [received sales agreement money](agents/received-sales-contract-money.md) for\nexact complete source Order/Agreement evidence without synthetic lines or tax recognition.\n\nSee [ordinary invoice accounting adjustments](agents/ordinary-accounting.md) for\nnon-retained provider credit applications, recorded refunds and durable recovery.\n\n## Protected billable sources (#4746)\n\n`invoice-source-binding.ts` is the generic pointer/guard contract for an owning\npackage's existing capacity reservation. It creates no capacity ledger. Trusted\npackages register qualified `billable:` source handlers; missing handlers and\nunbound protected lines fail closed at issue. `InvoiceLineItem.sourceReservationId`\nis command-owned; line save/delete, collection deletion, invoice cascade deletion\nand issue validate persisted identities. Release/unbind must share the owning\nreservation transaction. See [source binding](agents/invoice-source-binding.md).\n",
|
|
22425
23633
|
"moduleDocs": [
|
|
22426
23634
|
{
|
|
22427
23635
|
"path": "agents/customer-vendor-ui.md",
|
|
@@ -22443,6 +23651,26 @@
|
|
|
22443
23651
|
"module": "connected-payments",
|
|
22444
23652
|
"content": "# Tenant-owned connected payment accounts (#3831)\n\nA tenant (for example a co-op) is paid into its own Stripe Connect **Standard**\naccount. Checkouts are direct charges on that account, the platform's share is\nan application fee, and the platform never holds the tenant's money. Source:\n`src/connected-payments.ts`, `src/models/TenantPaymentAccount.ts`,\n`src/models/TenantPaymentWebhookEvent.ts`.\n\n## Model\n\n`TenantPaymentAccount { tenantId, backendId, environment, providerAccountId,\nstatus, chargesEnabled, detailsSubmitted, payoutsEnabled, capabilitiesJson,\ncapabilitiesObservedAt, feePolicyRef, disabledAt, disabledReason }`.\n\n- Tenant-scoped (`required`), native UUID tenant ids. Two unique indexes:\n `(tenantId, backendId, environment)` and\n `(backendId, environment, providerAccountId)`, so the database refuses a\n second owner of a provider account even if a command check were bypassed.\n- `status`: `pending` (details not submitted), `restricted` (details\n submitted, charges or payouts off), `enabled` (charges, details and payouts\n all on), `disabled` (operator; refreshes keep it off). Only `enabled` takes\n new charges.\n- Read-only generated surface (REST, MCP and CLI: `list`/`get` and read methods only); never deleted. `save()` refuses any write outside the\n commands, any change of tenant/backend/environment, and a provider account\n change outside the relink command.\n- Connected `Payment` rows and connected `PaymentIntent` creation/option\n writes need the commands' internal authority (`connected-payments-internal.ts`,\n per tenant), so no generated REST/MCP/CLI write can forge or advance them;\n connected payments and refunds are never deleted. A checkout's identity\n includes its environment (`PaymentIntent.connectedEnvironment`): the same\n `acct_` id exists in test and live.\n- `TenantPaymentWebhookEvent` (`_smrt_tenant_payment_webhook_events`, system\n table, unique `(backendId, environment, eventId)`) stores processed event ids;\n the SDK's dedupe is in memory only.\n- `PaymentIntent` and `Payment` gain server-managed `connectedAccountId` and\n `applicationFeeCents` (`Payment` also `refundOfPaymentId` and\n `connectedRefundState`), frozen once settled. A connected intent settles only\n with a Payment on the same account and fee, and its account, fee and payment\n options (which name the provider session settlement re-reads) are frozen\n from creation, so a generated update cannot repoint it. A connected\n `Payment` (charge or refund) keeps its kind, amounts, currency, provider\n references, account, fee and refunded payment from its first write, even\n while pending.\n\n## Commands\n\nAll take an explicit `tenantId` and check ownership against it, so a\nprivileged or system caller is refused the same way. There is no fallback to\nthe platform account.\n\n| Command | Does |\n|---|---|\n| `onboardTenantPaymentAccount` | Create the Standard account (per-tenant idempotency key) and store it; returns the existing one on retry. |\n| `createTenantOnboardingLink` | Single-use onboarding URL. A bearer secret: redirect, never log or store. |\n| `linkTenantPaymentAccount` | Link an existing account; `replace: true` relinks. Refused (`ACCOUNT_IN_USE`) when another tenant holds it or its `smrt_tenant_id` metadata names another tenant. An account whose metadata names no tenant needs `ownershipVerified: true` (the host proved control, for example Stripe OAuth). |\n| `refreshTenantPaymentAccount` | Snapshot from `getAccountCapabilities`, re-derive status. |\n| `setTenantPaymentAccountDisabled`, `setTenantPaymentFeePolicy` | Operator switches. |\n| `requireEnabledTenantPaymentAccount` | Throws `NO_ENABLED_ACCOUNT` unless enabled. |\n| `createConnectedCheckout` | Checkout on the tenant's account with `stripeAccount` + `applicationFeeAmount` (integer minor units from the caller's fee policy; `0` for none; below the amount). The intent (account, environment, fee, expiry) is recorded before the provider call and the option naming the provider session is added once, so a retry replays the same request (the expiry is part of the provider idempotency key) and recovers a lost answer; once the recorded expiry is under 31 minutes away the retry asks for a fresh session with a renewed expiry (the lost URL never reached the buyer). The requested amount and currency are recorded too: a retry with a different price, environment, account or fee is refused; a retry of a paid checkout returns it with `settled: true` (no URL; never charge again); a retry of an unpaid closed (expired, cancelled or lapsed) quote gets `QUOTE_CLOSED`; an explicit `expiresAt` too close to replay must be replaced by the caller. |\n| `handleConnectedPaymentWebhook` | See below. |\n| `refundConnectedPayment` | Refund on the tenant's account; `refundApplicationFee` is required; partial and full. The refund row is written (`requested`, holding its amount) before the provider is asked; only a provider-`succeeded` refund is journaled, `pending` waits for the refund update, `failed` (including a first request the SDK refused before sending) releases the amount; a re-sent request must repeat its `refundApplicationFee` (stored in the frozen `applicationFeeRefunded`). A retry with the same key returns a recorded result, or re-sends a lost request with the same provider idempotency key within 23 hours (older lost requests wait for the refund update). Once booked refunds cover the payment it is marked `REFUNDED` and its intent retired. |\n| `createStripeConnectGateway` | Platform `StripeAdapter` from smrt-secrets. |\n\n## Webhooks\n\n`handleConnectedPaymentWebhook({ db, gateway, environment, endpoint, payload,\nsignature, resolveSettlementAccounts })`:\n\n1. The SDK verifies the signature **before** routing, then maps the event's\n connected account to its `TenantPaymentAccount` (cross-tenant read under\n `withSystemContext`, the one reviewed cross-tenant path). Unknown accounts\n throw the SDK's `PaymentNotOwnedError`.\n2. The event's `livemode` must match `environment` (`ENVIRONMENT_MISMATCH`).\n3. A stored event id returns `{ duplicate: true }` with its first outcome (and the `application_fee` details, so a host can still book them).\n4. `account.updated` applies the snapshot unless an earlier second than the\n stored one (`stale_account_update`). `application_fee.*` (platform endpoint,\n `endpoint: 'platform'`) is routed to the tenant and reported, not booked.\n A payment event loads the quote **in the resolved tenant** and refuses\n (`QUOTE_NOT_OWNED`) unless it belongs to that tenant and account, then\n re-reads the Checkout Session from the provider, so delivery order never\n matters. A provider-confirmed checkout settles even when its notice\n arrives after the price lock (the session expires with the lock); a\n payment confirmed for a quote already expired or cancelled is reported\n `late_payment` and posts nothing. `account.updated` reloads the row and\n refuses an event for a provider account the row no longer holds; a\n concurrent operator write fails the revision-guarded save (retried by the\n provider). Refund updates (`charge.refund.updated`, `refund.*`) book or fail\n a pending refund recorded by `refundConnectedPayment` on that account;\n terminal states never move back. Refunds made by the command carry\n `metadata.smrt_refund_id` and are matched by it (an unknown one throws\n `REFUND_NOT_RECORDED`; an amount differing from the row throws\n `AMOUNT_MISMATCH`). Refunds made elsewhere are reported. Settlement records a `Payment` (deterministic id from the intent)\n through `recordPayment()` and marks the intent paid. `refunded` events are\n reported (`refund_reported`), never booked automatically.\n5. Connected `charge.dispute.*` events re-read the typed dispute through the\n public SDK (`gateway.getDispute`, optional for older custom gateways but\n required for dispute delivery), scoped to the verified account and environment. They locate one\n settled payment in that tenant by provider payment-intent/charge reference;\n when none exists, `gateway.lookupCheckout` resolves authoritative ownership\n by PaymentIntent/Charge in that same account and environment. Only a complete\n provider `no_match` is acknowledged as `dispute_reported`, without any journal\n or dispute projection. A matched quote must belong to a persisted intent in\n that tenant/account/environment (and match the saved session when present);\n a missing local settlement then refuses delivery (`DISPUTE_NOT_RECORDED`)\n until settlement arrives, including when checkout creation lost its response\n and saved no option. Unknown quote/tenant/account/environment, conflicting\n session identity, ambiguous or incomplete lookup and provider failure refuse\n delivery. An older custom gateway without `lookupCheckout` refuses this\n zero-settlement case with `CONFIGURATION`; it never guesses from absent rows.\n Unknown statuses or balance transaction kinds,\n currency conversions, changed evidence and missing fee configuration refuse\n delivery for operator reconciliation. No dispute is acknowledged as ignored.\n6. The event id is stored only after processing succeeds; a refusal throws,\n so respond non-2xx and nothing unprocessed is acknowledged.\n\n## Accounting\n\nThe direct charge arrives net of the fee, which the provider withheld at\nsource: `recordPayment()` debits cash `amount - fee`, debits\n`applicationFeeAccountId` `fee`, and credits receivables `amount`. The fee is\nan expense already paid, never a payable to the platform. A payment with a fee\nand no `applicationFeeAccountId` is refused. Refund journals reverse the\nrefunded amount; a refunded application fee is reported by\n`application_fee.refunded` for the host to book.\n\n## Dispute accounting and recovery (#4262)\n\n`TenantPaymentDispute` is a tenant-owned, command-written projection with no\ngenerated API/CLI/MCP surface. Its retained snapshot records provider lifecycle\nand all posted balance transaction evidence. A payment revision fence serializes\nreconciliation before the authoritative provider read. Every new provider\nbalance transaction gets one deterministic, posted journal in the same database\ntransaction as the snapshot. A crash rolls back both; a crash saving the inbox\nreplays the snapshot safely. Duplicate event ids return `paymentId` too. A\nredelivery whose historical outcome is `ignored` is reconciled and updates that\ninbox outcome; other processed outcomes stay deduplicated.\n\nPosts use provider integer minor units, never lifecycle status as money proof:\ncash changes by `net`, receivables by `-amount`, dispute fee expense by `fee`.\nFor example, a 10,000 withdrawal with a 1,500 fee credits cash 11,500, debits AR\n10,000 and expense 1,500. A reinstatement posts the opposite balances from its\nown provider transaction. Configure `disputeFeeAccountId` on the settlement\naccounts whenever fees occur. The provider's balance transaction must be an\n`adjustment`, with optional category `dispute` or `dispute_reversal`, and in the\nsettlement currency. Unknown contracts fail closed until supported explicitly.\n\nOriginal payment, invoice allocations, payouts, refund rows and settlement\njournals remain historical evidence. Reconciliation records the resulting\nreceivable even when the invoice was already paid or a supplier payout confirmed;\nit does not collect the debt, unwind an allocation, reverse a supplier remittance,\nor send a provider refund. Hosts must show/recover that receivable operationally.\nLifecycle updates with no balance evidence record status and post no money.\n\nBefore deployment, run the normal commerce schema migration to add\n`tenant_payment_disputes` and the webhook event's optional `paymentId` column.\nReplay previously ignored deliveries by having the provider redeliver the original\nsigned Connect webhook to the updated endpoint (a fresh valid signature is\nrequired; do not bypass signature validation or manually delete inbox history).\nOrdering uses current provider state, so redelivering an older event after a\nclosed dispute cannot revert its postings. Retain the original connected account\nmapping: relinking remains an explicit operation that strands old-account events.\nThe complete Payment/ledger contract runs on SQLite and PostgreSQL; the existing\nDuckDB checkout-only lane does not support Payment's full FK closure.\n\n## Operator setup\n\n- smrt-secrets (held by the installation tenant, `secretsTenantId`):\n `stripe-connect-<env>-secret-key` (`sk_`/`rk_` key of that environment),\n `stripe-connect-<env>-webhook-secret` (platform endpoint),\n `stripe-connect-<env>-connect-webhook-secret` (Connect endpoint). Values\n never appear in errors.\n- Stripe: one platform endpoint (`application_fee.created`,\n `application_fee.refunded`) and one Connect endpoint (`account.updated`,\n `checkout.session.completed`, `checkout.session.async_payment_succeeded`,\n `checkout.session.async_payment_failed`, `checkout.session.expired`,\n `charge.refunded`, `charge.refund.updated`, `charge.dispute.created`,\n `charge.dispute.updated`, `charge.dispute.closed`,\n `charge.dispute.funds_withdrawn`, `charge.dispute.funds_reinstated`), per environment.\n- Each tenant needs ledger accounts for cash, receivables and the platform fee\n expense, returned by `resolveSettlementAccounts`.\n\n## Known limits\n\nA `requested` refund the provider never made (a request lost in transport\nand not retried within 23 hours, or one the provider rejected — the SDK does\nnot expose the HTTP status, so a rejection cannot be told from an unreadable\nsuccess) holds its amount and books nothing until an operator resolves it.\nAutomatic reconciliation needs an SDK refund read and error status\n([sdk#1430](https://github.com/happyvertical/sdk/issues/1430)).\n\nRelinking strands open checkouts on the old account and refuses refunds of\nits payments (`ACCOUNT_NOT_OWNED`). Concurrent refunds with different keys are\ncapped by the provider, not locally. Payments confirmed after an intent\nexpired or was cancelled are reported `ignored` for an operator.\n\n## Frozen fee-policy provenance (#4263)\n\nAt the authoritative price calculation, pass `feePolicyRef` to\n`createConnectedCheckout`: an opaque immutable version reference (for example\n`bakery-membership:version:1`). It is host-attested evidence, not a lookup or an\nauthorization grant; the host must resolve and authorize the policy within the\nexplicit tenant before calling. This command validates account ownership and\nnever reads another tenant's policy. Nonempty references cannot contain leading\nor trailing whitespace. Omission stores the empty string for unversioned hosts.\n\nThe intent's server-managed `connectedFeePolicyRef` freezes **before** the\nprovider request, alongside price and fee, including when that request fails.\nEvery retry must repeat the original reference, even when a new agreement\nversion yields the same cents. A mismatch is refused before any provider call.\nKeep `offeringRef` and `idempotencyKey` tied to the purchase; changing them to\nencode an amendment would create another charge. Amendments to the account's\nlive `feePolicyRef` cannot rewrite a checkout. The reference follows settlement\nto `Payment` and any command-created refunds and cannot be edited there.\nExisting checkouts with no reference accept only an omitted reference on retry;\nthey are never retrospectively attributed to the current account policy.\n"
|
|
22445
23653
|
},
|
|
23654
|
+
{
|
|
23655
|
+
"path": "agents/accounting-connection.md",
|
|
23656
|
+
"module": "accounting-connection",
|
|
23657
|
+
"content": "# Tenant accounting connection (#5136)\n\nA tenant connects one QuickBooks Online company. Source:\n`src/accounting-connection.ts`, `src/models/AccountingConnection.ts`.\n\n## Why smrt-commerce\n\nCommerce already owns accounting sync (`syncFrozenInvoiceToAccounting`), depends\non `@happyvertical/accounting`, and takes smrt-secrets through a structural port\n(`ConnectedPaymentSecretReader` precedent), so the connection, its mappings\n(#5137) and the live-mode gate (#5138) share one tenant/realm/environment scope\nwithout a new package or a dependency cycle. Commerce does not import\n`@happyvertical/smrt-secrets`; the app passes a `SecretService`\n(`AccountingSecretStore`: `storeForTenant`, `retrieveForTenant`,\n`deleteForTenant`).\n\n## Model\n\n`AccountingConnection { tenantId, provider, realmId, environment, status,\nlastError, lastErrorAt, connectedBy, connectedAt, disconnectedAt, tokenVersion,\nlastRefreshedAt, leaseToken, leaseExpiresAt }`, unique on `(tenantId,\nprovider)`. Tenant-level: no user owns it. Status `connected`, `needs_reconnect`\nor `disconnected`. The refresh token is only in smrt-secrets\n(`accounting-quickbooks-refresh-token`, category `accounting.quickbooks`); the\nrow holds a version counter, never token material. `lastError` is a code\n(`REAUTH_REQUIRED`), never provider text. Read-only generated surface; `save()`\nrefuses writes outside the commands; never deleted (it owns sync history).\n\n## Commands\n\n| Command | Does |\n|---|---|\n| `completeQuickBooksConnection(deps, { tenantId, realmId, environment, tokens, connectedBy })` | The completion hook for the shared OAuth connect flow (smrt#5128): the callback supplies `realmId`, environment and the exchanged tokens. Stores the refresh token, rebinds the tenant's row to `connected`, clears errors. Reconnecting reuses the row (the company may change). |\n| `withTenantQuickBooksProvider(config, tenantId, fn)` | Ready provider for the tenant's connection; apps never handle tokens. |\n| `disconnectQuickBooks(deps, { tenantId, oauth })` | Revoke at Intuit, delete the secret, mark `disconnected`; row and history stay. Idempotent. A failed revoke throws `REVOKE_FAILED` and changes nothing. |\n| `getAccountingConnection(deps, tenantId)` | Read the row. |\n\nErrors are `AccountingConnectionError` with `code` `INVALID_INPUT`,\n`NOT_CONNECTED`, `NEEDS_RECONNECT`, `LEASE_TIMEOUT` or `REVOKE_FAILED`.\n\n## Serialized rotation\n\nIntuit rotates the refresh token on every refresh and a fresh `QuickBooksProvider`\nhas no access token, so it refreshes on first use: two concurrent users of the\nstored token lose one. Locking only in `onTokenRefresh` would be too late (the\nrefresh already happened). Instead the whole first refresh runs under a\nper-connection **lease** (`leaseToken`/`leaseExpiresAt`): a conditional\n`UPDATE ... RETURNING` (SQLite and PostgreSQL), never a transaction held across\nthe Intuit call or the secret write. Waiters poll up to `waitMs`, then throw\n`LEASE_TIMEOUT`. Inside the lease the stored token is read, the provider is\ncreated with `onTokenRefresh` persisting the rotated token (before the lease is\nreleased), and `ensureAccessToken()` is called; `fn` then runs on the fresh\nprovider outside the lease. `completeQuickBooksConnection` and\n`disconnectQuickBooks` take the same lease, so an in-flight refresh cannot\noverwrite a fresh connect or resurrect a deleted secret.\n\nA rejected grant (sdk#1541 `AccountingReauthRequiredError`, detected\nstructurally as `code === 'REAUTH_REQUIRED'`, or raw `invalid_grant`) is\nre-checked: if the stored token changed meanwhile it retries once, otherwise the\nconnection becomes `needs_reconnect` and callers get `NEEDS_RECONNECT` without\nfurther provider calls, until `completeQuickBooksConnection` runs again.\n\n## SDK seams\n\n- `@happyvertical/accounting` sdk#1541: `AccountingReauthRequiredError`\n (`code: 'REAUTH_REQUIRED'`) and `QuickBooksOAuthClient.refresh`. smrt matches\n the error structurally and only needs `revoke` from the OAuth client.\n- A provider that accepts a seeded access token and expiry would avoid the\n refresh-per-provider; today every new provider refreshes once, which the lease\n covers. A later refresh by a long-lived provider (after about 55 minutes)\n persists through `onTokenRefresh` but is not leased: build providers per job.\n\n## Live mode\n\n`enableLiveAccounting` / `disableLiveAccounting` set the per-company production\nenablement the sync functions check; see [live-mode gate](accounting-live-gate.md).\n"
|
|
23658
|
+
},
|
|
23659
|
+
{
|
|
23660
|
+
"path": "agents/accounting-mapping.md",
|
|
23661
|
+
"module": "accounting-mapping",
|
|
23662
|
+
"content": "# Accounting mappings (#5137)\n\nSource: `src/accounting-mapping.ts`, `src/models/AccountingMapping.ts`. Replaces\nthe flat `Invoice.customerExternalId` and the hand-built\n`FrozenQuickBooksTaxMapping`.\n\n## Model\n\n`AccountingMapping { tenantId, provider, realmId, environment, kind, localId,\nexternalId, externalName, detailsJson, status, confirmedBy, confirmedAt,\ninvalidatedAt }`, unique on `(tenantId, provider, realmId, environment, kind,\nlocalId)`. Read-only generated surface; written only by the commands.\n\n| `kind` | `localId` | `externalId` |\n|---|---|---|\n| `customer` | commerce `Customer` id | provider customer id |\n| `tax_code` | commerce `TaxCode` id, or `none` for untaxed lines | provider TaxCode id; `details.taxComponents` holds the ordered provider rates for compound tax |\n| `tax_component` | commerce `TaxComponent` id | provider tax rate id |\n| `item` | `default` or `sku:<sku>` (sku wins) | provider product/service item |\n| `deposit_account` | `default` | provider clearing/deposit account (used by payment sync, #5139) |\n\n`realmId` and `environment` are in the key, so another company or the other\nenvironment never sees these rows. `completeQuickBooksConnection` also marks the\ntenant's mappings of the previous company/environment `invalidated` (kept for\nhistory, never used); `setAccountingMapping` reactivates a row.\n\n## Commands\n\n- `setAccountingMapping` / `removeAccountingMapping` / `getAccountingMapping` /\n `listAccountingMappings` (scope = `getAccountingMappingScope(db, tenantId)`,\n the connected company).\n- `buildFrozenInvoiceMapping({ db, tenantId, invoiceId })` returns a\n `QuickBooksFrozenInvoiceMapping` (realm, environment, `lines`, `components`,\n `customerRef`) from the records, so sync callers pass only the tenant and the\n document. Missing mappings throw `AccountingMappingError('MAPPING_INCOMPLETE')`\n with every missing `{ kind, localId }`, never a guess. `customerRef` replaces\n the flat invoice field in the sync (`mapping.customerRef`).\n- Customer resolution: `resolveAccountingCustomer` then, if needed,\n `confirmAccountingCustomer`.\n\n## Customer resolution\n\n1. An active mapping wins; the provider is not called.\n2. Otherwise `directory.find({ name, email })`. Exactly one match that agrees on\n email (or, without an email, on name) is linked and recorded.\n3. Several matches, or one that agrees on neither, return\n `needs_confirmation` with the candidates and change nothing. The operator\n calls `confirmAccountingCustomer` with a candidate (re-checked against the\n provider) or `'create'` on purpose.\n4. No match: `directory.create` with a stable `requestId` per\n (customer, realm, environment), then record the mapping. A crash between\n create and record is healed by step 2 (the next lookup finds it).\n\n## SDK seam (sdk#1539)\n\n`AccountingCustomerDirectory` (`find`, `create`) is the port; the host adapts\nthe SDK's customer find / find-or-create to it. smrt tests use fakes.\n\nOptional Svelte pickers are not included; the provider lists they need come from\nthe host (`directory`-style ports), and Work owns that presentation.\n"
|
|
23663
|
+
},
|
|
23664
|
+
{
|
|
23665
|
+
"path": "agents/accounting-live-gate.md",
|
|
23666
|
+
"module": "accounting-live-gate",
|
|
23667
|
+
"content": "# Live-mode gate on accounting sync (#5138)\n\nSource: `src/accounting-live-gate.ts`, `enableLiveAccounting` /\n`disableLiveAccounting` in `src/accounting-connection.ts`.\n\n`runQuickBooksPilot` refuses anything but a fixture sandbox, but the frozen\ninvoice, credit and refund sync accepted any provider with\n`environment: 'production'`. They no longer do without a deliberate enablement.\n\n## Rule\n\nA write is **production** when any of the caller's mapping scope, the provider's\nown `environment`, or the environment the document is already synced under says\nso. They must agree (`ACCOUNTING_ENVIRONMENT_MISMATCH` otherwise, so a\nsandbox-labelled mapping cannot reach a production provider). A production write\nneeds, on the tenant's `AccountingConnection`:\n\n1. `status === 'connected'` and `environment === 'production'`;\n2. `liveEnabledRealmId === realmId`, set by\n `enableLiveAccounting({ tenantId, realmId, enabledBy, evidenceRef })`, which\n itself refuses unless the connected production company is that realm.\n\nOtherwise `AccountingLiveGateError` (`LIVE_ACCOUNTING_NOT_ENABLED`) is thrown\n**before** any state is reserved or provider called, so state is unchanged.\nSandbox needs no enablement and no connection (it stays the default).\n\nEnablement is per company: reconnecting to another realm or environment, or\ndisconnecting, clears it; `disableLiveAccounting` switches it off. The app owns\nwho may call `enableLiveAccounting` and when (Work reserves it for the owner);\ncommerce only refuses writes without it.\n\n## Where it is checked\n\n`assertAccountingWriteAllowed` runs first in `syncFrozenInvoiceToAccounting`\n(invoice and credit memo), `syncOrdinaryInvoiceToAccounting`,\n`syncOrdinaryCreditToAccounting`, `syncOrdinaryRefundToAccounting`,\n`syncRetainedInvoiceToAccounting`, `releaseRetainedInvoiceToAccounting`,\n`syncRetainedCreditToAccounting`, `syncRetainedRefundToAccounting`, and the\npayment sync (#5139). Reconcile and read paths do not write remotely and are\nnot gated. The fixture pilot stays sandbox-only.\n"
|
|
23668
|
+
},
|
|
23669
|
+
{
|
|
23670
|
+
"path": "agents/accounting-payment-sync.md",
|
|
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"
|
|
23673
|
+
},
|
|
22446
23674
|
{
|
|
22447
23675
|
"path": "agents/historical-sales.md",
|
|
22448
23676
|
"module": "historical-sales",
|
|
@@ -22531,7 +23759,7 @@
|
|
|
22531
23759
|
{
|
|
22532
23760
|
"path": "agents/ordinary-accounting.md",
|
|
22533
23761
|
"module": "ordinary-accounting",
|
|
22534
|
-
"content": "# Ordinary invoice accounting adjustments (#4118)\n\nOrdinary issued invoices use the same frozen money exporter as other canonical\nCommerce invoices. Their provider credit applications and already-settled refund\nrecordings need durable ownership too; they do not have a retention agreement.\n\nUse `syncOrdinaryInvoiceToAccounting` with the active tenant, canonical issued\ninvoice ID, provider, stable request ID, evidence reference, reviewed SDK\n`QuickBooksOrdinaryReceivableMapping` (`kind: 'ordinary'`) and exact\n`QuickBooksFrozenInvoiceMapping` (`invoiceMapping`). It saves both mappings before\ncalling `syncFrozenInvoiceToAccounting`. It does not fabricate quantities, tax,\nretention accounts or an original provider invoice for historical imported facts.\nThe mapping supports explicit accrual/invoice-tax-point, verified home currency,\nAR and optional bank accounts. The SDK validates real provider account/customer\nmetadata; ordinary mapping cannot withhold or release retention.\n\n`readOrdinaryInvoiceAccountingState(invoice)` returns the immutable source and\nreviewed mappings, nullable original external ID, pending/ready status, credits,\nrefunds and individual remote steps. On a lost original export response, retain\nthat state and use the existing `readFrozenAccountingSyncState` request/attempt\nidentity plus `reconcileOrdinaryBaseInvoice` and exact verified provider outcome.\nRetry the original sync command afterwards. A fresh process can reconstruct the\nrequest from the public state; it must not guess a mapping or query private JSON.\n\nFor an issued same-source credit, `loadOrdinaryCreditAccountingSnapshot` and\n`toOrdinaryCreditAccountingInput` provide read-only exact review. Then call\n`syncOrdinaryCreditToAccounting` with the credit ID/mapping, request/evidence and\nexplicit effective date. The command reserves the actual local applied amount,\nexports the frozen CreditMemo and applies only that amount to the original remote\nInvoice. Zero application leaves unapplied credit capacity; it creates no fake\nzero payment. Once reserved, later same-date credits, UUID ordering and balance\nrefreshes cannot move the provider application. Generic direct credit export is\nblocked for managed sources; the owning read helpers do not permit a write bypass.\n\n`syncOrdinaryRefundToAccounting` requires an already-completed local refund\nPayment, actual cash journal, one exact full allocation to a reconciled provider\ncredit, and effectiveOn equal to the local settlement date. It reserves remaining\nunapplied credit capacity before recording the provider cash-refund journal and\nits noncash CreditMemo application. These are accounting records of an existing\nsettlement, never a bank transfer. The Payment and its allocations cannot be\nchanged/deleted after reservation, including while an outcome is unknown.\n\nEvery remote write uses the shared recoverable step engine also used by retained\naccounting. `reconcileOrdinaryAccountingStep` requires exact observed request and\nattempt identity, authoritative readback/absence evidence and proof an interrupted\nowner stopped. `reconcileOrdinaryCreditAccounting` resolves the frozen CreditMemo\nexport. Never reset unknown state on timeout or assume a request hash alone proves\nremote idempotency. Resume the original operation after reconciliation; changed\nrequest facts fail. Network operations reject caller-owned money transactions;\nlocal reservations use the same tenant/source money locks and rollback boundary.\n\nOrdinary state and refund bindings are command-owned fields on Invoice and Payment.\nRun normal schema migration for these additive fields before using the capability.\nExisting rows remain unbound; no automatic conversion of earlier app-only posted\nhistory is performed. Retained APIs still require a real positive retention\nagreement. No live provider certification is implied by controlled SDK fixtures.\n\nFocused proof: `pnpm --filter @happyvertical/smrt-commerce exec vitest run\nsrc/__tests__/ordinary-accounting.test.ts src/__tests__/retention-accounting.test.ts`.\nThe corresponding `ordinary-accounting.optional.test.ts` and retained suite run\nthrough the standard managed PostgreSQL wrapper. The shared helper covers base,\ncredit and both refund-step lost responses; same-day ordering; changed retry;\nsource/tenant checks; reservation rollback; concurrent refund attempts; and direct\npayment/allocation mutation refusal. The retained suite protects shared-engine\ncompatibility.\n\nAn existing generic frozen export can enter ordinary coordination only when the\nreviewed mapping reconstructs its exact original creation request. This check\nruns under the reservation lock, including unresolved exports; a mismatch leaves\nordinary state absent. Once ordinary authority is reserved, base export uses the\nowning command so a competing generic export cannot replace that mapping between\nreservation and provider I/O. Read-only frozen projections remain available.\n"
|
|
23762
|
+
"content": "# Ordinary invoice accounting adjustments (#4118)\n\nOrdinary issued invoices use the same frozen money exporter as other canonical\nCommerce invoices. Their provider credit applications and already-settled refund\nrecordings need durable ownership too; they do not have a retention agreement.\n\nUse `syncOrdinaryInvoiceToAccounting` with the active tenant, canonical issued\ninvoice ID, provider, stable request ID, evidence reference, reviewed SDK\n`QuickBooksOrdinaryReceivableMapping` (`kind: 'ordinary'`) and exact\n`QuickBooksFrozenInvoiceMapping` (`invoiceMapping`). It saves both mappings before\ncalling `syncFrozenInvoiceToAccounting`. It does not fabricate quantities, tax,\nretention accounts or an original provider invoice for historical imported facts.\nThe mapping supports explicit accrual/invoice-tax-point, verified home currency,\nAR and optional bank accounts. The SDK validates real provider account/customer\nmetadata; ordinary mapping cannot withhold or release retention.\n\n`readOrdinaryInvoiceAccountingState(invoice)` returns the immutable source and\nreviewed mappings, nullable original external ID, pending/ready status, credits,\nrefunds and individual remote steps. On a lost original export response, retain\nthat state and use the existing `readFrozenAccountingSyncState` request/attempt\nidentity plus `reconcileOrdinaryBaseInvoice` and exact verified provider outcome.\nRetry the original sync command afterwards. A fresh process can reconstruct the\nrequest from the public state; it must not guess a mapping or query private JSON.\n\nFor an issued same-source credit, `loadOrdinaryCreditAccountingSnapshot` and\n`toOrdinaryCreditAccountingInput` provide read-only exact review. Then call\n`syncOrdinaryCreditToAccounting` with the credit ID/mapping, request/evidence and\nexplicit effective date. The command reserves the actual local applied amount,\nexports the frozen CreditMemo and applies only that amount to the original remote\nInvoice. Zero application leaves unapplied credit capacity; it creates no fake\nzero payment. Once reserved, later same-date credits, UUID ordering and balance\nrefreshes cannot move the provider application. Generic direct credit export is\nblocked for managed sources; the owning read helpers do not permit a write bypass.\n\n`syncOrdinaryRefundToAccounting` requires an already-completed local refund\nPayment, actual cash journal, one exact full allocation to a reconciled provider\ncredit, and effectiveOn equal to the local settlement date. It reserves remaining\nunapplied credit capacity before recording the provider cash-refund journal and\nits noncash CreditMemo application. These are accounting records of an existing\nsettlement, never a bank transfer. The Payment and its allocations cannot be\nchanged/deleted after reservation, including while an outcome is unknown.\n\nEvery remote write uses the shared recoverable step engine also used by retained\naccounting. `reconcileOrdinaryAccountingStep` requires exact observed request and\nattempt identity, authoritative readback/absence evidence and proof an interrupted\nowner stopped. `reconcileOrdinaryCreditAccounting` resolves the frozen CreditMemo\nexport. Never reset unknown state on timeout or assume a request hash alone proves\nremote idempotency. Resume the original operation after reconciliation; changed\nrequest facts fail. Network operations reject caller-owned money transactions;\nlocal reservations use the same tenant/source money locks and rollback boundary.\n\nOrdinary state and refund bindings are command-owned fields on Invoice and Payment.\nRun normal schema migration for these additive fields before using the capability.\nExisting rows remain unbound; no automatic conversion of earlier app-only posted\nhistory is performed. Retained APIs still require a real positive retention\nagreement. No live provider certification is implied by controlled SDK fixtures.\n\nFocused proof: `pnpm --filter @happyvertical/smrt-commerce exec vitest run\nsrc/__tests__/ordinary-accounting.test.ts src/__tests__/retention-accounting.test.ts`.\nThe corresponding `ordinary-accounting.optional.test.ts` and retained suite run\nthrough the standard managed PostgreSQL wrapper. The shared helper covers base,\ncredit and both refund-step lost responses; same-day ordering; changed retry;\nsource/tenant checks; reservation rollback; concurrent refund attempts; and direct\npayment/allocation mutation refusal. The retained suite protects shared-engine\ncompatibility.\n\nAn existing generic frozen export can enter ordinary coordination only when the\nreviewed mapping reconstructs its exact original creation request. This check\nruns under the reservation lock, including unresolved exports; a mismatch leaves\nordinary state absent. Once ordinary authority is reserved, base export uses the\nowning command so a competing generic export cannot replace that mapping between\nreservation and provider I/O. Read-only frozen projections remain available.\n\nProduction providers or mappings are refused unless live mode is enabled for the\ntenant's connected company; see [live-mode gate](accounting-live-gate.md).\n"
|
|
22535
23763
|
},
|
|
22536
23764
|
{
|
|
22537
23765
|
"path": "agents/invoice-source-binding.md",
|