@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
@@ -11,7 +11,7 @@
11
11
  * @see packages/server/src/modules/documents/providers/documents.provider.ts (insertDocuments query)
12
12
  */
13
13
 
14
- import { makeUUID } from './ids.js';
14
+ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
15
15
 
16
16
  /**
17
17
  * Document insert parameters shape
@@ -67,9 +67,9 @@ export interface DocumentInsertParams {
67
67
  * ```typescript
68
68
  * // Minimal invoice document
69
69
  * const invoice = createDocument({
70
- * charge_id: makeUUID('charge-1'),
71
- * creditor_id: makeUUID('supplier-1'),
72
- * debtor_id: makeUUID('my-business'),
70
+ * charge_id: makeUUID('charge', 'charge-1'),
71
+ * creditor_id: makeUUID('business', 'supplier-1'),
72
+ * debtor_id: makeUUID('business', 'my-business'),
73
73
  * type: 'INVOICE',
74
74
  * total_amount: 1000.0,
75
75
  * currency_code: 'ILS',
@@ -78,9 +78,9 @@ export interface DocumentInsertParams {
78
78
  *
79
79
  * // Receipt with VAT
80
80
  * const receipt = createDocument({
81
- * charge_id: makeUUID('charge-2'),
82
- * creditor_id: makeUUID('customer-1'),
83
- * debtor_id: makeUUID('my-business'),
81
+ * charge_id: makeUUID('charge', 'charge-2'),
82
+ * creditor_id: makeUUID('business', 'customer-1'),
83
+ * debtor_id: makeUUID('business', 'my-business'),
84
84
  * type: 'RECEIPT',
85
85
  * total_amount: 500.0,
86
86
  * currency_code: 'USD',
@@ -93,9 +93,9 @@ export interface DocumentInsertParams {
93
93
  * // Invoice with full metadata
94
94
  * const detailedInvoice = createDocument(
95
95
  * {
96
- * charge_id: makeUUID('charge-3'),
97
- * creditor_id: makeUUID('supplier-2'),
98
- * debtor_id: makeUUID('my-business'),
96
+ * charge_id: makeUUID('charge', 'charge-3'),
97
+ * creditor_id: makeUUID('business', 'supplier-2'),
98
+ * debtor_id: makeUUID('business', 'my-business'),
99
99
  * type: 'INVOICE',
100
100
  * total_amount: 2500.0,
101
101
  * currency_code: 'EUR',
@@ -123,7 +123,7 @@ export function createDocument(
123
123
  overrides?: Partial<DocumentInsertParams>,
124
124
  ): DocumentInsertParams {
125
125
  return {
126
- id: makeUUID(),
126
+ id: makeUUIDLegacy(),
127
127
  image_url: null,
128
128
  file_url: null,
129
129
  type: params.type,
@@ -3,7 +3,7 @@ import {
3
3
  createFinancialAccount,
4
4
  FINANCIAL_ACCOUNT_TYPES,
5
5
  } from './financial-account.js';
6
- import { makeUUID } from './ids.js';
6
+ import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.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-owner');
50
+ const ownerId = makeUUID('business', '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');
99
+ const ownerId = makeUUID('business', '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');
116
+ const ownerId = makeUUID('business', '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');
130
+ const ownerId = makeUUID('business', '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');
144
+ const ownerId = makeUUID('business', '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');
157
+ const ownerId = makeUUID('business', '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 { makeUUID } from './ids.js';
5
+ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.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: makeUUID().slice(0, 13), // Default: unique short string
62
+ accountNumber: makeUUIDLegacy().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
+ }
@@ -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('supplier-local');
39
+ const supplierId = makeUUID('business', 'supplier-local');
40
40
  const supplier = createBusiness({
41
41
  id: supplierId,
42
42
  hebrewName: 'ספק מקומי',
43
43
  });
44
44
 
45
- const taxCategoryId = makeUUID('tax-expense');
45
+ const taxCategoryId = makeUUID('tax-category', 'tax-expense');
46
46
  const taxCategory = createTaxCategory({
47
47
  id: taxCategoryId,
48
48
  });
49
49
 
50
- const accountId = makeUUID('bank-account');
50
+ const accountId = makeUUID('financial-account', '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('expense-charge');
58
+ const chargeId = makeUUID('charge', '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('biz-1') });
110
- const business2 = createBusiness({ id: makeUUID('biz-1') });
109
+ const business1 = createBusiness({ id: makeUUID('business', 'biz-1') });
110
+ const business2 = createBusiness({ id: makeUUID('business', '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(`owner-${index}`),
121
+ ownerId: makeUUID('business', `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-1'),
132
- business_id: makeUUID('business-1'),
131
+ charge_id: makeUUID('charge', 'charge-1'),
132
+ business_id: makeUUID('business', '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-doc');
144
- const creditorId = makeUUID('creditor');
145
- const debtorId = makeUUID('debtor');
143
+ const chargeId = makeUUID('charge', 'charge-doc');
144
+ const creditorId = makeUUID('business', 'creditor');
145
+ const debtorId = makeUUID('business', '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('supplier-1');
21
+ * const businessId = makeUUID('business', '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 './ids.js';
54
+ export { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.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 './ids.js';
3
+ import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.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-cat-expense');
30
+ const customId = makeUUID('tax-category', '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('default-category') });
88
- const category2 = createTaxCategory({ id: makeUUID('default-category') });
87
+ const category1 = createTaxCategory({ id: makeUUID('tax-category', 'default-category') });
88
+ const category2 = createTaxCategory({ id: makeUUID('tax-category', '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 { makeUUID } from './ids.js';
2
+ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
3
3
 
4
4
  /**
5
5
  * Tax category factory for test fixtures
@@ -17,17 +17,17 @@ import { makeUUID } from './ids.js';
17
17
  * @example
18
18
  * ```typescript
19
19
  * // Minimal tax category
20
- * const category = createTaxCategory({ id: makeUUID('expense-general') });
20
+ * const category = createTaxCategory({ id: makeUUID('tax-category', 'expense-general') });
21
21
  *
22
22
  * // Tax category with Hashavshevet integration
23
23
  * const integrated = createTaxCategory({
24
- * id: makeUUID('expense-office'),
24
+ * id: makeUUID('tax-category', 'expense-office'),
25
25
  * hashavshevetName: 'משרדיות',
26
26
  * });
27
27
  *
28
28
  * // Tax-excluded category
29
29
  * const excluded = createTaxCategory({
30
- * id: makeUUID('income-exempt'),
30
+ * id: makeUUID('tax-category', 'income-exempt'),
31
31
  * taxExcluded: true,
32
32
  * });
33
33
  * ```
@@ -35,10 +35,11 @@ import { makeUUID } from './ids.js';
35
35
  export function createTaxCategory(
36
36
  overrides?: Partial<IInsertTaxCategoryParams>,
37
37
  ): IInsertTaxCategoryParams {
38
+ const defaultId = makeUUIDLegacy();
38
39
  return {
39
- id: makeUUID(),
40
+ id: defaultId,
40
41
  hashavshevetName: null,
41
42
  taxExcluded: false,
42
43
  ...overrides,
43
44
  };
44
- }
45
+ }
@@ -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 './ids.js';
4
+ import { makeUUID } from '../../demo-fixtures/helpers/deterministic-uuid.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-1');
10
- const businessId = makeUUID('business-1');
9
+ const chargeId = makeUUID('charge', 'charge-1');
10
+ const businessId = makeUUID('business', '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-1');
44
- const businessId = makeUUID('business-1');
43
+ const chargeId = makeUUID('charge', 'charge-1');
44
+ const businessId = makeUUID('business', '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-1');
67
- const businessId = makeUUID('business-1');
66
+ const chargeId = makeUUID('charge', 'charge-1');
67
+ const businessId = makeUUID('business', '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-1');
82
- const businessId = makeUUID('business-1');
81
+ const chargeId = makeUUID('charge', 'charge-1');
82
+ const businessId = makeUUID('business', '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-1');
98
- const businessId = makeUUID('bank');
97
+ const chargeId = makeUUID('charge', 'charge-1');
98
+ const businessId = makeUUID('business', '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-1');
114
- const businessId = makeUUID('business-1');
115
- const customId = makeUUID('custom-tx');
116
- const accountId = makeUUID('eur-account');
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');
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-1');
144
- const businessId = makeUUID('business-1');
143
+ const chargeId = makeUUID('charge', 'charge-1');
144
+ const businessId = makeUUID('business', '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-1');
166
- const businessId = makeUUID('business-1');
165
+ const chargeId = makeUUID('charge', 'charge-1');
166
+ const businessId = makeUUID('business', '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-1');
193
- const businessId = makeUUID('business-1');
192
+ const chargeId = makeUUID('charge', 'charge-1');
193
+ const businessId = makeUUID('business', '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-1');
226
- const businessId = makeUUID('supplier');
225
+ const chargeId = makeUUID('charge', 'charge-1');
226
+ const businessId = makeUUID('business', '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-1');
241
- const businessId = makeUUID('customer');
240
+ const chargeId = makeUUID('charge', 'charge-1');
241
+ const businessId = makeUUID('business', '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-1');
256
- const businessId = makeUUID('business-1');
255
+ const chargeId = makeUUID('charge', 'charge-1');
256
+ const businessId = makeUUID('business', '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 } from './ids.js';
13
+ import { makeUUID, makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.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-1'),
65
- * business_id: makeUUID('supplier-1'),
64
+ * charge_id: makeUUID('charge', 'charge-1'),
65
+ * business_id: makeUUID('business', '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-1'),
74
- * business_id: makeUUID('bank'),
73
+ * charge_id: makeUUID('charge', 'charge-1'),
74
+ * business_id: makeUUID('business', '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-1'),
85
- * business_id: makeUUID('supplier-1'),
84
+ * charge_id: makeUUID('charge', 'charge-1'),
85
+ * business_id: makeUUID('business', '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('eur-account'),
91
+ * account_id: makeUUID('account', '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: makeUUID(),
112
- account_id: makeUUID('default-account'),
111
+ id: makeUUIDLegacy(),
112
+ account_id: makeUUID('account', 'default-account'),
113
113
  charge_id: params.charge_id,
114
- source_id: makeUUID('source-raw-tx'),
114
+ source_id: makeUUID('transaction-source', 'source-raw-tx'),
115
115
  source_description: null,
116
116
  currency: params.currency,
117
117
  event_date:
@@ -23,7 +23,7 @@ import {
23
23
  createTaxCategory,
24
24
  createFinancialAccount,
25
25
  } from '../../factories';
26
- import { makeUUID } from '../../factories/ids';
26
+ import { makeUUID } from '../../../demo-fixtures/helpers/deterministic-uuid.js';
27
27
  import type { Fixture } from '../../helpers/fixture-types';
28
28
  import { CountryCode } from '../../../modules/countries/types.js';
29
29
  import { Currency } from '../../../shared/enums.js';
@@ -55,13 +55,13 @@ export const expenseScenarioA: Fixture = {
55
55
  businesses: [
56
56
  // Admin business (owner of the expense)
57
57
  createBusiness({
58
- id: makeUUID('admin-business'),
58
+ id: makeUUID('business', 'admin-business-scenario-a'),
59
59
  hebrewName: 'חשבונאות ניהול',
60
60
  country: CountryCode.Israel,
61
61
  }),
62
62
  // Supplier business
63
63
  createBusiness({
64
- id: makeUUID('supplier-local-ltd'),
64
+ id: makeUUID('business', 'supplier-local-ltd'),
65
65
  hebrewName: 'ספק מקומי בע"מ',
66
66
  country: CountryCode.Israel,
67
67
  exemptDealer: false,
@@ -73,11 +73,11 @@ export const expenseScenarioA: Fixture = {
73
73
  taxCategories: {
74
74
  taxCategories: [
75
75
  createTaxCategory({
76
- id: makeUUID('expense-general'),
76
+ id: makeUUID('tax-category', 'expense-general'),
77
77
  hashavshevetName: 'General Expenses',
78
78
  }),
79
79
  createTaxCategory({
80
- id: makeUUID('bank-account-tax-category'),
80
+ id: makeUUID('tax-category', 'bank-account-tax-category'),
81
81
  hashavshevetName: 'Bank Account',
82
82
  }),
83
83
  ],
@@ -88,7 +88,7 @@ export const expenseScenarioA: Fixture = {
88
88
  createFinancialAccount({
89
89
  accountNumber: 'BANK-ACCOUNT-001',
90
90
  type: 'BANK_ACCOUNT',
91
- ownerId: makeUUID('admin-business'),
91
+ ownerId: makeUUID('business', 'admin-business-scenario-a'),
92
92
  }),
93
93
  ],
94
94
  },
@@ -98,7 +98,7 @@ export const expenseScenarioA: Fixture = {
98
98
  {
99
99
  accountNumber: 'BANK-ACCOUNT-001',
100
100
  currency: Currency.Ils,
101
- taxCategoryId: makeUUID('bank-account-tax-category'),
101
+ taxCategoryId: makeUUID('tax-category', 'bank-account-tax-category'),
102
102
  },
103
103
  ],
104
104
  },
@@ -107,12 +107,12 @@ export const expenseScenarioA: Fixture = {
107
107
  charges: [
108
108
  createCharge(
109
109
  {
110
- owner_id: makeUUID('admin-business'),
111
- tax_category_id: makeUUID('expense-general'),
110
+ owner_id: makeUUID('business', 'admin-business-scenario-a'),
111
+ tax_category_id: makeUUID('tax-category', 'expense-general'),
112
112
  user_description: 'Office supplies purchase',
113
113
  },
114
114
  {
115
- id: makeUUID('charge-office-supplies'),
115
+ id: makeUUID('charge', 'charge-office-supplies'),
116
116
  },
117
117
  ),
118
118
  ],
@@ -122,15 +122,15 @@ export const expenseScenarioA: Fixture = {
122
122
  transactions: [
123
123
  createTransaction(
124
124
  {
125
- charge_id: makeUUID('charge-office-supplies'),
126
- business_id: makeUUID('supplier-local-ltd'),
125
+ charge_id: makeUUID('charge', 'charge-office-supplies'),
126
+ business_id: makeUUID('business', 'supplier-local-ltd'),
127
127
  amount: '-500.00', // Negative = expense/outflow
128
128
  currency: Currency.Ils,
129
129
  event_date: '2024-01-15',
130
130
  is_fee: false,
131
131
  },
132
132
  {
133
- id: makeUUID('transaction-supplies-payment'),
133
+ id: makeUUID('transaction', 'transaction-supplies-payment'),
134
134
  account_id: 'BANK-ACCOUNT-001', // Will be resolved to UUID by loader
135
135
  source_description: 'Office supplies - Local Supplier Ltd',
136
136
  debit_date: '2024-01-15',
@@ -144,16 +144,16 @@ export const expenseScenarioA: Fixture = {
144
144
  documents: [
145
145
  createDocument(
146
146
  {
147
- charge_id: makeUUID('charge-office-supplies'),
148
- creditor_id: makeUUID('supplier-local-ltd'), // Supplier is creditor
149
- debtor_id: makeUUID('admin-business'), // Admin is debtor (owes money)
147
+ charge_id: makeUUID('charge', 'charge-office-supplies'),
148
+ creditor_id: makeUUID('business', 'supplier-local-ltd'), // Supplier is creditor
149
+ debtor_id: makeUUID('business', 'admin-business-scenario-a'), // Admin is debtor (owes money)
150
150
  type: 'RECEIPT',
151
151
  total_amount: 500.0, // Matches transaction amount (positive in document)
152
152
  currency_code: Currency.Ils,
153
153
  date: '2024-01-15', // Receipt date matches transaction
154
154
  },
155
155
  {
156
- id: makeUUID('document-supplies-receipt'),
156
+ id: makeUUID('document', 'document-supplies-receipt'),
157
157
  serial_number: 'RCP-2024-001',
158
158
  vat_amount: null, // For simplicity, no VAT breakdown on receipt
159
159
  },
@@ -164,10 +164,10 @@ export const expenseScenarioA: Fixture = {
164
164
  expectations: {
165
165
  ledger: [
166
166
  {
167
- chargeId: makeUUID('charge-office-supplies'),
167
+ chargeId: makeUUID('charge', 'charge-office-supplies'),
168
168
  recordCount: 2, // Debit expense + credit bank
169
- debitEntities: [makeUUID('expense-general')],
170
- creditEntities: [makeUUID('bank-account-tax-category')],
169
+ debitEntities: [makeUUID('tax-category', 'expense-general')],
170
+ creditEntities: [makeUUID('tax-category', 'bank-account-tax-category')],
171
171
  totalDebitLocal: 500.0,
172
172
  totalCreditLocal: 500.0,
173
173
  balanced: true,