@accounter/server 0.0.9-alpha-20251210155614-e6e65aaecafef9e8fedd0b933f613ffcf478cecf → 0.0.9-alpha-20251210171954-c9c0e7693ebe08d3643d9ee2c00c03606a53e334

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +43 -5
  2. package/dist/server/src/__tests__/factories/business.d.ts +2 -2
  3. package/dist/server/src/__tests__/factories/business.js +5 -4
  4. package/dist/server/src/__tests__/factories/business.js.map +1 -1
  5. package/dist/server/src/__tests__/factories/business.test.js +2 -2
  6. package/dist/server/src/__tests__/factories/business.test.js.map +1 -1
  7. package/dist/server/src/__tests__/factories/charge.d.ts +9 -9
  8. package/dist/server/src/__tests__/factories/charge.js +15 -15
  9. package/dist/server/src/__tests__/factories/charge.js.map +1 -1
  10. package/dist/server/src/__tests__/factories/charge.test.js +14 -14
  11. package/dist/server/src/__tests__/factories/charge.test.js.map +1 -1
  12. package/dist/server/src/__tests__/factories/document.d.ts +9 -9
  13. package/dist/server/src/__tests__/factories/document.js +11 -11
  14. package/dist/server/src/__tests__/factories/document.js.map +1 -1
  15. package/dist/server/src/__tests__/factories/document.test.js +38 -38
  16. package/dist/server/src/__tests__/factories/document.test.js.map +1 -1
  17. package/dist/server/src/__tests__/factories/financial-account.js +2 -2
  18. package/dist/server/src/__tests__/factories/financial-account.js.map +1 -1
  19. package/dist/server/src/__tests__/factories/financial-account.test.js +7 -7
  20. package/dist/server/src/__tests__/factories/financial-account.test.js.map +1 -1
  21. package/dist/server/src/__tests__/factories/index.d.ts +2 -2
  22. package/dist/server/src/__tests__/factories/index.js +2 -2
  23. package/dist/server/src/__tests__/factories/index.js.map +1 -1
  24. package/dist/server/src/__tests__/factories/index.test.js +12 -12
  25. package/dist/server/src/__tests__/factories/index.test.js.map +1 -1
  26. package/dist/server/src/__tests__/factories/tax-category.d.ts +3 -3
  27. package/dist/server/src/__tests__/factories/tax-category.js +6 -5
  28. package/dist/server/src/__tests__/factories/tax-category.js.map +1 -1
  29. package/dist/server/src/__tests__/factories/tax-category.test.js +4 -4
  30. package/dist/server/src/__tests__/factories/tax-category.test.js.map +1 -1
  31. package/dist/server/src/__tests__/factories/transaction.d.ts +7 -7
  32. package/dist/server/src/__tests__/factories/transaction.js +11 -11
  33. package/dist/server/src/__tests__/factories/transaction.js.map +1 -1
  34. package/dist/server/src/__tests__/factories/transaction.test.js +27 -27
  35. package/dist/server/src/__tests__/factories/transaction.test.js.map +1 -1
  36. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js +20 -20
  37. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js.map +1 -1
  38. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js +20 -20
  39. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js.map +1 -1
  40. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.test.js +8 -8
  41. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.test.js.map +1 -1
  42. package/dist/server/src/__tests__/helpers/db-setup.d.ts +0 -1
  43. package/dist/server/src/__tests__/helpers/db-setup.js +0 -2
  44. package/dist/server/src/__tests__/helpers/db-setup.js.map +1 -1
  45. package/dist/server/src/__tests__/helpers/fixture-loader.js +2 -2
  46. package/dist/server/src/__tests__/helpers/fixture-loader.js.map +1 -1
  47. package/dist/server/src/__tests__/helpers/fixture-loader.test.js +32 -29
  48. package/dist/server/src/__tests__/helpers/fixture-loader.test.js.map +1 -1
  49. package/dist/server/src/__tests__/helpers/fixture-validation.test.js +50 -50
  50. package/dist/server/src/__tests__/helpers/fixture-validation.test.js.map +1 -1
  51. package/dist/server/src/__tests__/helpers/seed-helpers.business.test.js +23 -31
  52. package/dist/server/src/__tests__/helpers/seed-helpers.business.test.js.map +1 -1
  53. package/dist/server/src/__tests__/helpers/seed-helpers.concurrent.test.js +8 -8
  54. package/dist/server/src/__tests__/helpers/seed-helpers.concurrent.test.js.map +1 -1
  55. package/dist/server/src/__tests__/helpers/seed-helpers.financial-entity.test.js +41 -50
  56. package/dist/server/src/__tests__/helpers/seed-helpers.financial-entity.test.js.map +1 -1
  57. package/dist/server/src/__tests__/helpers/seed-helpers.tax-category.test.js +23 -31
  58. package/dist/server/src/__tests__/helpers/seed-helpers.tax-category.test.js.map +1 -1
  59. package/dist/server/src/__tests__/helpers/test-db-config.js +1 -1
  60. package/dist/server/src/__tests__/helpers/test-db-config.js.map +1 -1
  61. package/dist/server/src/__tests__/seed-admin-context.integration.test.js +128 -131
  62. package/dist/server/src/__tests__/seed-admin-context.integration.test.js.map +1 -1
  63. package/dist/server/src/demo-fixtures/__tests__/deterministic-uuid.test.js +58 -0
  64. package/dist/server/src/demo-fixtures/__tests__/deterministic-uuid.test.js.map +1 -0
  65. package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.d.ts +50 -0
  66. package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.js +66 -0
  67. package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.js.map +1 -0
  68. package/dist/server/src/modules/admin-context/{heplers → helpers}/admin-context.helper.d.ts +1 -1
  69. package/dist/server/src/modules/admin-context/{heplers → helpers}/admin-context.helper.js +2 -2
  70. package/dist/server/src/modules/admin-context/{heplers → helpers}/admin-context.helper.js.map +1 -1
  71. package/dist/server/src/modules/admin-context/resolvers/admin-context.resolvers.js +1 -1
  72. package/dist/server/src/modules/business-trips/providers/business-trips.provider.d.ts +1 -1
  73. package/dist/server/src/modules/business-trips/providers/business-trips.provider.js +1 -1
  74. package/dist/server/src/modules/business-trips/providers/business-trips.provider.js.map +1 -1
  75. package/dist/server/src/modules/charges/helpers/common.helper.js +3 -3
  76. package/dist/server/src/modules/charges/helpers/common.helper.js.map +1 -1
  77. package/dist/server/src/modules/charges/helpers/{merge-charges.hepler.js → merge-charges.helper.js} +6 -6
  78. package/dist/server/src/modules/charges/helpers/{merge-charges.hepler.js.map → merge-charges.helper.js.map} +1 -1
  79. package/dist/server/src/modules/charges/resolvers/charges.resolver.js +1 -1
  80. package/dist/server/src/modules/charges-matcher/__tests__/auto-match-integration.test.js +2 -2
  81. package/dist/server/src/modules/charges-matcher/__tests__/auto-match-integration.test.js.map +1 -1
  82. package/dist/server/src/modules/charges-matcher/providers/charges-matcher.provider.js +1 -1
  83. package/dist/server/src/modules/charges-matcher/providers/charges-matcher.provider.js.map +1 -1
  84. package/dist/server/src/modules/corn-jobs/resolvers/corn-jobs.resolver.js +1 -1
  85. package/dist/server/src/modules/corn-jobs/resolvers/corn-jobs.resolver.js.map +1 -1
  86. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.d.ts +0 -2
  87. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js +0 -4
  88. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js.map +1 -1
  89. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.js +20 -20
  90. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.js.map +1 -1
  91. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.js +21 -21
  92. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.js.map +1 -1
  93. package/dist/server/src/modules/transactions/helpers/common.helper.js +11 -6
  94. package/dist/server/src/modules/transactions/helpers/common.helper.js.map +1 -1
  95. package/package.json +1 -1
  96. package/src/__tests__/factories/business.test.ts +3 -3
  97. package/src/__tests__/factories/business.ts +5 -4
  98. package/src/__tests__/factories/charge.test.ts +14 -14
  99. package/src/__tests__/factories/charge.ts +16 -16
  100. package/src/__tests__/factories/document.test.ts +38 -38
  101. package/src/__tests__/factories/document.ts +11 -11
  102. package/src/__tests__/factories/financial-account.test.ts +7 -7
  103. package/src/__tests__/factories/financial-account.ts +3 -3
  104. package/src/__tests__/factories/index.test.ts +12 -12
  105. package/src/__tests__/factories/index.ts +2 -2
  106. package/src/__tests__/factories/tax-category.test.ts +4 -4
  107. package/src/__tests__/factories/tax-category.ts +7 -6
  108. package/src/__tests__/factories/transaction.test.ts +27 -27
  109. package/src/__tests__/factories/transaction.ts +11 -11
  110. package/src/__tests__/fixtures/expenses/expense-scenario-a.ts +20 -20
  111. package/src/__tests__/fixtures/expenses/expense-scenario-b.test.ts +8 -8
  112. package/src/__tests__/fixtures/expenses/expense-scenario-b.ts +20 -20
  113. package/src/__tests__/helpers/db-setup.ts +0 -3
  114. package/src/__tests__/helpers/fixture-loader.test.ts +31 -29
  115. package/src/__tests__/helpers/fixture-loader.ts +2 -2
  116. package/src/__tests__/helpers/fixture-validation.test.ts +50 -50
  117. package/src/__tests__/helpers/seed-helpers.business.test.ts +145 -147
  118. package/src/__tests__/helpers/seed-helpers.concurrent.test.ts +10 -10
  119. package/src/__tests__/helpers/seed-helpers.financial-entity.test.ts +218 -231
  120. package/src/__tests__/helpers/seed-helpers.tax-category.test.ts +162 -164
  121. package/src/__tests__/helpers/test-db-config.ts +1 -1
  122. package/src/__tests__/seed-admin-context.integration.test.ts +199 -208
  123. package/src/demo-fixtures/__tests__/deterministic-uuid.test.ts +75 -0
  124. package/src/demo-fixtures/helpers/deterministic-uuid.ts +68 -0
  125. package/src/modules/admin-context/{heplers → helpers}/admin-context.helper.ts +3 -3
  126. package/src/modules/admin-context/resolvers/admin-context.resolvers.ts +1 -1
  127. package/src/modules/business-trips/providers/business-trips.provider.ts +1 -1
  128. package/src/modules/charges/helpers/common.helper.ts +3 -3
  129. package/src/modules/charges/helpers/{merge-charges.hepler.ts → merge-charges.helper.ts} +5 -5
  130. package/src/modules/charges/resolvers/charges.resolver.ts +1 -1
  131. package/src/modules/charges-matcher/__tests__/auto-match-integration.test.ts +2 -2
  132. package/src/modules/charges-matcher/providers/charges-matcher.provider.ts +1 -1
  133. package/src/modules/corn-jobs/resolvers/corn-jobs.resolver.ts +1 -1
  134. package/src/modules/ledger/__tests__/helpers/ledger-assertions.ts +0 -5
  135. package/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.ts +20 -20
  136. package/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.ts +21 -21
  137. package/src/modules/transactions/helpers/common.helper.ts +12 -6
  138. package/dist/server/src/__tests__/factories/ids.d.ts +0 -22
  139. package/dist/server/src/__tests__/factories/ids.js +0 -46
  140. package/dist/server/src/__tests__/factories/ids.js.map +0 -1
  141. package/dist/server/src/__tests__/factories/ids.test.js +0 -71
  142. package/dist/server/src/__tests__/factories/ids.test.js.map +0 -1
  143. package/src/__tests__/factories/ids.test.ts +0 -80
  144. package/src/__tests__/factories/ids.ts +0 -49
  145. /package/dist/server/src/{__tests__/factories/ids.test.d.ts → demo-fixtures/__tests__/deterministic-uuid.test.d.ts} +0 -0
  146. /package/dist/server/src/modules/charges/helpers/{merge-charges.hepler.d.ts → merge-charges.helper.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect } from 'vitest';
2
2
  import { expenseScenarioB } from './expense-scenario-b';
3
3
  import { validateFixture } from '../../helpers/fixture-validation';
4
- import { makeUUID } from '../../factories/ids';
4
+ import { makeUUID } from '../../../demo-fixtures/helpers/deterministic-uuid.js';
5
5
  import { CountryCode } from '../../../modules/countries/types.js';
6
6
  import { Currency } from '../../../shared/enums.js';
7
7
 
@@ -39,8 +39,8 @@ describe('Expense Scenario B - USD Invoice', () => {
39
39
 
40
40
  it('should have correct business entities', () => {
41
41
  const businesses = expenseScenarioB.businesses!.businesses;
42
- const admin = businesses.find(b => b.id === makeUUID('admin-business-usd'));
43
- const supplier = businesses.find(b => b.id === makeUUID('supplier-us-vendor-llc'));
42
+ const admin = businesses.find(b => b.id === makeUUID('business', 'admin-business-usd'));
43
+ const supplier = businesses.find(b => b.id === makeUUID('business', 'supplier-us-vendor-llc'));
44
44
 
45
45
  expect(admin).toBeDefined();
46
46
  expect(admin?.country).toBe(CountryCode.Israel);
@@ -51,7 +51,7 @@ describe('Expense Scenario B - USD Invoice', () => {
51
51
  });
52
52
 
53
53
  it('should have referential integrity between charge, transaction, and document', () => {
54
- const chargeId = makeUUID('charge-consulting-services');
54
+ const chargeId = makeUUID('charge', 'charge-consulting-services');
55
55
  const charge = expenseScenarioB.charges!.charges[0];
56
56
  const transaction = expenseScenarioB.transactions!.transactions[0];
57
57
  const document = expenseScenarioB.documents!.documents[0];
@@ -94,7 +94,7 @@ describe('Expense Scenario B - USD Invoice', () => {
94
94
  it('should have ledger expectations with exchange rate', () => {
95
95
  const ledgerExpectation = expenseScenarioB.expectations!.ledger![0];
96
96
 
97
- expect(ledgerExpectation.chargeId).toBe(makeUUID('charge-consulting-services'));
97
+ expect(ledgerExpectation.chargeId).toBe(makeUUID('charge', 'charge-consulting-services'));
98
98
  expect(ledgerExpectation.recordCount).toBe(2);
99
99
  expect(ledgerExpectation.balanced).toBe(true);
100
100
  expect(ledgerExpectation.foreignCurrency).toBe('USD');
@@ -116,14 +116,14 @@ describe('Expense Scenario B - USD Invoice', () => {
116
116
  const debitEntity = ledgerExpectation.debitEntities![0];
117
117
  const creditEntity = ledgerExpectation.creditEntities![0];
118
118
 
119
- expect(debitEntity).toBe(makeUUID('expense-consulting'));
120
- expect(creditEntity).toBe(makeUUID('usd-account-tax-category'));
119
+ expect(debitEntity).toBe(makeUUID('tax-category', 'expense-consulting'));
120
+ expect(creditEntity).toBe(makeUUID('tax-category', 'usd-account-tax-category'));
121
121
  });
122
122
 
123
123
  it('should have USD account mapped to tax category', () => {
124
124
  const accountMapping = expenseScenarioB.accountTaxCategories?.mappings[0];
125
125
  expect(accountMapping?.accountNumber).toBe('USD-ACCOUNT-001');
126
126
  expect(accountMapping?.currency).toBe(Currency.Usd);
127
- expect(accountMapping?.taxCategoryId).toBe(makeUUID('usd-account-tax-category'));
127
+ expect(accountMapping?.taxCategoryId).toBe(makeUUID('tax-category', 'usd-account-tax-category'));
128
128
  });
129
129
  });
@@ -26,7 +26,7 @@ import {
26
26
  createTaxCategory,
27
27
  createFinancialAccount,
28
28
  } from '../../factories';
29
- import { makeUUID } from '../../factories/ids';
29
+ import { makeUUID } from '../../../demo-fixtures/helpers/deterministic-uuid.js';
30
30
  import type { Fixture } from '../../helpers/fixture-types';
31
31
  import { CountryCode } from '../../../modules/countries/types.js';
32
32
  import { Currency } from '../../../shared/enums.js';
@@ -67,13 +67,13 @@ export const expenseScenarioB: Fixture = {
67
67
  businesses: [
68
68
  // Admin business (owner of the expense)
69
69
  createBusiness({
70
- id: makeUUID('admin-business-usd'),
70
+ id: makeUUID('business', 'admin-business-usd'),
71
71
  hebrewName: 'חשבונאות ניהול',
72
72
  country: CountryCode.Israel,
73
73
  }),
74
74
  // US Supplier business
75
75
  createBusiness({
76
- id: makeUUID('supplier-us-vendor-llc'),
76
+ id: makeUUID('business', 'supplier-us-vendor-llc'),
77
77
  hebrewName: 'ספק אמריקאי',
78
78
  country: CountryCode['United States of America (the)'],
79
79
  exemptDealer: false,
@@ -85,11 +85,11 @@ export const expenseScenarioB: Fixture = {
85
85
  taxCategories: {
86
86
  taxCategories: [
87
87
  createTaxCategory({
88
- id: makeUUID('expense-consulting'),
88
+ id: makeUUID('tax-category', 'expense-consulting'),
89
89
  hashavshevetName: 'Consulting Expenses',
90
90
  }),
91
91
  createTaxCategory({
92
- id: makeUUID('usd-account-tax-category'),
92
+ id: makeUUID('tax-category', 'usd-account-tax-category'),
93
93
  hashavshevetName: 'Foreign Currency Account',
94
94
  }),
95
95
  ],
@@ -100,7 +100,7 @@ export const expenseScenarioB: Fixture = {
100
100
  createFinancialAccount({
101
101
  accountNumber: 'USD-ACCOUNT-001',
102
102
  type: 'BANK_ACCOUNT',
103
- ownerId: makeUUID('admin-business-usd'),
103
+ ownerId: makeUUID('business', 'admin-business-usd'),
104
104
  }),
105
105
  ],
106
106
  },
@@ -110,7 +110,7 @@ export const expenseScenarioB: Fixture = {
110
110
  {
111
111
  accountNumber: 'USD-ACCOUNT-001',
112
112
  currency: Currency.Usd,
113
- taxCategoryId: makeUUID('usd-account-tax-category'),
113
+ taxCategoryId: makeUUID('tax-category', 'usd-account-tax-category'),
114
114
  },
115
115
  ],
116
116
  },
@@ -119,12 +119,12 @@ export const expenseScenarioB: Fixture = {
119
119
  charges: [
120
120
  createCharge(
121
121
  {
122
- owner_id: makeUUID('admin-business-usd'),
123
- tax_category_id: makeUUID('expense-consulting'),
122
+ owner_id: makeUUID('business', 'admin-business-usd'),
123
+ tax_category_id: makeUUID('tax-category', 'expense-consulting'),
124
124
  user_description: 'Consulting services from US vendor',
125
125
  },
126
126
  {
127
- id: makeUUID('charge-consulting-services'),
127
+ id: makeUUID('charge', 'charge-consulting-services'),
128
128
  },
129
129
  ),
130
130
  ],
@@ -134,15 +134,15 @@ export const expenseScenarioB: Fixture = {
134
134
  transactions: [
135
135
  createTransaction(
136
136
  {
137
- charge_id: makeUUID('charge-consulting-services'),
138
- business_id: makeUUID('supplier-us-vendor-llc'),
137
+ charge_id: makeUUID('charge', 'charge-consulting-services'),
138
+ business_id: makeUUID('business', 'supplier-us-vendor-llc'),
139
139
  amount: '-200.00', // Negative = expense/outflow in USD
140
140
  currency: Currency.Usd,
141
141
  event_date: '2024-01-20',
142
142
  is_fee: false,
143
143
  },
144
144
  {
145
- id: makeUUID('transaction-consulting-payment'),
145
+ id: makeUUID('transaction', 'transaction-consulting-payment'),
146
146
  account_id: 'USD-ACCOUNT-001', // Will be resolved to UUID by loader
147
147
  source_description: 'Consulting services - US Vendor LLC',
148
148
  debit_date: '2024-01-20',
@@ -156,16 +156,16 @@ export const expenseScenarioB: Fixture = {
156
156
  documents: [
157
157
  createDocument(
158
158
  {
159
- charge_id: makeUUID('charge-consulting-services'),
160
- creditor_id: makeUUID('supplier-us-vendor-llc'), // Supplier is creditor
161
- debtor_id: makeUUID('admin-business-usd'), // Admin is debtor
159
+ charge_id: makeUUID('charge', 'charge-consulting-services'),
160
+ creditor_id: makeUUID('business', 'supplier-us-vendor-llc'), // Supplier is creditor
161
+ debtor_id: makeUUID('business', 'admin-business-usd'), // Admin is debtor
162
162
  type: 'INVOICE',
163
163
  total_amount: 200.0, // Amount in USD
164
164
  currency_code: Currency.Usd,
165
165
  date: '2024-01-20', // Invoice date matches transaction
166
166
  },
167
167
  {
168
- id: makeUUID('document-consulting-invoice'),
168
+ id: makeUUID('document', 'document-consulting-invoice'),
169
169
  serial_number: 'INV-US-2024-001',
170
170
  vat_amount: null, // US invoice - no Israeli VAT
171
171
  },
@@ -176,10 +176,10 @@ export const expenseScenarioB: Fixture = {
176
176
  expectations: {
177
177
  ledger: [
178
178
  {
179
- chargeId: makeUUID('charge-consulting-services'),
179
+ chargeId: makeUUID('charge', 'charge-consulting-services'),
180
180
  recordCount: 2, // Document + transaction entries
181
- debitEntities: [makeUUID('expense-consulting'), makeUUID('usd-account-tax-category')],
182
- creditEntities: [makeUUID('usd-account-tax-category'), makeUUID('supplier-us-vendor-llc')],
181
+ debitEntities: [makeUUID('tax-category', 'expense-consulting'), makeUUID('tax-category', 'usd-account-tax-category')],
182
+ creditEntities: [makeUUID('tax-category', 'usd-account-tax-category'), makeUUID('business', 'supplier-us-vendor-llc')],
183
183
  // Ledger processes document (700 ILS) + transaction (700 ILS) = 1400 ILS total
184
184
  // With exchange rate of 3.5 ILS/USD: 200 USD × 3.5 = 700 ILS per entry
185
185
  totalDebitLocal: 1400.0,
@@ -5,6 +5,3 @@ export { withTestTransaction, withConcurrentTransactions } from './test-transact
5
5
  export { isPoolHealthy, debugLog, emitMetrics } from './diagnostics.js';
6
6
  export { TestDbConnectionError, TestDbMigrationError, TestDbSeedError } from './errors.js';
7
7
  export { TestDatabase } from './test-database.js';
8
-
9
- // Backward-compatible no-op reset (seed flag lives in db-fixtures now)
10
- export function resetSetupFlags(): void {}
@@ -18,8 +18,8 @@ import {
18
18
  createCharge,
19
19
  createTransaction,
20
20
  createDocument,
21
- makeUUID,
22
21
  } from '../factories/index.js';
22
+ import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.js';
23
23
 
24
24
  describe('Fixture Loader', () => {
25
25
  let pool: Pool;
@@ -35,9 +35,9 @@ describe('Fixture Loader', () => {
35
35
  describe('insertFixture', () => {
36
36
  it('should insert a complete minimal fixture successfully', () =>
37
37
  withTestTransaction(pool, async client => {
38
- const businessId = makeUUID('test-business-1');
39
- const taxCategoryId = makeUUID('test-tax-cat-1');
40
- const chargeId = makeUUID('test-charge-1');
38
+ const businessId = makeUUID('business', 'test-business-1');
39
+ const taxCategoryId = makeUUID('tax-category', 'test-tax-cat-1');
40
+ const chargeId = makeUUID('charge', 'test-charge-1');
41
41
 
42
42
  const fixture: Fixture = {
43
43
  businesses: {
@@ -83,6 +83,7 @@ describe('Fixture Loader', () => {
83
83
  [businessId],
84
84
  );
85
85
  expect(businessResult.rows).toHaveLength(1);
86
+ expect(businessResult.rows[0].id).toBe(businessId);
86
87
  expect(businessResult.rows[0].hebrew_name).toBe('Test Business');
87
88
 
88
89
  const taxCatResult = await client.query(
@@ -90,6 +91,7 @@ describe('Fixture Loader', () => {
90
91
  [taxCategoryId],
91
92
  );
92
93
  expect(taxCatResult.rows).toHaveLength(1);
94
+ expect(taxCatResult.rows[0].id).toBe(taxCategoryId);
93
95
  expect(taxCatResult.rows[0].hashavshevet_name).toBe('Test Tax Category');
94
96
 
95
97
  const chargeResult = await client.query(
@@ -102,13 +104,13 @@ describe('Fixture Loader', () => {
102
104
 
103
105
  it('should insert fixture with transactions and documents', () =>
104
106
  withTestTransaction(pool, async client => {
105
- const supplierId = makeUUID('supplier-1');
106
- const customerId = makeUUID('customer-1');
107
- const taxCategoryId = makeUUID('tax-cat-1');
107
+ const supplierId = makeUUID('business', 'supplier-1');
108
+ const customerId = makeUUID('business', 'customer-1');
109
+ const taxCategoryId = makeUUID('tax-category', 'tax-cat-1');
108
110
  const accountNumber = 'ACC-12345';
109
- const chargeId = makeUUID('charge-1');
110
- const transactionId = makeUUID('tx-1');
111
- const documentId = makeUUID('doc-1');
111
+ const chargeId = makeUUID('charge', 'charge-1');
112
+ const transactionId = makeUUID('transaction', 'tx-1');
113
+ const documentId = makeUUID('document', 'doc-1');
112
114
 
113
115
  const fixture: Fixture = {
114
116
  businesses: {
@@ -216,7 +218,7 @@ describe('Fixture Loader', () => {
216
218
 
217
219
  it('should handle fixture with only some sections populated', () =>
218
220
  withTestTransaction(pool, async client => {
219
- const businessId = makeUUID('lonely-business');
221
+ const businessId = makeUUID('business', 'lonely-business');
220
222
 
221
223
  const fixture: Fixture = {
222
224
  businesses: {
@@ -238,8 +240,8 @@ describe('Fixture Loader', () => {
238
240
 
239
241
  it('should throw validation error before insertion for invalid FK references', () =>
240
242
  withTestTransaction(pool, async client => {
241
- const businessId = makeUUID('test-biz');
242
- const invalidChargeId = makeUUID('invalid-charge');
243
+ const businessId = makeUUID('business', 'test-biz');
244
+ const invalidChargeId = makeUUID('charge', 'invalid-charge');
243
245
 
244
246
  const fixture: Fixture = {
245
247
  businesses: {
@@ -250,7 +252,7 @@ describe('Fixture Loader', () => {
250
252
  createCharge(
251
253
  {
252
254
  owner_id: 'non-existent-owner', // Invalid FK reference
253
- tax_category_id: makeUUID('tax-cat'),
255
+ tax_category_id: makeUUID('tax-category', 'tax-cat'),
254
256
  },
255
257
  { id: invalidChargeId },
256
258
  ),
@@ -269,7 +271,7 @@ describe('Fixture Loader', () => {
269
271
  charges: [
270
272
  createCharge({
271
273
  owner_id: 'non-existent-owner',
272
- tax_category_id: makeUUID('tax-cat'),
274
+ tax_category_id: makeUUID('tax-category', 'tax-cat'),
273
275
  }),
274
276
  ],
275
277
  },
@@ -288,7 +290,7 @@ describe('Fixture Loader', () => {
288
290
 
289
291
  it('should validate fixture before insertion', () =>
290
292
  withTestTransaction(pool, async client => {
291
- const chargeId = makeUUID('orphan-charge');
293
+ const chargeId = makeUUID('charge', 'orphan-charge');
292
294
 
293
295
  const fixture: Fixture = {
294
296
  // Missing businesses and tax categories
@@ -296,8 +298,8 @@ describe('Fixture Loader', () => {
296
298
  charges: [
297
299
  createCharge(
298
300
  {
299
- owner_id: makeUUID('missing-owner'),
300
- tax_category_id: makeUUID('missing-tax'),
301
+ owner_id: makeUUID('business', 'missing-owner'),
302
+ tax_category_id: makeUUID('tax-category', 'missing-tax'),
301
303
  },
302
304
  { id: chargeId },
303
305
  ),
@@ -310,12 +312,12 @@ describe('Fixture Loader', () => {
310
312
 
311
313
  it('should insert multiple entities in correct order', () =>
312
314
  withTestTransaction(pool, async client => {
313
- const biz1 = makeUUID('biz-1');
314
- const biz2 = makeUUID('biz-2');
315
- const tax1 = makeUUID('tax-1');
316
- const tax2 = makeUUID('tax-2');
317
- const charge1 = makeUUID('charge-1');
318
- const charge2 = makeUUID('charge-2');
315
+ const biz1 = makeUUID('business', 'biz-1');
316
+ const biz2 = makeUUID('business', 'biz-2');
317
+ const tax1 = makeUUID('tax-category', 'tax-1');
318
+ const tax2 = makeUUID('tax-category', 'tax-2');
319
+ const charge1 = makeUUID('charge', 'charge-1');
320
+ const charge2 = makeUUID('charge', 'charge-2');
319
321
 
320
322
  const fixture: Fixture = {
321
323
  businesses: {
@@ -360,7 +362,7 @@ describe('Fixture Loader', () => {
360
362
 
361
363
  it('should handle ON CONFLICT for idempotent insertion', () =>
362
364
  withTestTransaction(pool, async client => {
363
- const businessId = makeUUID('duplicate-biz');
365
+ const businessId = makeUUID('business', 'duplicate-biz');
364
366
 
365
367
  const fixture: Fixture = {
366
368
  businesses: {
@@ -392,11 +394,11 @@ describe('Fixture Loader', () => {
392
394
 
393
395
  it('should insert transactions with generated source_id', () =>
394
396
  withTestTransaction(pool, async client => {
395
- const businessId = makeUUID('biz-tx');
396
- const taxCatId = makeUUID('tax-tx');
397
- const chargeId = makeUUID('charge-tx');
397
+ const businessId = makeUUID('business', 'biz-tx');
398
+ const taxCatId = makeUUID('tax-category', 'tax-tx');
399
+ const chargeId = makeUUID('charge', 'charge-tx');
398
400
  const accountNumber = 'ACC-TX-001';
399
- const transactionId = makeUUID('tx-with-source');
401
+ const transactionId = makeUUID('transaction', 'tx-with-source');
400
402
 
401
403
  const fixture: Fixture = {
402
404
  businesses: {
@@ -12,7 +12,7 @@ import type { PoolClient } from 'pg';
12
12
  import type { Fixture } from './fixture-types.js';
13
13
  import { assertValidFixture } from './fixture-validation.js';
14
14
  import { qualifyTable } from './test-db-config.js';
15
- import { makeUUID } from '../factories/ids.js';
15
+ import { makeUUID, makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
16
16
 
17
17
  /**
18
18
  * Custom error for fixture insertion failures
@@ -334,7 +334,7 @@ export async function insertFixture(
334
334
  // Insert directly into transactions_raw_list with etherscan_id to satisfy check constraint
335
335
  // This avoids triggering any creditcard/bank transaction handlers which would auto-create charges
336
336
  // etherscan_id is used because it has no INSERT trigger and is a simple UUID reference
337
- const dummyEtherscanId = transaction.id ? makeUUID(`etherscan-${transaction.id}`) : makeUUID();
337
+ const dummyEtherscanId = transaction.id ? makeUUID('raw-transaction', `etherscan-${transaction.id}`) : makeUUIDLegacy();
338
338
  const rawListResult = await client.query(
339
339
  `INSERT INTO ${qualifyTable('transactions_raw_list')} (etherscan_id)
340
340
  VALUES ($1)
@@ -5,18 +5,18 @@ import { createDocument } from '../factories/document.js';
5
5
  import { createFinancialAccount } from '../factories/financial-account.js';
6
6
  import { createTaxCategory } from '../factories/tax-category.js';
7
7
  import { createTransaction } from '../factories/transaction.js';
8
- import { makeUUID } from '../factories/ids.js';
8
+ import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.js';
9
9
  import type { Fixture } from './fixture-types.js';
10
10
  import { assertValidFixture, validateFixture } from './fixture-validation.js';
11
11
 
12
12
  describe('Fixture Validation', () => {
13
13
  describe('validateFixture', () => {
14
14
  it('should validate a complete valid fixture', () => {
15
- const adminId = makeUUID('admin');
16
- const supplierId = makeUUID('supplier');
17
- const taxCatId = makeUUID('tax-cat');
18
- const chargeId = makeUUID('charge');
19
- const accountId = makeUUID('account');
15
+ const adminId = makeUUID('business', 'admin');
16
+ const supplierId = makeUUID('business', 'supplier');
17
+ const taxCatId = makeUUID('tax-category', 'tax-cat');
18
+ const chargeId = makeUUID('charge', 'charge');
19
+ const accountId = makeUUID('account', 'account');
20
20
 
21
21
  const fixture: Fixture = {
22
22
  businesses: {
@@ -67,9 +67,9 @@ describe('Fixture Validation', () => {
67
67
  });
68
68
 
69
69
  it('should validate a minimal fixture with just charges', () => {
70
- const adminId = makeUUID('admin');
71
- const chargeId = makeUUID('charge');
72
- const taxCatId = makeUUID('tax-cat');
70
+ const adminId = makeUUID('business', 'admin');
71
+ const chargeId = makeUUID('charge', 'charge');
72
+ const taxCatId = makeUUID('tax-category', 'tax-cat');
73
73
 
74
74
  const fixture: Fixture = {
75
75
  businesses: {
@@ -90,9 +90,9 @@ describe('Fixture Validation', () => {
90
90
  });
91
91
 
92
92
  it('should fail when transaction references non-existent charge', () => {
93
- const adminId = makeUUID('admin');
94
- const supplierId = makeUUID('supplier');
95
- const nonExistentChargeId = makeUUID('non-existent-charge');
93
+ const adminId = makeUUID('business', 'admin');
94
+ const supplierId = makeUUID('business', 'supplier');
95
+ const nonExistentChargeId = makeUUID('charge', 'non-existent-charge');
96
96
 
97
97
  const fixture: Fixture = {
98
98
  businesses: {
@@ -121,9 +121,9 @@ describe('Fixture Validation', () => {
121
121
  });
122
122
 
123
123
  it('should fail when document references non-existent charge', () => {
124
- const adminId = makeUUID('admin');
125
- const supplierId = makeUUID('supplier');
126
- const nonExistentChargeId = makeUUID('non-existent-charge');
124
+ const adminId = makeUUID('business', 'admin');
125
+ const supplierId = makeUUID('business', 'supplier');
126
+ const nonExistentChargeId = makeUUID('charge', 'non-existent-charge');
127
127
 
128
128
  const fixture: Fixture = {
129
129
  businesses: {
@@ -154,8 +154,8 @@ describe('Fixture Validation', () => {
154
154
  });
155
155
 
156
156
  it('should fail when charge references non-existent business', () => {
157
- const nonExistentBusinessId = makeUUID('non-existent-business');
158
- const chargeId = makeUUID('charge');
157
+ const nonExistentBusinessId = makeUUID('business', 'non-existent-business');
158
+ const chargeId = makeUUID('charge', 'charge');
159
159
 
160
160
  const fixture: Fixture = {
161
161
  charges: {
@@ -175,9 +175,9 @@ describe('Fixture Validation', () => {
175
175
  });
176
176
 
177
177
  it('should fail when charge references non-existent tax category', () => {
178
- const adminId = makeUUID('admin');
179
- const chargeId = makeUUID('charge');
180
- const nonExistentTaxCatId = makeUUID('non-existent-tax-cat');
178
+ const adminId = makeUUID('business', 'admin');
179
+ const chargeId = makeUUID('charge', 'charge');
180
+ const nonExistentTaxCatId = makeUUID('tax-category', 'non-existent-tax-cat');
181
181
 
182
182
  const fixture: Fixture = {
183
183
  businesses: {
@@ -203,9 +203,9 @@ describe('Fixture Validation', () => {
203
203
  });
204
204
 
205
205
  it('should fail when transaction references non-existent business', () => {
206
- const adminId = makeUUID('admin');
207
- const chargeId = makeUUID('charge');
208
- const nonExistentBusinessId = makeUUID('non-existent-business');
206
+ const adminId = makeUUID('business', 'admin');
207
+ const chargeId = makeUUID('charge', 'charge');
208
+ const nonExistentBusinessId = makeUUID('business', 'non-existent-business');
209
209
 
210
210
  const fixture: Fixture = {
211
211
  businesses: {
@@ -237,9 +237,9 @@ describe('Fixture Validation', () => {
237
237
  });
238
238
 
239
239
  it('should fail when document references non-existent creditor', () => {
240
- const adminId = makeUUID('admin');
241
- const chargeId = makeUUID('charge');
242
- const nonExistentCreditorId = makeUUID('non-existent-creditor');
240
+ const adminId = makeUUID('business', 'admin');
241
+ const chargeId = makeUUID('charge', 'charge');
242
+ const nonExistentCreditorId = makeUUID('business', 'non-existent-creditor');
243
243
 
244
244
  const fixture: Fixture = {
245
245
  businesses: {
@@ -273,10 +273,10 @@ describe('Fixture Validation', () => {
273
273
  });
274
274
 
275
275
  it('should fail when document references non-existent debtor', () => {
276
- const adminId = makeUUID('admin');
277
- const supplierId = makeUUID('supplier');
278
- const chargeId = makeUUID('charge');
279
- const nonExistentDebtorId = makeUUID('non-existent-debtor');
276
+ const adminId = makeUUID('business', 'admin');
277
+ const supplierId = makeUUID('business', 'supplier');
278
+ const chargeId = makeUUID('charge', 'charge');
279
+ const nonExistentDebtorId = makeUUID('business', 'non-existent-debtor');
280
280
 
281
281
  const fixture: Fixture = {
282
282
  businesses: {
@@ -310,7 +310,7 @@ describe('Fixture Validation', () => {
310
310
  });
311
311
 
312
312
  it('should fail when charge is missing owner_id', () => {
313
- const chargeId = makeUUID('charge');
313
+ const chargeId = makeUUID('charge', 'charge');
314
314
 
315
315
  const fixture: Fixture = {
316
316
  charges: {
@@ -337,8 +337,8 @@ describe('Fixture Validation', () => {
337
337
  });
338
338
 
339
339
  it('should fail when transaction is missing required fields', () => {
340
- const adminId = makeUUID('admin');
341
- const chargeId = makeUUID('charge');
340
+ const adminId = makeUUID('business', 'admin');
341
+ const chargeId = makeUUID('charge', 'charge');
342
342
 
343
343
  const fixture: Fixture = {
344
344
  businesses: {
@@ -350,10 +350,10 @@ describe('Fixture Validation', () => {
350
350
  transactions: {
351
351
  transactions: [
352
352
  {
353
- id: makeUUID('tx'),
354
- account_id: makeUUID('account'),
353
+ id: makeUUID('transaction', 'tx'),
354
+ account_id: makeUUID('account', 'account'),
355
355
  charge_id: '', // Missing
356
- source_id: makeUUID('source'),
356
+ source_id: makeUUID('source', 'source'),
357
357
  currency: '', // Missing
358
358
  event_date: '', // Missing
359
359
  amount: '', // Will be caught as missing
@@ -379,8 +379,8 @@ describe('Fixture Validation', () => {
379
379
  });
380
380
 
381
381
  it('should fail when document is missing required fields', () => {
382
- const adminId = makeUUID('admin');
383
- const chargeId = makeUUID('charge');
382
+ const adminId = makeUUID('business', 'admin');
383
+ const chargeId = makeUUID('charge', 'charge');
384
384
 
385
385
  const fixture: Fixture = {
386
386
  businesses: {
@@ -392,7 +392,7 @@ describe('Fixture Validation', () => {
392
392
  documents: {
393
393
  documents: [
394
394
  {
395
- id: makeUUID('doc'),
395
+ id: makeUUID('document', 'doc'),
396
396
  charge_id: '', // Missing
397
397
  creditor_id: '', // Missing
398
398
  debtor_id: '', // Missing
@@ -430,7 +430,7 @@ describe('Fixture Validation', () => {
430
430
  });
431
431
 
432
432
  it('should detect duplicate business IDs', () => {
433
- const duplicateId = makeUUID('duplicate-business');
433
+ const duplicateId = makeUUID('business', 'duplicate-business');
434
434
 
435
435
  const fixture: Fixture = {
436
436
  businesses: {
@@ -449,8 +449,8 @@ describe('Fixture Validation', () => {
449
449
  });
450
450
 
451
451
  it('should detect duplicate charge IDs', () => {
452
- const adminId = makeUUID('admin');
453
- const duplicateChargeId = makeUUID('duplicate-charge');
452
+ const adminId = makeUUID('business', 'admin');
453
+ const duplicateChargeId = makeUUID('charge', 'duplicate-charge');
454
454
 
455
455
  const fixture: Fixture = {
456
456
  businesses: {
@@ -472,8 +472,8 @@ describe('Fixture Validation', () => {
472
472
  });
473
473
 
474
474
  it('should validate financial account owner reference', () => {
475
- const nonExistentOwnerId = makeUUID('non-existent-owner');
476
- const accountNumber = makeUUID('account');
475
+ const nonExistentOwnerId = makeUUID('business', 'non-existent-owner');
476
+ const accountNumber = makeUUID('account', 'account');
477
477
 
478
478
  const fixture: Fixture = {
479
479
  accounts: {
@@ -493,7 +493,7 @@ describe('Fixture Validation', () => {
493
493
  });
494
494
 
495
495
  it('should allow financial account without owner', () => {
496
- const accountNumber = makeUUID('account');
496
+ const accountNumber = makeUUID('account', 'account');
497
497
 
498
498
  const fixture: Fixture = {
499
499
  accounts: {
@@ -508,9 +508,9 @@ describe('Fixture Validation', () => {
508
508
 
509
509
  describe('assertValidFixture', () => {
510
510
  it('should not throw for valid fixture', () => {
511
- const adminId = makeUUID('admin');
512
- const chargeId = makeUUID('charge');
513
- const taxCatId = makeUUID('tax-cat');
511
+ const adminId = makeUUID('business', 'admin');
512
+ const chargeId = makeUUID('charge', 'charge');
513
+ const taxCatId = makeUUID('tax-category', 'tax-cat');
514
514
 
515
515
  const fixture: Fixture = {
516
516
  businesses: {
@@ -530,8 +530,8 @@ describe('Fixture Validation', () => {
530
530
  });
531
531
 
532
532
  it('should throw for invalid fixture with formatted error message', () => {
533
- const nonExistentBusinessId = makeUUID('non-existent-business');
534
- const chargeId = makeUUID('charge');
533
+ const nonExistentBusinessId = makeUUID('business', 'non-existent-business');
534
+ const chargeId = makeUUID('charge', 'charge');
535
535
 
536
536
  const fixture: Fixture = {
537
537
  charges: {