@accounter/server 0.0.9-alpha-20251210153039-1cfd8df346dd211c95a70c76c63465a29236849b → 0.0.9-alpha-20251210155614-e6e65aaecafef9e8fedd0b933f613ffcf478cecf

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 (94) hide show
  1. package/CHANGELOG.md +5 -27
  2. package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
  3. package/dist/server/src/__tests__/factories/business.d.ts +2 -2
  4. package/dist/server/src/__tests__/factories/business.js +4 -5
  5. package/dist/server/src/__tests__/factories/business.js.map +1 -1
  6. package/dist/server/src/__tests__/factories/business.test.js +2 -2
  7. package/dist/server/src/__tests__/factories/business.test.js.map +1 -1
  8. package/dist/server/src/__tests__/factories/charge.d.ts +9 -9
  9. package/dist/server/src/__tests__/factories/charge.js +15 -15
  10. package/dist/server/src/__tests__/factories/charge.js.map +1 -1
  11. package/dist/server/src/__tests__/factories/charge.test.js +14 -14
  12. package/dist/server/src/__tests__/factories/charge.test.js.map +1 -1
  13. package/dist/server/src/__tests__/factories/document.d.ts +9 -9
  14. package/dist/server/src/__tests__/factories/document.js +11 -11
  15. package/dist/server/src/__tests__/factories/document.js.map +1 -1
  16. package/dist/server/src/__tests__/factories/document.test.js +38 -38
  17. package/dist/server/src/__tests__/factories/document.test.js.map +1 -1
  18. package/dist/server/src/__tests__/factories/financial-account.js +2 -2
  19. package/dist/server/src/__tests__/factories/financial-account.js.map +1 -1
  20. package/dist/server/src/__tests__/factories/financial-account.test.js +7 -7
  21. package/dist/server/src/__tests__/factories/financial-account.test.js.map +1 -1
  22. package/dist/server/src/__tests__/factories/ids.d.ts +22 -0
  23. package/dist/server/src/__tests__/factories/ids.js +46 -0
  24. package/dist/server/src/__tests__/factories/ids.js.map +1 -0
  25. package/dist/server/src/__tests__/factories/ids.test.js +71 -0
  26. package/dist/server/src/__tests__/factories/ids.test.js.map +1 -0
  27. package/dist/server/src/__tests__/factories/index.d.ts +2 -2
  28. package/dist/server/src/__tests__/factories/index.js +2 -2
  29. package/dist/server/src/__tests__/factories/index.js.map +1 -1
  30. package/dist/server/src/__tests__/factories/index.test.js +12 -12
  31. package/dist/server/src/__tests__/factories/index.test.js.map +1 -1
  32. package/dist/server/src/__tests__/factories/tax-category.d.ts +3 -3
  33. package/dist/server/src/__tests__/factories/tax-category.js +5 -6
  34. package/dist/server/src/__tests__/factories/tax-category.js.map +1 -1
  35. package/dist/server/src/__tests__/factories/tax-category.test.js +4 -4
  36. package/dist/server/src/__tests__/factories/tax-category.test.js.map +1 -1
  37. package/dist/server/src/__tests__/factories/transaction.d.ts +7 -7
  38. package/dist/server/src/__tests__/factories/transaction.js +11 -11
  39. package/dist/server/src/__tests__/factories/transaction.js.map +1 -1
  40. package/dist/server/src/__tests__/factories/transaction.test.js +27 -27
  41. package/dist/server/src/__tests__/factories/transaction.test.js.map +1 -1
  42. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js +20 -20
  43. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js.map +1 -1
  44. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js +20 -20
  45. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js.map +1 -1
  46. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.test.js +8 -8
  47. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.test.js.map +1 -1
  48. package/dist/server/src/__tests__/helpers/fixture-loader.js +2 -2
  49. package/dist/server/src/__tests__/helpers/fixture-loader.js.map +1 -1
  50. package/dist/server/src/__tests__/helpers/fixture-loader.test.js +29 -32
  51. package/dist/server/src/__tests__/helpers/fixture-loader.test.js.map +1 -1
  52. package/dist/server/src/__tests__/helpers/fixture-validation.test.js +50 -50
  53. package/dist/server/src/__tests__/helpers/fixture-validation.test.js.map +1 -1
  54. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.d.ts +2 -0
  55. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js +4 -0
  56. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js.map +1 -1
  57. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.js +20 -20
  58. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.js.map +1 -1
  59. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.js +21 -21
  60. package/dist/server/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.js.map +1 -1
  61. package/package.json +1 -1
  62. package/src/__tests__/factories/business.test.ts +3 -3
  63. package/src/__tests__/factories/business.ts +4 -5
  64. package/src/__tests__/factories/charge.test.ts +14 -14
  65. package/src/__tests__/factories/charge.ts +16 -16
  66. package/src/__tests__/factories/document.test.ts +38 -38
  67. package/src/__tests__/factories/document.ts +11 -11
  68. package/src/__tests__/factories/financial-account.test.ts +7 -7
  69. package/src/__tests__/factories/financial-account.ts +3 -3
  70. package/src/__tests__/factories/ids.test.ts +80 -0
  71. package/src/__tests__/factories/ids.ts +49 -0
  72. package/src/__tests__/factories/index.test.ts +12 -12
  73. package/src/__tests__/factories/index.ts +2 -2
  74. package/src/__tests__/factories/tax-category.test.ts +4 -4
  75. package/src/__tests__/factories/tax-category.ts +6 -7
  76. package/src/__tests__/factories/transaction.test.ts +27 -27
  77. package/src/__tests__/factories/transaction.ts +11 -11
  78. package/src/__tests__/fixtures/expenses/expense-scenario-a.ts +20 -20
  79. package/src/__tests__/fixtures/expenses/expense-scenario-b.test.ts +8 -8
  80. package/src/__tests__/fixtures/expenses/expense-scenario-b.ts +20 -20
  81. package/src/__tests__/helpers/fixture-loader.test.ts +29 -31
  82. package/src/__tests__/helpers/fixture-loader.ts +2 -2
  83. package/src/__tests__/helpers/fixture-validation.test.ts +50 -50
  84. package/src/modules/ledger/__tests__/helpers/ledger-assertions.ts +5 -0
  85. package/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.ts +20 -20
  86. package/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.ts +21 -21
  87. package/dist/server/src/demo-fixtures/__tests__/deterministic-uuid.test.js +0 -58
  88. package/dist/server/src/demo-fixtures/__tests__/deterministic-uuid.test.js.map +0 -1
  89. package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.d.ts +0 -50
  90. package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.js +0 -66
  91. package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.js.map +0 -1
  92. package/src/demo-fixtures/__tests__/deterministic-uuid.test.ts +0 -75
  93. package/src/demo-fixtures/helpers/deterministic-uuid.ts +0 -68
  94. /package/dist/server/src/{demo-fixtures/__tests__/deterministic-uuid.test.d.ts → __tests__/factories/ids.test.d.ts} +0 -0
@@ -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 '../../demo-fixtures/helpers/deterministic-uuid.js';
8
+ import { makeUUID } from '../factories/ids.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('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');
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');
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('business', 'admin');
71
- const chargeId = makeUUID('charge', 'charge');
72
- const taxCatId = makeUUID('tax-category', 'tax-cat');
70
+ const adminId = makeUUID('admin');
71
+ const chargeId = makeUUID('charge');
72
+ const taxCatId = makeUUID('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('business', 'admin');
94
- const supplierId = makeUUID('business', 'supplier');
95
- const nonExistentChargeId = makeUUID('charge', 'non-existent-charge');
93
+ const adminId = makeUUID('admin');
94
+ const supplierId = makeUUID('supplier');
95
+ const nonExistentChargeId = makeUUID('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('business', 'admin');
125
- const supplierId = makeUUID('business', 'supplier');
126
- const nonExistentChargeId = makeUUID('charge', 'non-existent-charge');
124
+ const adminId = makeUUID('admin');
125
+ const supplierId = makeUUID('supplier');
126
+ const nonExistentChargeId = makeUUID('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('business', 'non-existent-business');
158
- const chargeId = makeUUID('charge', 'charge');
157
+ const nonExistentBusinessId = makeUUID('non-existent-business');
158
+ const chargeId = makeUUID('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('business', 'admin');
179
- const chargeId = makeUUID('charge', 'charge');
180
- const nonExistentTaxCatId = makeUUID('tax-category', 'non-existent-tax-cat');
178
+ const adminId = makeUUID('admin');
179
+ const chargeId = makeUUID('charge');
180
+ const nonExistentTaxCatId = makeUUID('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('business', 'admin');
207
- const chargeId = makeUUID('charge', 'charge');
208
- const nonExistentBusinessId = makeUUID('business', 'non-existent-business');
206
+ const adminId = makeUUID('admin');
207
+ const chargeId = makeUUID('charge');
208
+ const nonExistentBusinessId = makeUUID('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('business', 'admin');
241
- const chargeId = makeUUID('charge', 'charge');
242
- const nonExistentCreditorId = makeUUID('business', 'non-existent-creditor');
240
+ const adminId = makeUUID('admin');
241
+ const chargeId = makeUUID('charge');
242
+ const nonExistentCreditorId = makeUUID('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('business', 'admin');
277
- const supplierId = makeUUID('business', 'supplier');
278
- const chargeId = makeUUID('charge', 'charge');
279
- const nonExistentDebtorId = makeUUID('business', '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');
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', 'charge');
313
+ const chargeId = makeUUID('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('business', 'admin');
341
- const chargeId = makeUUID('charge', 'charge');
340
+ const adminId = makeUUID('admin');
341
+ const chargeId = makeUUID('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('transaction', 'tx'),
354
- account_id: makeUUID('account', 'account'),
353
+ id: makeUUID('tx'),
354
+ account_id: makeUUID('account'),
355
355
  charge_id: '', // Missing
356
- source_id: makeUUID('source', 'source'),
356
+ source_id: makeUUID('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('business', 'admin');
383
- const chargeId = makeUUID('charge', 'charge');
382
+ const adminId = makeUUID('admin');
383
+ const chargeId = makeUUID('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('document', 'doc'),
395
+ id: makeUUID('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('business', 'duplicate-business');
433
+ const duplicateId = makeUUID('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('business', 'admin');
453
- const duplicateChargeId = makeUUID('charge', 'duplicate-charge');
452
+ const adminId = makeUUID('admin');
453
+ const duplicateChargeId = makeUUID('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('business', 'non-existent-owner');
476
- const accountNumber = makeUUID('account', 'account');
475
+ const nonExistentOwnerId = makeUUID('non-existent-owner');
476
+ const accountNumber = makeUUID('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', 'account');
496
+ const accountNumber = makeUUID('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('business', 'admin');
512
- const chargeId = makeUUID('charge', 'charge');
513
- const taxCatId = makeUUID('tax-category', 'tax-cat');
511
+ const adminId = makeUUID('admin');
512
+ const chargeId = makeUUID('charge');
513
+ const taxCatId = makeUUID('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('business', 'non-existent-business');
534
- const chargeId = makeUUID('charge', 'charge');
533
+ const nonExistentBusinessId = makeUUID('non-existent-business');
534
+ const chargeId = makeUUID('charge');
535
535
 
536
536
  const fixture: Fixture = {
537
537
  charges: {
@@ -1,4 +1,6 @@
1
1
  import { expect } from 'vitest';
2
+ // Adjusted relative path: helper is one directory deeper than scenario tests
3
+ import { makeUUID } from '../../../../__tests__/factories/ids.js';
2
4
 
3
5
  // Minimal ledger record type based on DB result interface
4
6
  export interface LedgerRecord {
@@ -241,6 +243,9 @@ export function assertExpenseScenarioLogic(records: LedgerRecord[], opts: {
241
243
  });
242
244
  }
243
245
 
246
+ /** Helper to prepare deterministic UUID sets for known fixture aliases */
247
+ export function fixtureUUID(alias: string): string { return makeUUID(alias); }
248
+
244
249
  /** Combined high-level assertion for typical simple local expense scenario */
245
250
  export function assertSimpleLocalExpenseScenario(records: LedgerRecord[], params: {
246
251
  chargeId: string;
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
2
2
  import { TestDatabase } from '../../../__tests__/helpers/db-setup.js';
3
3
  import { insertFixture } from '../../../__tests__/helpers/fixture-loader.js';
4
4
  import { expenseScenarioA } from '../../../__tests__/fixtures/expenses/expense-scenario-a.js';
5
- import { makeUUID } from '../../../demo-fixtures/helpers/deterministic-uuid.js';
5
+ import { makeUUID } from '../../../__tests__/factories/ids.js';
6
6
  import { qualifyTable } from '../../../__tests__/helpers/test-db-config.js';
7
7
  import { buildAdminContextFromDb } from '../../../__tests__/helpers/admin-context-builder.js';
8
8
  import { env } from '../../../environment.js';
@@ -43,7 +43,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
43
43
  afterEach(async () => {
44
44
  const client = await db.getPool().connect();
45
45
  try {
46
- const chargeId = makeUUID('charge', 'charge-office-supplies');
46
+ const chargeId = makeUUID('charge-office-supplies');
47
47
  await client.query(
48
48
  `DELETE FROM ${qualifyTable('ledger_records')} WHERE charge_id = $1`,
49
49
  [chargeId],
@@ -65,7 +65,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
65
65
  await client.query(
66
66
  `DELETE FROM ${qualifyTable('financial_accounts_tax_categories')}
67
67
  WHERE tax_category_id IN ($1, $2)`,
68
- [makeUUID('tax-category', 'expense-general'), makeUUID('tax-category', 'bank-account-tax-category')],
68
+ [makeUUID('expense-general'), makeUUID('bank-account-tax-category')],
69
69
  );
70
70
  await client.query(
71
71
  `DELETE FROM ${qualifyTable('financial_accounts')} WHERE account_number = $1`,
@@ -73,19 +73,19 @@ describe('Ledger Generation - Expense Scenario A', () => {
73
73
  );
74
74
  await client.query(
75
75
  `DELETE FROM ${qualifyTable('tax_categories')} WHERE id IN ($1, $2)`,
76
- [makeUUID('tax-category', 'expense-general'), makeUUID('tax-category', 'bank-account-tax-category')],
76
+ [makeUUID('expense-general'), makeUUID('bank-account-tax-category')],
77
77
  );
78
78
  await client.query(
79
79
  `DELETE FROM ${qualifyTable('businesses')} WHERE id IN ($1, $2)`,
80
- [makeUUID('business', 'admin-business-scenario-a'), makeUUID('business', 'supplier-local-ltd')],
80
+ [makeUUID('admin-business'), makeUUID('supplier-local-ltd')],
81
81
  );
82
82
  await client.query(
83
83
  `DELETE FROM ${qualifyTable('financial_entities')} WHERE id IN ($1, $2, $3, $4)`,
84
84
  [
85
- makeUUID('business', 'admin-business-scenario-a'),
86
- makeUUID('business', 'supplier-local-ltd'),
87
- makeUUID('tax-category', 'expense-general'),
88
- makeUUID('tax-category', 'bank-account-tax-category'),
85
+ makeUUID('admin-business'),
86
+ makeUUID('supplier-local-ltd'),
87
+ makeUUID('expense-general'),
88
+ makeUUID('bank-account-tax-category'),
89
89
  ],
90
90
  );
91
91
  } finally {
@@ -101,7 +101,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
101
101
 
102
102
  await insertFixture(insertClient, expenseScenarioA);
103
103
 
104
- const chargeId = makeUUID('charge', 'charge-office-supplies');
104
+ const chargeId = makeUUID('charge-office-supplies');
105
105
 
106
106
  // Verify inserts within the same transaction
107
107
  const chargeResult = await insertClient.query(
@@ -137,7 +137,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
137
137
  // Re-open a new client (outside prior transaction) for verification & generation
138
138
  const client = await db.getPool().connect();
139
139
  try {
140
- const chargeId = makeUUID('charge', 'charge-office-supplies');
140
+ const chargeId = makeUUID('charge-office-supplies');
141
141
  const chargeResult = await client.query(
142
142
  `SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
143
143
  [chargeId],
@@ -192,8 +192,8 @@ describe('Ledger Generation - Expense Scenario A', () => {
192
192
  assertSimpleLocalExpenseScenario(ledgerResult.rows as any, {
193
193
  chargeId: charge.id,
194
194
  ownerId: charge.owner_id, // Use actual charge owner for ledger record owner assertions
195
- expenseEntity: makeUUID('tax-category', 'expense-general'),
196
- bankEntity: makeUUID('tax-category', 'bank-account-tax-category'),
195
+ expenseEntity: makeUUID('expense-general'),
196
+ bankEntity: makeUUID('bank-account-tax-category'),
197
197
  expectedCurrency: Currency.Ils,
198
198
  expectedTotal: ledgerExpectation?.totalDebitLocal || 500.0,
199
199
  });
@@ -212,7 +212,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
212
212
  it('should be idempotent on repeated ledger generation (no duplicate records)', async () => {
213
213
  const client = await db.getPool().connect();
214
214
  try {
215
- const chargeId = makeUUID('charge', 'charge-office-supplies');
215
+ const chargeId = makeUUID('charge-office-supplies');
216
216
  // Ensure fixture inserted (if previous test did cleanup, reinsert minimal fixture)
217
217
  const existingCharge = await client.query(
218
218
  `SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
@@ -296,7 +296,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
296
296
  expect(expenseScenarioA.expectations?.ledger).toHaveLength(1);
297
297
 
298
298
  const ledgerExpectation = expenseScenarioA.expectations?.ledger?.[0];
299
- expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge', 'charge-office-supplies'));
299
+ expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge-office-supplies'));
300
300
  expect(ledgerExpectation?.recordCount).toBe(2);
301
301
  expect(ledgerExpectation?.balanced).toBe(true);
302
302
  expect(ledgerExpectation?.totalDebitLocal).toBe(500.0);
@@ -307,11 +307,11 @@ describe('Ledger Generation - Expense Scenario A', () => {
307
307
 
308
308
  it('should create deterministic UUIDs for reproducible tests', () => {
309
309
  // Verify all IDs are deterministic and match expected values
310
- const adminBusinessId = makeUUID('business', 'admin-business-scenario-a');
311
- const supplierId = makeUUID('business', 'supplier-local-ltd');
312
- const chargeId = makeUUID('charge', 'charge-office-supplies');
313
- const transactionId = makeUUID('transaction', 'transaction-supplies-payment');
314
- const documentId = makeUUID('document', 'document-supplies-receipt');
310
+ const adminBusinessId = makeUUID('admin-business');
311
+ const supplierId = makeUUID('supplier-local-ltd');
312
+ const chargeId = makeUUID('charge-office-supplies');
313
+ const transactionId = makeUUID('transaction-supplies-payment');
314
+ const documentId = makeUUID('document-supplies-receipt');
315
315
 
316
316
  expect(adminBusinessId).toBe(expenseScenarioA.businesses?.businesses[0]?.id);
317
317
  expect(supplierId).toBe(expenseScenarioA.businesses?.businesses[1]?.id);
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
2
2
  import { TestDatabase } from '../../../__tests__/helpers/db-setup.js';
3
3
  import { insertFixture } from '../../../__tests__/helpers/fixture-loader.js';
4
4
  import { expenseScenarioB } from '../../../__tests__/fixtures/expenses/expense-scenario-b.js';
5
- import { makeUUID } from '../../../demo-fixtures/helpers/deterministic-uuid.js';
5
+ import { makeUUID } from '../../../__tests__/factories/ids.js';
6
6
  import { qualifyTable } from '../../../__tests__/helpers/test-db-config.js';
7
7
  import { buildAdminContextFromDb } from '../../../__tests__/helpers/admin-context-builder.js';
8
8
  import { mockExchangeRate } from '../../../__tests__/helpers/exchange-mock.js';
@@ -48,7 +48,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
48
48
  afterEach(async () => {
49
49
  const client = await db.getPool().connect();
50
50
  try {
51
- const chargeId = makeUUID('charge', 'charge-consulting-services');
51
+ const chargeId = makeUUID('charge-consulting-services');
52
52
  await client.query(
53
53
  `DELETE FROM ${qualifyTable('ledger_records')} WHERE charge_id = $1`,
54
54
  [chargeId],
@@ -70,7 +70,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
70
70
  await client.query(
71
71
  `DELETE FROM ${qualifyTable('financial_accounts_tax_categories')}
72
72
  WHERE tax_category_id IN ($1, $2)`,
73
- [makeUUID('tax-category', 'expense-consulting'), makeUUID('tax-category', 'usd-account-tax-category')],
73
+ [makeUUID('expense-consulting'), makeUUID('usd-account-tax-category')],
74
74
  );
75
75
  await client.query(
76
76
  `DELETE FROM ${qualifyTable('financial_accounts')} WHERE account_number = $1`,
@@ -78,19 +78,19 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
78
78
  );
79
79
  await client.query(
80
80
  `DELETE FROM ${qualifyTable('tax_categories')} WHERE id IN ($1, $2)`,
81
- [makeUUID('tax-category', 'expense-consulting'), makeUUID('tax-category', 'usd-account-tax-category')],
81
+ [makeUUID('expense-consulting'), makeUUID('usd-account-tax-category')],
82
82
  );
83
83
  await client.query(
84
84
  `DELETE FROM ${qualifyTable('businesses')} WHERE id IN ($1, $2)`,
85
- [makeUUID('business', 'admin-business-usd'), makeUUID('business', 'supplier-us-vendor-llc')],
85
+ [makeUUID('admin-business-usd'), makeUUID('supplier-us-vendor-llc')],
86
86
  );
87
87
  await client.query(
88
88
  `DELETE FROM ${qualifyTable('financial_entities')} WHERE id IN ($1, $2, $3, $4)`,
89
89
  [
90
- makeUUID('business', 'admin-business-usd'),
91
- makeUUID('business', 'supplier-us-vendor-llc'),
92
- makeUUID('tax-category', 'expense-consulting'),
93
- makeUUID('tax-category', 'usd-account-tax-category'),
90
+ makeUUID('admin-business-usd'),
91
+ makeUUID('supplier-us-vendor-llc'),
92
+ makeUUID('expense-consulting'),
93
+ makeUUID('usd-account-tax-category'),
94
94
  ],
95
95
  );
96
96
  } finally {
@@ -106,7 +106,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
106
106
 
107
107
  await insertFixture(insertClient, expenseScenarioB);
108
108
 
109
- const chargeId = makeUUID('charge', 'charge-consulting-services');
109
+ const chargeId = makeUUID('charge-consulting-services');
110
110
 
111
111
  // Verify inserts within the same transaction
112
112
  const chargeResult = await insertClient.query(
@@ -143,7 +143,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
143
143
  // Re-open a new client (outside prior transaction) for verification & generation
144
144
  const client = await db.getPool().connect();
145
145
  try {
146
- const chargeId = makeUUID('charge', 'charge-consulting-services');
146
+ const chargeId = makeUUID('charge-consulting-services');
147
147
  const chargeResult = await client.query(
148
148
  `SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
149
149
  [chargeId],
@@ -200,8 +200,8 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
200
200
  assertForeignExpenseScenario(ledgerResult.rows as any, {
201
201
  chargeId: charge.id,
202
202
  ownerId: charge.owner_id, // Use actual charge owner id
203
- expenseEntity: makeUUID('tax-category', 'expense-consulting'),
204
- bankEntity: makeUUID('tax-category', 'usd-account-tax-category'),
203
+ expenseEntity: makeUUID('expense-consulting'),
204
+ bankEntity: makeUUID('usd-account-tax-category'),
205
205
  expectedCurrency: Currency.Usd,
206
206
  expectedForeignAmount: ledgerExpectation?.foreignAmount || 200.0,
207
207
  expectedRate: ledgerExpectation?.exchangeRate || 3.5,
@@ -222,7 +222,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
222
222
  it('should be idempotent on repeated foreign ledger generation (no duplicate records)', async () => {
223
223
  const client = await db.getPool().connect();
224
224
  try {
225
- const chargeId = makeUUID('charge', 'charge-consulting-services');
225
+ const chargeId = makeUUID('charge-consulting-services');
226
226
  // Ensure fixture inserted if absent
227
227
  const existingCharge = await client.query(
228
228
  `SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
@@ -310,14 +310,14 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
310
310
  const accountMapping = expenseScenarioB.accountTaxCategories?.mappings[0];
311
311
  expect(accountMapping?.accountNumber).toBe('USD-ACCOUNT-001');
312
312
  expect(accountMapping?.currency).toBe(Currency.Usd);
313
- expect(accountMapping?.taxCategoryId).toBe(makeUUID('tax-category', 'usd-account-tax-category'));
313
+ expect(accountMapping?.taxCategoryId).toBe(makeUUID('usd-account-tax-category'));
314
314
 
315
315
  // Verify expectations are defined
316
316
  expect(expenseScenarioB.expectations).toBeDefined();
317
317
  expect(expenseScenarioB.expectations?.ledger).toHaveLength(1);
318
318
 
319
319
  const ledgerExpectation = expenseScenarioB.expectations?.ledger?.[0];
320
- expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge', 'charge-consulting-services'));
320
+ expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge-consulting-services'));
321
321
  expect(ledgerExpectation?.recordCount).toBe(2);
322
322
  expect(ledgerExpectation?.balanced).toBe(true);
323
323
  expect(ledgerExpectation?.totalDebitLocal).toBe(1400.0);
@@ -331,11 +331,11 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
331
331
 
332
332
  it('should create deterministic UUIDs for reproducible tests', () => {
333
333
  // Verify all IDs are deterministic and match expected values
334
- const adminBusinessId = makeUUID('business', 'admin-business-usd');
335
- const supplierId = makeUUID('business', 'supplier-us-vendor-llc');
336
- const chargeId = makeUUID('charge', 'charge-consulting-services');
337
- const transactionId = makeUUID('transaction', 'transaction-consulting-payment');
338
- const documentId = makeUUID('document', 'document-consulting-invoice');
334
+ const adminBusinessId = makeUUID('admin-business-usd');
335
+ const supplierId = makeUUID('supplier-us-vendor-llc');
336
+ const chargeId = makeUUID('charge-consulting-services');
337
+ const transactionId = makeUUID('transaction-consulting-payment');
338
+ const documentId = makeUUID('document-consulting-invoice');
339
339
 
340
340
  expect(adminBusinessId).toBe(expenseScenarioB.businesses?.businesses[0]?.id);
341
341
  expect(supplierId).toBe(expenseScenarioB.businesses?.businesses[1]?.id);
@@ -1,58 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { makeUUID } from '../helpers/deterministic-uuid.js';
3
- describe('deterministic-uuid', () => {
4
- describe('makeUUID', () => {
5
- it('generates same UUID for same inputs', () => {
6
- const uuid1 = makeUUID('business', 'acme-consulting-llc');
7
- const uuid2 = makeUUID('business', 'acme-consulting-llc');
8
- expect(uuid1).toBe(uuid2);
9
- expect(uuid1).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
10
- });
11
- it('generates different UUIDs for different names', () => {
12
- const uuid1 = makeUUID('business', 'acme-llc');
13
- const uuid2 = makeUUID('business', 'acme-corp');
14
- expect(uuid1).not.toBe(uuid2);
15
- });
16
- it('generates different UUIDs for different namespaces', () => {
17
- const businessUUID = makeUUID('business', 'acme');
18
- const chargeUUID = makeUUID('charge', 'acme');
19
- expect(businessUUID).not.toBe(chargeUUID);
20
- });
21
- it('includes namespace in composite key', () => {
22
- // Same name, different namespace types
23
- const bizUUID = makeUUID('business', 'test-entity');
24
- const transactionUUID = makeUUID('transaction', 'test-entity');
25
- const documentUUID = makeUUID('document', 'test-entity');
26
- expect(bizUUID).not.toBe(transactionUUID);
27
- expect(bizUUID).not.toBe(documentUUID);
28
- expect(transactionUUID).not.toBe(documentUUID);
29
- });
30
- it('generates valid UUID v5 format', () => {
31
- const uuid = makeUUID('charge', 'monthly-invoice-2024-11');
32
- // UUID v5 format: xxxxxxxx-xxxx-5xxx-yxxx-xxxxxxxxxxxx
33
- // where y is one of [8, 9, a, b]
34
- expect(uuid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
35
- });
36
- it('handles kebab-case names correctly', () => {
37
- const uuid1 = makeUUID('business', 'us-supplier-acme-llc');
38
- const uuid2 = makeUUID('business', 'us-supplier-acme-llc');
39
- expect(uuid1).toBe(uuid2);
40
- });
41
- it('handles numeric components in names', () => {
42
- const uuid1 = makeUUID('charge', 'invoice-2024-11-15');
43
- const uuid2 = makeUUID('charge', 'invoice-2024-11-15');
44
- expect(uuid1).toBe(uuid2);
45
- });
46
- it('is case-sensitive for names', () => {
47
- const uuid1 = makeUUID('business', 'acme-llc');
48
- const uuid2 = makeUUID('business', 'ACME-LLC');
49
- expect(uuid1).not.toBe(uuid2);
50
- });
51
- it('is case-sensitive for namespaces', () => {
52
- const uuid1 = makeUUID('business', 'acme');
53
- const uuid2 = makeUUID('Business', 'acme');
54
- expect(uuid1).not.toBe(uuid2);
55
- });
56
- });
57
- });
58
- //# sourceMappingURL=deterministic-uuid.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deterministic-uuid.test.js","sourceRoot":"","sources":["../../../../../src/demo-fixtures/__tests__/deterministic-uuid.test.ts"],"names":[],"mappings":"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"}
@@ -1,50 +0,0 @@
1
- /**
2
- * Generate deterministic UUID v5 from semantic name.
3
- *
4
- * This function creates stable, reproducible UUIDs for demo/staging data entities.
5
- * The same namespace + name combination will always produce the same UUID across
6
- * deployments, making it safe to reference these IDs in documentation, screenshots,
7
- * and external links.
8
- *
9
- * @param namespace - Entity type: 'business', 'charge', 'transaction', 'document', etc.
10
- * @param name - Semantic identifier (kebab-case recommended)
11
- * @returns UUID v5 string (e.g., '550e8400-e29b-41d4-a716-446655440000')
12
- *
13
- * @example
14
- * ```typescript
15
- * // Business entity
16
- * makeUUID('business', 'acme-consulting-llc')
17
- * // => Always produces same UUID
18
- *
19
- * // Charge entity
20
- * makeUUID('charge', 'consulting-invoice-2024-11')
21
- * // => Stable across deploys
22
- *
23
- * // Financial account
24
- * makeUUID('financial-account', 'bank-usd-account')
25
- * // => Different from makeUUID('business', 'bank-usd-account')
26
- * ```
27
- *
28
- * @remarks
29
- * **Naming Conventions:**
30
- * - Use kebab-case for all semantic names
31
- * - Combine entity type + descriptive name ensures no collisions
32
- * - Never change a semantic name once deployed (breaks external links)
33
- * - For updates to same entity, append version: `acme-consulting-llc-v2`
34
- *
35
- * **Stability Warning:**
36
- * Once a UUID is generated and used in staging/production, the semantic name
37
- * MUST NOT be changed. Doing so will generate a different UUID and break:
38
- * - External documentation with embedded links
39
- * - Screenshots with visible UUIDs
40
- * - Any hardcoded references in client applications
41
- *
42
- * If you need to modify an entity, create a new semantic name with a version suffix.
43
- */
44
- export declare function makeUUID(namespace: string, name: string): string;
45
- /**
46
- * Backward compatible adapter for legacy single-argument API.
47
- * - When seed is provided, returns deterministic UUID v5 scoped under 'legacy' namespace
48
- * - When seed omitted, returns a random UUID to preserve previous behavior
49
- */
50
- export declare function makeUUIDLegacy(seed?: string): string;