@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
@@ -3,7 +3,7 @@ import {
3
3
  createFinancialAccount,
4
4
  FINANCIAL_ACCOUNT_TYPES,
5
5
  } from './financial-account.js';
6
- import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.js';
6
+ import { makeUUID } from './ids.js';
7
7
 
8
8
  describe('Factory: Financial Account', () => {
9
9
  describe('FINANCIAL_ACCOUNT_TYPES', () => {
@@ -47,7 +47,7 @@ describe('Factory: Financial Account', () => {
47
47
  });
48
48
 
49
49
  it('should apply overrides correctly', () => {
50
- const ownerId = makeUUID('business', 'business-owner');
50
+ const ownerId = makeUUID('business-owner');
51
51
  const account = createFinancialAccount({
52
52
  accountNumber: '123456789',
53
53
  name: 'Main Business Account',
@@ -96,7 +96,7 @@ describe('Factory: Financial Account', () => {
96
96
  });
97
97
 
98
98
  it('should create bank account scenario', () => {
99
- const ownerId = makeUUID('business', 'business');
99
+ const ownerId = makeUUID('business');
100
100
  const account = createFinancialAccount({
101
101
  accountNumber: '12-345-6789',
102
102
  type: 'BANK_ACCOUNT',
@@ -113,7 +113,7 @@ describe('Factory: Financial Account', () => {
113
113
  });
114
114
 
115
115
  it('should create credit card scenario', () => {
116
- const ownerId = makeUUID('business', 'business');
116
+ const ownerId = makeUUID('business');
117
117
  const account = createFinancialAccount({
118
118
  accountNumber: '4580-****-****-1234',
119
119
  type: 'CREDIT_CARD',
@@ -127,7 +127,7 @@ describe('Factory: Financial Account', () => {
127
127
  });
128
128
 
129
129
  it('should create crypto wallet scenario', () => {
130
- const ownerId = makeUUID('business', 'business');
130
+ const ownerId = makeUUID('business');
131
131
  const account = createFinancialAccount({
132
132
  accountNumber: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
133
133
  type: 'CRYPTO_WALLET',
@@ -141,7 +141,7 @@ describe('Factory: Financial Account', () => {
141
141
  });
142
142
 
143
143
  it('should create bank deposit account scenario', () => {
144
- const ownerId = makeUUID('business', 'business');
144
+ const ownerId = makeUUID('business');
145
145
  const account = createFinancialAccount({
146
146
  accountNumber: 'DEP-123456',
147
147
  type: 'BANK_DEPOSIT_ACCOUNT',
@@ -154,7 +154,7 @@ describe('Factory: Financial Account', () => {
154
154
  });
155
155
 
156
156
  it('should create foreign securities account scenario', () => {
157
- const ownerId = makeUUID('business', 'business');
157
+ const ownerId = makeUUID('business');
158
158
  const account = createFinancialAccount({
159
159
  accountNumber: 'SEC-US-789',
160
160
  type: 'FOREIGN_SECURITIES',
@@ -2,7 +2,7 @@ import type {
2
2
  financial_account_type,
3
3
  IInsertFinancialAccountsParams,
4
4
  } from '../../modules/financial-accounts/__generated__/financial-accounts.types.js';
5
- import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
5
+ import { makeUUID } from './ids.js';
6
6
 
7
7
  /**
8
8
  * Valid financial account types
@@ -59,11 +59,11 @@ export function createFinancialAccount(
59
59
  overrides?: Partial<IInsertFinancialAccountsParams['bankAccounts'][number]>,
60
60
  ): IInsertFinancialAccountsParams['bankAccounts'][number] {
61
61
  return {
62
- accountNumber: makeUUIDLegacy().slice(0, 13), // Default: unique short string
62
+ accountNumber: makeUUID().slice(0, 13), // Default: unique short string
63
63
  name: null,
64
64
  privateBusiness: 'PRIVATE',
65
65
  ownerId: null,
66
66
  type: 'BANK_ACCOUNT',
67
67
  ...overrides,
68
68
  };
69
- }
69
+ }
@@ -0,0 +1,80 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { UUID_REGEX } from '../../shared/constants.js';
3
+ import { makeUUID } from './ids.js';
4
+
5
+ describe('Factory Helpers: IDs', () => {
6
+ describe('makeUUID', () => {
7
+ it('should generate a valid UUID format', () => {
8
+ const id = makeUUID();
9
+ expect(id).toMatch(UUID_REGEX);
10
+ });
11
+
12
+ it('should generate different UUIDs without seed', () => {
13
+ const id1 = makeUUID();
14
+ const id2 = makeUUID();
15
+ expect(id1).not.toBe(id2);
16
+ });
17
+
18
+ it('should generate deterministic UUID with seed', () => {
19
+ const seed = 'admin-business';
20
+ const id1 = makeUUID(seed);
21
+ const id2 = makeUUID(seed);
22
+ expect(id1).toBe(id2);
23
+ });
24
+
25
+ it('should generate different UUIDs for different seeds', () => {
26
+ const id1 = makeUUID('seed-one');
27
+ const id2 = makeUUID('seed-two');
28
+ expect(id1).not.toBe(id2);
29
+ });
30
+
31
+ it('should generate valid UUID v4 format with seed', () => {
32
+ const id = makeUUID('test-seed');
33
+ expect(id).toMatch(UUID_REGEX);
34
+ // Version bits should be 4
35
+ expect(id.charAt(14)).toBe('4');
36
+ });
37
+
38
+ it('should handle empty string seed', () => {
39
+ const id1 = makeUUID('');
40
+ const id2 = makeUUID('');
41
+ // Empty string seed should produce same deterministic UUID
42
+ expect(id1).toBe(id2);
43
+ expect(id1).toMatch(UUID_REGEX);
44
+ // Empty string produces specific deterministic UUID (hash of '' = 0)
45
+ expect(id1).toBe('00000000-0000-4000-8000-000000000000');
46
+ });
47
+
48
+ it('should handle complex seed strings', () => {
49
+ const seeds = [
50
+ 'admin-business-123',
51
+ 'supplier_with_underscores',
52
+ 'UPPERCASE-SEED',
53
+ 'seed with spaces',
54
+ 'seed-with-special-chars-!@#$%',
55
+ ];
56
+
57
+ seeds.forEach(seed => {
58
+ const id = makeUUID(seed);
59
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
60
+ expect(id).toMatch(uuidRegex);
61
+ });
62
+ });
63
+
64
+ it('should be consistent across multiple calls with same seed', () => {
65
+ const seed = 'consistent-seed';
66
+ const ids = Array.from({ length: 10 }, () => makeUUID(seed));
67
+ const uniqueIds = new Set(ids);
68
+ expect(uniqueIds.size).toBe(1);
69
+ });
70
+
71
+ it('should generate different IDs for similar but different seeds', () => {
72
+ const id1 = makeUUID('test');
73
+ const id2 = makeUUID('test1');
74
+ const id3 = makeUUID('test-');
75
+ expect(id1).not.toBe(id2);
76
+ expect(id1).not.toBe(id3);
77
+ expect(id2).not.toBe(id3);
78
+ });
79
+ });
80
+ });
@@ -0,0 +1,49 @@
1
+ import { randomUUID } from 'node:crypto';
2
+
3
+ /**
4
+ * Generate a UUID for use in test fixtures
5
+ *
6
+ * @param seed - Optional seed string for deterministic UUID generation
7
+ * @returns A valid UUID v4 string
8
+ *
9
+ * @remarks
10
+ * - When seed is provided, generates a deterministic UUID based on the seed
11
+ * - When seed is omitted, generates a random UUID
12
+ * - Deterministic mode uses a simple hash-based approach for test reproducibility
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Random UUID
17
+ * const id1 = makeUUID(); // e.g., '123e4567-e89b-12d3-a456-426614174000'
18
+ *
19
+ * // Deterministic UUID (same seed always produces same UUID)
20
+ * const id2 = makeUUID('admin-business'); // Always same UUID
21
+ * const id3 = makeUUID('admin-business'); // Same as id2
22
+ * ```
23
+ */
24
+ export function makeUUID(seed?: string): string {
25
+ // Check for undefined or null (not provided), but treat empty string as valid seed
26
+ if (seed === undefined || seed === null) {
27
+ return randomUUID();
28
+ }
29
+
30
+ // Simple deterministic UUID generation from seed
31
+ // Use a basic hash to convert seed to hex values
32
+ let hash = 0;
33
+ for (let i = 0; i < seed.length; i++) {
34
+ hash = (hash << 5) - hash + seed.charCodeAt(i);
35
+ hash = hash & hash; // Convert to 32-bit integer
36
+ }
37
+
38
+ // Generate deterministic hex values
39
+ const hex = (Math.abs(hash) * 123456789).toString(16).padStart(32, '0').slice(0, 32);
40
+
41
+ // Format as UUID v4 (with version and variant bits set correctly)
42
+ return [
43
+ hex.slice(0, 8),
44
+ hex.slice(8, 12),
45
+ `4${hex.slice(13, 16)}`, // Version 4
46
+ `${((parseInt(hex.slice(16, 18), 16) & 0x3f) | 0x80).toString(16)}${hex.slice(18, 20)}`, // Variant bits
47
+ hex.slice(20, 32),
48
+ ].join('-');
49
+ }
@@ -36,18 +36,18 @@ describe('Factory Integration', () => {
36
36
 
37
37
  it('should create a complete expense scenario using factories', () => {
38
38
  // Setup: Create supporting entities
39
- const supplierId = makeUUID('business', 'supplier-local');
39
+ const supplierId = makeUUID('supplier-local');
40
40
  const supplier = createBusiness({
41
41
  id: supplierId,
42
42
  hebrewName: 'ספק מקומי',
43
43
  });
44
44
 
45
- const taxCategoryId = makeUUID('tax-category', 'tax-expense');
45
+ const taxCategoryId = makeUUID('tax-expense');
46
46
  const taxCategory = createTaxCategory({
47
47
  id: taxCategoryId,
48
48
  });
49
49
 
50
- const accountId = makeUUID('financial-account', 'bank-account');
50
+ const accountId = makeUUID('bank-account');
51
51
  const account = createFinancialAccount({
52
52
  accountNumber: accountId,
53
53
  type: 'BANK_ACCOUNT',
@@ -55,7 +55,7 @@ describe('Factory Integration', () => {
55
55
  });
56
56
 
57
57
  // Act: Create charge with transaction and document
58
- const chargeId = makeUUID('charge', 'expense-charge');
58
+ const chargeId = makeUUID('expense-charge');
59
59
  const charge = createCharge(
60
60
  {
61
61
  owner_id: supplierId,
@@ -106,8 +106,8 @@ describe('Factory Integration', () => {
106
106
 
107
107
  it('should create deterministic UUIDs with seeds', () => {
108
108
  // Create same entities twice with same seeds
109
- const business1 = createBusiness({ id: makeUUID('business', 'biz-1') });
110
- const business2 = createBusiness({ id: makeUUID('business', 'biz-1') });
109
+ const business1 = createBusiness({ id: makeUUID('biz-1') });
110
+ const business2 = createBusiness({ id: makeUUID('biz-1') });
111
111
 
112
112
  expect(business1.id).toBe(business2.id);
113
113
  });
@@ -118,7 +118,7 @@ describe('Factory Integration', () => {
118
118
  types.forEach((type, index) => {
119
119
  const account = createFinancialAccount({
120
120
  type,
121
- ownerId: makeUUID('business', `owner-${index}`),
121
+ ownerId: makeUUID(`owner-${index}`),
122
122
  });
123
123
 
124
124
  expect(account.type).toBe(type);
@@ -128,8 +128,8 @@ describe('Factory Integration', () => {
128
128
 
129
129
  it('should handle numeric conversions correctly', () => {
130
130
  const transaction = createTransaction({
131
- charge_id: makeUUID('charge', 'charge-1'),
132
- business_id: makeUUID('business', 'business-1'),
131
+ charge_id: makeUUID('charge-1'),
132
+ business_id: makeUUID('business-1'),
133
133
  amount: -123.45, // Number input
134
134
  currency: 'USD',
135
135
  event_date: '2024-01-15',
@@ -140,9 +140,9 @@ describe('Factory Integration', () => {
140
140
  });
141
141
 
142
142
  it('should create documents with different types', () => {
143
- const chargeId = makeUUID('charge', 'charge-doc');
144
- const creditorId = makeUUID('business', 'creditor');
145
- const debtorId = makeUUID('business', 'debtor');
143
+ const chargeId = makeUUID('charge-doc');
144
+ const creditorId = makeUUID('creditor');
145
+ const debtorId = makeUUID('debtor');
146
146
 
147
147
  const invoice = createDocument({
148
148
  charge_id: chargeId,
@@ -18,7 +18,7 @@
18
18
  * } from '../factories';
19
19
  *
20
20
  * // Create a complete charge scenario
21
- * const businessId = makeUUID('business', 'supplier-1');
21
+ * const businessId = makeUUID('supplier-1');
22
22
  * const business = createBusiness({ id: businessId });
23
23
  * const charge = createCharge({ owner_id: businessId });
24
24
  * const transaction = createTransaction({
@@ -51,6 +51,6 @@ export { createDocument } from './document.js';
51
51
  export type { DocumentInsertParams } from './document.js';
52
52
 
53
53
  // Helper utilities
54
- export { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.js';
54
+ export { makeUUID } from './ids.js';
55
55
  export { iso, isoToday, addDays } from './dates.js';
56
56
  export { formatNumeric, formatMoney, formatDecimal, parseNumeric } from './money.js';
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { UUID_REGEX } from '../../shared/constants.js';
3
- import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.js';
3
+ import { makeUUID } from './ids.js';
4
4
  import { createTaxCategory } from './tax-category.js';
5
5
 
6
6
  describe('Factory: Tax Category', () => {
@@ -27,7 +27,7 @@ describe('Factory: Tax Category', () => {
27
27
  });
28
28
 
29
29
  it('should apply overrides correctly', () => {
30
- const customId = makeUUID('tax-category', 'tax-cat-expense');
30
+ const customId = makeUUID('tax-cat-expense');
31
31
  const category = createTaxCategory({
32
32
  id: customId,
33
33
  hashavshevetName: 'משרדיות',
@@ -84,8 +84,8 @@ describe('Factory: Tax Category', () => {
84
84
  });
85
85
 
86
86
  it('should create deterministic categories with seed', () => {
87
- const category1 = createTaxCategory({ id: makeUUID('tax-category', 'default-category') });
88
- const category2 = createTaxCategory({ id: makeUUID('tax-category', 'default-category') });
87
+ const category1 = createTaxCategory({ id: makeUUID('default-category') });
88
+ const category2 = createTaxCategory({ id: makeUUID('default-category') });
89
89
 
90
90
  expect(category1.id).toBe(category2.id);
91
91
  });
@@ -1,5 +1,5 @@
1
1
  import type { IInsertTaxCategoryParams } from '../../modules/financial-entities/__generated__/tax-categories.types.js';
2
- import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
2
+ import { makeUUID } from './ids.js';
3
3
 
4
4
  /**
5
5
  * Tax category factory for test fixtures
@@ -17,17 +17,17 @@ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.j
17
17
  * @example
18
18
  * ```typescript
19
19
  * // Minimal tax category
20
- * const category = createTaxCategory({ id: makeUUID('tax-category', 'expense-general') });
20
+ * const category = createTaxCategory({ id: makeUUID('expense-general') });
21
21
  *
22
22
  * // Tax category with Hashavshevet integration
23
23
  * const integrated = createTaxCategory({
24
- * id: makeUUID('tax-category', 'expense-office'),
24
+ * id: makeUUID('expense-office'),
25
25
  * hashavshevetName: 'משרדיות',
26
26
  * });
27
27
  *
28
28
  * // Tax-excluded category
29
29
  * const excluded = createTaxCategory({
30
- * id: makeUUID('tax-category', 'income-exempt'),
30
+ * id: makeUUID('income-exempt'),
31
31
  * taxExcluded: true,
32
32
  * });
33
33
  * ```
@@ -35,11 +35,10 @@ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.j
35
35
  export function createTaxCategory(
36
36
  overrides?: Partial<IInsertTaxCategoryParams>,
37
37
  ): IInsertTaxCategoryParams {
38
- const defaultId = makeUUIDLegacy();
39
38
  return {
40
- id: defaultId,
39
+ id: makeUUID(),
41
40
  hashavshevetName: null,
42
41
  taxExcluded: false,
43
42
  ...overrides,
44
43
  };
45
- }
44
+ }
@@ -1,13 +1,13 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { UUID_REGEX } from '../../shared/constants.js';
3
3
  import { createTransaction } from './transaction.js';
4
- import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.js';
4
+ import { makeUUID } from './ids.js';
5
5
 
6
6
  describe('Factory: Transaction', () => {
7
7
  describe('createTransaction', () => {
8
8
  it('should create transaction with required fields', () => {
9
- const chargeId = makeUUID('charge', 'charge-1');
10
- const businessId = makeUUID('business', 'business-1');
9
+ const chargeId = makeUUID('charge-1');
10
+ const businessId = makeUUID('business-1');
11
11
 
12
12
  const transaction = createTransaction({
13
13
  charge_id: chargeId,
@@ -40,8 +40,8 @@ describe('Factory: Transaction', () => {
40
40
  });
41
41
 
42
42
  it('should generate unique IDs by default', () => {
43
- const chargeId = makeUUID('charge', 'charge-1');
44
- const businessId = makeUUID('business', 'business-1');
43
+ const chargeId = makeUUID('charge-1');
44
+ const businessId = makeUUID('business-1');
45
45
 
46
46
  const transaction1 = createTransaction({
47
47
  charge_id: chargeId,
@@ -63,8 +63,8 @@ describe('Factory: Transaction', () => {
63
63
  });
64
64
 
65
65
  it('should accept numeric amount and convert to string', () => {
66
- const chargeId = makeUUID('charge', 'charge-1');
67
- const businessId = makeUUID('business', 'business-1');
66
+ const chargeId = makeUUID('charge-1');
67
+ const businessId = makeUUID('business-1');
68
68
 
69
69
  const transaction = createTransaction({
70
70
  charge_id: chargeId,
@@ -78,8 +78,8 @@ describe('Factory: Transaction', () => {
78
78
  });
79
79
 
80
80
  it('should accept Date object for event_date and convert to ISO string', () => {
81
- const chargeId = makeUUID('charge', 'charge-1');
82
- const businessId = makeUUID('business', 'business-1');
81
+ const chargeId = makeUUID('charge-1');
82
+ const businessId = makeUUID('business-1');
83
83
  const date = new Date('2024-03-15T12:00:00Z');
84
84
 
85
85
  const transaction = createTransaction({
@@ -94,8 +94,8 @@ describe('Factory: Transaction', () => {
94
94
  });
95
95
 
96
96
  it('should handle is_fee parameter', () => {
97
- const chargeId = makeUUID('charge', 'charge-1');
98
- const businessId = makeUUID('business', 'bank');
97
+ const chargeId = makeUUID('charge-1');
98
+ const businessId = makeUUID('bank');
99
99
 
100
100
  const feeTransaction = createTransaction({
101
101
  charge_id: chargeId,
@@ -110,10 +110,10 @@ describe('Factory: Transaction', () => {
110
110
  });
111
111
 
112
112
  it('should apply overrides correctly', () => {
113
- const chargeId = makeUUID('charge', 'charge-1');
114
- const businessId = makeUUID('business', 'business-1');
115
- const customId = makeUUID('transaction', 'custom-tx');
116
- const accountId = makeUUID('financial-account', 'eur-account');
113
+ const chargeId = makeUUID('charge-1');
114
+ const businessId = makeUUID('business-1');
115
+ const customId = makeUUID('custom-tx');
116
+ const accountId = makeUUID('eur-account');
117
117
 
118
118
  const transaction = createTransaction(
119
119
  {
@@ -140,8 +140,8 @@ describe('Factory: Transaction', () => {
140
140
  });
141
141
 
142
142
  it('should allow partial overrides', () => {
143
- const chargeId = makeUUID('charge', 'charge-1');
144
- const businessId = makeUUID('business', 'business-1');
143
+ const chargeId = makeUUID('charge-1');
144
+ const businessId = makeUUID('business-1');
145
145
 
146
146
  const transaction = createTransaction(
147
147
  {
@@ -162,8 +162,8 @@ describe('Factory: Transaction', () => {
162
162
  });
163
163
 
164
164
  it('should preserve all required fields', () => {
165
- const chargeId = makeUUID('charge', 'charge-1');
166
- const businessId = makeUUID('business', 'business-1');
165
+ const chargeId = makeUUID('charge-1');
166
+ const businessId = makeUUID('business-1');
167
167
 
168
168
  const transaction = createTransaction({
169
169
  charge_id: chargeId,
@@ -189,8 +189,8 @@ describe('Factory: Transaction', () => {
189
189
  });
190
190
 
191
191
  it('should handle different currency types', () => {
192
- const chargeId = makeUUID('charge', 'charge-1');
193
- const businessId = makeUUID('business', 'business-1');
192
+ const chargeId = makeUUID('charge-1');
193
+ const businessId = makeUUID('business-1');
194
194
 
195
195
  const ilsTransaction = createTransaction({
196
196
  charge_id: chargeId,
@@ -222,8 +222,8 @@ describe('Factory: Transaction', () => {
222
222
  });
223
223
 
224
224
  it('should handle negative amounts (expenses)', () => {
225
- const chargeId = makeUUID('charge', 'charge-1');
226
- const businessId = makeUUID('business', 'supplier');
225
+ const chargeId = makeUUID('charge-1');
226
+ const businessId = makeUUID('supplier');
227
227
 
228
228
  const expense = createTransaction({
229
229
  charge_id: chargeId,
@@ -237,8 +237,8 @@ describe('Factory: Transaction', () => {
237
237
  });
238
238
 
239
239
  it('should handle positive amounts (income)', () => {
240
- const chargeId = makeUUID('charge', 'charge-1');
241
- const businessId = makeUUID('business', 'customer');
240
+ const chargeId = makeUUID('charge-1');
241
+ const businessId = makeUUID('customer');
242
242
 
243
243
  const income = createTransaction({
244
244
  charge_id: chargeId,
@@ -252,8 +252,8 @@ describe('Factory: Transaction', () => {
252
252
  });
253
253
 
254
254
  it('should allow explicit null overrides', () => {
255
- const chargeId = makeUUID('charge', 'charge-1');
256
- const businessId = makeUUID('business', 'business-1');
255
+ const chargeId = makeUUID('charge-1');
256
+ const businessId = makeUUID('business-1');
257
257
 
258
258
  const transaction = createTransaction(
259
259
  {
@@ -10,7 +10,7 @@
10
10
  * @see packages/migrations/src/actions/2024-01-29T13-15-23.initial.ts (transactions table)
11
11
  */
12
12
 
13
- import { makeUUID, makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
13
+ import { makeUUID } from './ids.js';
14
14
  import { formatNumeric } from './money.js';
15
15
 
16
16
  /**
@@ -61,8 +61,8 @@ export interface TransactionInsertParams {
61
61
  * ```typescript
62
62
  * // Minimal transaction with required fields
63
63
  * const transaction = createTransaction({
64
- * charge_id: makeUUID('charge', 'charge-1'),
65
- * business_id: makeUUID('business', 'supplier-1'),
64
+ * charge_id: makeUUID('charge-1'),
65
+ * business_id: makeUUID('supplier-1'),
66
66
  * amount: '-100.50',
67
67
  * currency: 'ILS',
68
68
  * event_date: '2024-01-15',
@@ -70,8 +70,8 @@ export interface TransactionInsertParams {
70
70
  *
71
71
  * // Transaction with optional is_fee flag
72
72
  * const feeTransaction = createTransaction({
73
- * charge_id: makeUUID('charge', 'charge-1'),
74
- * business_id: makeUUID('business', 'bank'),
73
+ * charge_id: makeUUID('charge-1'),
74
+ * business_id: makeUUID('bank'),
75
75
  * amount: '-5.00',
76
76
  * currency: 'USD',
77
77
  * event_date: '2024-01-15',
@@ -81,14 +81,14 @@ export interface TransactionInsertParams {
81
81
  * // Transaction with full overrides
82
82
  * const customTransaction = createTransaction(
83
83
  * {
84
- * charge_id: makeUUID('charge', 'charge-1'),
85
- * business_id: makeUUID('business', 'supplier-1'),
84
+ * charge_id: makeUUID('charge-1'),
85
+ * business_id: makeUUID('supplier-1'),
86
86
  * amount: '500.00',
87
87
  * currency: 'EUR',
88
88
  * event_date: '2024-03-10',
89
89
  * },
90
90
  * {
91
- * account_id: makeUUID('account', 'eur-account'),
91
+ * account_id: makeUUID('eur-account'),
92
92
  * source_description: 'Invoice payment EUR',
93
93
  * debit_date: '2024-03-12',
94
94
  * current_balance: '15000.00',
@@ -108,10 +108,10 @@ export function createTransaction(
108
108
  overrides?: Partial<TransactionInsertParams>,
109
109
  ): TransactionInsertParams {
110
110
  return {
111
- id: makeUUIDLegacy(),
112
- account_id: makeUUID('account', 'default-account'),
111
+ id: makeUUID(),
112
+ account_id: makeUUID('default-account'),
113
113
  charge_id: params.charge_id,
114
- source_id: makeUUID('transaction-source', 'source-raw-tx'),
114
+ source_id: makeUUID('source-raw-tx'),
115
115
  source_description: null,
116
116
  currency: params.currency,
117
117
  event_date: