@accounter/server 0.0.9-alpha-20251210183522-3f6d1965667d05308b9ebddd784f4937b36d594c → 0.0.9-alpha-20251210203829-57f49a64dd7ec3eb26b1ebac959531c02728c50b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -22
- package/dist/server/src/__tests__/factories/business.d.ts +4 -5
- package/dist/server/src/__tests__/factories/business.js +2 -6
- package/dist/server/src/__tests__/factories/business.js.map +1 -1
- package/dist/server/src/__tests__/factories/business.test.js +4 -4
- package/dist/server/src/__tests__/factories/business.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/financial-account.d.ts +3 -3
- package/dist/server/src/__tests__/factories/financial-account.js +1 -1
- package/dist/server/src/__tests__/factories/financial-account.js.map +1 -1
- package/dist/server/src/__tests__/factories/index.test.js +7 -7
- package/dist/server/src/__tests__/factories/index.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/tax-category.d.ts +2 -3
- package/dist/server/src/__tests__/factories/tax-category.js +0 -4
- package/dist/server/src/__tests__/factories/tax-category.js.map +1 -1
- package/dist/server/src/__tests__/factories/tax-category.test.js +6 -6
- package/dist/server/src/__tests__/factories/tax-category.test.js.map +1 -1
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js +4 -4
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js.map +1 -1
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js +4 -4
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-loader.js +1 -2
- package/dist/server/src/__tests__/helpers/fixture-loader.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-loader.test.js +19 -19
- package/dist/server/src/__tests__/helpers/fixture-loader.test.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-types.d.ts +12 -41
- package/dist/server/src/__tests__/helpers/fixture-types.js +0 -4
- package/dist/server/src/__tests__/helpers/fixture-types.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-validation.test.js +18 -18
- package/dist/server/src/__tests__/helpers/fixture-validation.test.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/factories/business.test.ts +4 -4
- package/src/__tests__/factories/business.ts +5 -9
- package/src/__tests__/factories/financial-account.ts +5 -5
- package/src/__tests__/factories/index.test.ts +7 -7
- package/src/__tests__/factories/tax-category.test.ts +6 -6
- package/src/__tests__/factories/tax-category.ts +4 -8
- package/src/__tests__/fixtures/expenses/expense-scenario-a.ts +4 -4
- package/src/__tests__/fixtures/expenses/expense-scenario-b.ts +4 -4
- package/src/__tests__/helpers/fixture-loader.test.ts +19 -19
- package/src/__tests__/helpers/fixture-loader.ts +1 -2
- package/src/__tests__/helpers/fixture-types.ts +12 -40
- package/src/__tests__/helpers/fixture-validation.test.ts +18 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
financial_account_type,
|
|
3
|
+
IInsertFinancialAccountsParams,
|
|
3
4
|
} from '../../modules/financial-accounts/__generated__/financial-accounts.types.js';
|
|
4
5
|
import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
|
|
5
|
-
import { FixtureAccounts } from '__tests__/helpers/fixture-types.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Valid financial account types
|
|
@@ -21,7 +21,7 @@ export const FINANCIAL_ACCOUNT_TYPES = [
|
|
|
21
21
|
* Creates a minimal financial account object ready for insertion via pgtyped.
|
|
22
22
|
*
|
|
23
23
|
* @param overrides - Optional overrides for any financial account field
|
|
24
|
-
* @returns Financial account object matching
|
|
24
|
+
* @returns Financial account object matching IInsertFinancialAccountsParams.bankAccounts[0] shape
|
|
25
25
|
*
|
|
26
26
|
* @remarks
|
|
27
27
|
* - accountNumber defaults to unique numeric string if not provided
|
|
@@ -56,8 +56,8 @@ export const FINANCIAL_ACCOUNT_TYPES = [
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
export function createFinancialAccount(
|
|
59
|
-
overrides?: Partial<
|
|
60
|
-
):
|
|
59
|
+
overrides?: Partial<IInsertFinancialAccountsParams['bankAccounts'][number]>,
|
|
60
|
+
): IInsertFinancialAccountsParams['bankAccounts'][number] {
|
|
61
61
|
return {
|
|
62
62
|
accountNumber: makeUUIDLegacy().slice(0, 13), // Default: unique short string
|
|
63
63
|
name: null,
|
|
@@ -66,4 +66,4 @@ export function createFinancialAccount(
|
|
|
66
66
|
type: 'BANK_ACCOUNT',
|
|
67
67
|
...overrides,
|
|
68
68
|
};
|
|
69
|
-
}
|
|
69
|
+
}
|
|
@@ -39,7 +39,7 @@ describe('Factory Integration', () => {
|
|
|
39
39
|
const supplierId = makeUUID('business', 'supplier-local');
|
|
40
40
|
const supplier = createBusiness({
|
|
41
41
|
id: supplierId,
|
|
42
|
-
|
|
42
|
+
hebrewName: 'ספק מקומי',
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
const taxCategoryId = makeUUID('tax-category', 'tax-expense');
|
|
@@ -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('business', 'biz-1') });
|
|
110
|
+
const business2 = createBusiness({ id: makeUUID('business', 'biz-1') });
|
|
111
111
|
|
|
112
112
|
expect(business1.id).toBe(business2.id);
|
|
113
113
|
});
|
|
@@ -171,21 +171,21 @@ describe('Factory Integration', () => {
|
|
|
171
171
|
|
|
172
172
|
it('should support partial overrides across all factories', () => {
|
|
173
173
|
const business = createBusiness({
|
|
174
|
-
|
|
174
|
+
hebrewName: 'עסק',
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
const taxCategory = createTaxCategory({
|
|
178
|
-
|
|
178
|
+
hashavshevetName: 'Category 1',
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
const account = createFinancialAccount({
|
|
182
182
|
accountNumber: '123456',
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
expect(business.
|
|
185
|
+
expect(business.hebrewName).toBe('עסק');
|
|
186
186
|
expect(business.id).toBeDefined();
|
|
187
187
|
|
|
188
|
-
expect(taxCategory.
|
|
188
|
+
expect(taxCategory.hashavshevetName).toBe('Category 1');
|
|
189
189
|
expect(taxCategory.id).toBeDefined();
|
|
190
190
|
|
|
191
191
|
expect(account.accountNumber).toBe('123456');
|
|
@@ -30,21 +30,21 @@ describe('Factory: Tax Category', () => {
|
|
|
30
30
|
const customId = makeUUID('tax-category', 'tax-cat-expense');
|
|
31
31
|
const category = createTaxCategory({
|
|
32
32
|
id: customId,
|
|
33
|
-
|
|
33
|
+
hashavshevetName: 'משרדיות',
|
|
34
34
|
taxExcluded: true,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
expect(category.id).toBe(customId);
|
|
38
|
-
expect(category.
|
|
38
|
+
expect(category.hashavshevetName).toBe('משרדיות');
|
|
39
39
|
expect(category.taxExcluded).toBe(true);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it('should allow partial overrides', () => {
|
|
43
43
|
const category = createTaxCategory({
|
|
44
|
-
|
|
44
|
+
hashavshevetName: 'שכר',
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
expect(category.
|
|
47
|
+
expect(category.hashavshevetName).toBe('שכר');
|
|
48
48
|
expect(category.id).toBeDefined();
|
|
49
49
|
expect(category.taxExcluded).toBe(false);
|
|
50
50
|
});
|
|
@@ -69,10 +69,10 @@ describe('Factory: Tax Category', () => {
|
|
|
69
69
|
|
|
70
70
|
it('should handle Hashavshevet integration name', () => {
|
|
71
71
|
const category = createTaxCategory({
|
|
72
|
-
|
|
72
|
+
hashavshevetName: 'הוצאות משרד',
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
expect(category.
|
|
75
|
+
expect(category.hashavshevetName).toBe('הוצאות משרד');
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it('should allow explicit null overrides', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { IInsertTaxCategoryParams } from '../../modules/financial-entities/__generated__/tax-categories.types.js';
|
|
1
2
|
import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.js';
|
|
2
|
-
import { FixtureTaxCategories } from '__tests__/helpers/fixture-types.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Tax category factory for test fixtures
|
|
@@ -11,7 +11,6 @@ import { FixtureTaxCategories } from '__tests__/helpers/fixture-types.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
13
|
* - id defaults to deterministic UUID if not provided
|
|
14
|
-
* - name defaults to overrides.id ?? defaultId (intelligent fallback for display)
|
|
15
14
|
* - hashavshevetName defaults to null (not integrated with Hashavshevet)
|
|
16
15
|
* - taxExcluded defaults to false (most categories include tax)
|
|
17
16
|
*
|
|
@@ -34,16 +33,13 @@ import { FixtureTaxCategories } from '__tests__/helpers/fixture-types.js';
|
|
|
34
33
|
* ```
|
|
35
34
|
*/
|
|
36
35
|
export function createTaxCategory(
|
|
37
|
-
overrides?: Partial<
|
|
38
|
-
):
|
|
36
|
+
overrides?: Partial<IInsertTaxCategoryParams>,
|
|
37
|
+
): IInsertTaxCategoryParams {
|
|
39
38
|
const defaultId = makeUUIDLegacy();
|
|
40
39
|
return {
|
|
41
40
|
id: defaultId,
|
|
42
|
-
// Intelligent name defaulting: use provided id, or use generated UUID
|
|
43
|
-
// This ensures display name is always meaningful even when only id is specified
|
|
44
|
-
name: overrides?.id ?? defaultId,
|
|
45
41
|
hashavshevetName: null,
|
|
46
42
|
taxExcluded: false,
|
|
47
43
|
...overrides,
|
|
48
44
|
};
|
|
49
|
-
}
|
|
45
|
+
}
|
|
@@ -56,13 +56,13 @@ export const expenseScenarioA: Fixture = {
|
|
|
56
56
|
// Admin business (owner of the expense)
|
|
57
57
|
createBusiness({
|
|
58
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
64
|
id: makeUUID('business', 'supplier-local-ltd'),
|
|
65
|
-
|
|
65
|
+
hebrewName: 'ספק מקומי בע"מ',
|
|
66
66
|
country: CountryCode.Israel,
|
|
67
67
|
exemptDealer: false,
|
|
68
68
|
isReceiptEnough: true, // Can provide receipts for small purchases
|
|
@@ -74,11 +74,11 @@ export const expenseScenarioA: Fixture = {
|
|
|
74
74
|
taxCategories: [
|
|
75
75
|
createTaxCategory({
|
|
76
76
|
id: makeUUID('tax-category', 'expense-general'),
|
|
77
|
-
|
|
77
|
+
hashavshevetName: 'General Expenses',
|
|
78
78
|
}),
|
|
79
79
|
createTaxCategory({
|
|
80
80
|
id: makeUUID('tax-category', 'bank-account-tax-category'),
|
|
81
|
-
|
|
81
|
+
hashavshevetName: 'Bank Account',
|
|
82
82
|
}),
|
|
83
83
|
],
|
|
84
84
|
},
|
|
@@ -68,13 +68,13 @@ export const expenseScenarioB: Fixture = {
|
|
|
68
68
|
// Admin business (owner of the expense)
|
|
69
69
|
createBusiness({
|
|
70
70
|
id: makeUUID('business', 'admin-business-usd'),
|
|
71
|
-
|
|
71
|
+
hebrewName: 'חשבונאות ניהול',
|
|
72
72
|
country: CountryCode.Israel,
|
|
73
73
|
}),
|
|
74
74
|
// US Supplier business
|
|
75
75
|
createBusiness({
|
|
76
76
|
id: makeUUID('business', 'supplier-us-vendor-llc'),
|
|
77
|
-
|
|
77
|
+
hebrewName: 'ספק אמריקאי',
|
|
78
78
|
country: CountryCode['United States of America (the)'],
|
|
79
79
|
exemptDealer: false,
|
|
80
80
|
isReceiptEnough: false, // Requires invoice for foreign transactions
|
|
@@ -86,11 +86,11 @@ export const expenseScenarioB: Fixture = {
|
|
|
86
86
|
taxCategories: [
|
|
87
87
|
createTaxCategory({
|
|
88
88
|
id: makeUUID('tax-category', 'expense-consulting'),
|
|
89
|
-
|
|
89
|
+
hashavshevetName: 'Consulting Expenses',
|
|
90
90
|
}),
|
|
91
91
|
createTaxCategory({
|
|
92
92
|
id: makeUUID('tax-category', 'usd-account-tax-category'),
|
|
93
|
-
|
|
93
|
+
hashavshevetName: 'Foreign Currency Account',
|
|
94
94
|
}),
|
|
95
95
|
],
|
|
96
96
|
},
|
|
@@ -44,7 +44,7 @@ describe('Fixture Loader', () => {
|
|
|
44
44
|
businesses: [
|
|
45
45
|
createBusiness({
|
|
46
46
|
id: businessId,
|
|
47
|
-
|
|
47
|
+
hebrewName: 'Test Business',
|
|
48
48
|
}),
|
|
49
49
|
],
|
|
50
50
|
},
|
|
@@ -52,7 +52,7 @@ describe('Fixture Loader', () => {
|
|
|
52
52
|
taxCategories: [
|
|
53
53
|
createTaxCategory({
|
|
54
54
|
id: taxCategoryId,
|
|
55
|
-
|
|
55
|
+
hashavshevetName: 'Test Tax Category',
|
|
56
56
|
}),
|
|
57
57
|
],
|
|
58
58
|
},
|
|
@@ -84,7 +84,7 @@ describe('Fixture Loader', () => {
|
|
|
84
84
|
);
|
|
85
85
|
expect(businessResult.rows).toHaveLength(1);
|
|
86
86
|
expect(businessResult.rows[0].id).toBe(businessId);
|
|
87
|
-
expect(businessResult.rows[0].hebrew_name).
|
|
87
|
+
expect(businessResult.rows[0].hebrew_name).toBe('Test Business');
|
|
88
88
|
|
|
89
89
|
const taxCatResult = await client.query(
|
|
90
90
|
`SELECT * FROM ${qualifyTable('tax_categories')} WHERE id = $1`,
|
|
@@ -92,7 +92,7 @@ describe('Fixture Loader', () => {
|
|
|
92
92
|
);
|
|
93
93
|
expect(taxCatResult.rows).toHaveLength(1);
|
|
94
94
|
expect(taxCatResult.rows[0].id).toBe(taxCategoryId);
|
|
95
|
-
expect(taxCatResult.rows[0].hashavshevet_name).
|
|
95
|
+
expect(taxCatResult.rows[0].hashavshevet_name).toBe('Test Tax Category');
|
|
96
96
|
|
|
97
97
|
const chargeResult = await client.query(
|
|
98
98
|
`SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
|
|
@@ -115,12 +115,12 @@ describe('Fixture Loader', () => {
|
|
|
115
115
|
const fixture: Fixture = {
|
|
116
116
|
businesses: {
|
|
117
117
|
businesses: [
|
|
118
|
-
createBusiness({ id: supplierId,
|
|
119
|
-
createBusiness({ id: customerId,
|
|
118
|
+
createBusiness({ id: supplierId, hebrewName: 'Supplier Ltd' }),
|
|
119
|
+
createBusiness({ id: customerId, hebrewName: 'Customer Inc' }),
|
|
120
120
|
],
|
|
121
121
|
},
|
|
122
122
|
taxCategories: {
|
|
123
|
-
taxCategories: [createTaxCategory({ id: taxCategoryId
|
|
123
|
+
taxCategories: [createTaxCategory({ id: taxCategoryId })],
|
|
124
124
|
},
|
|
125
125
|
accounts: {
|
|
126
126
|
accounts: [
|
|
@@ -222,7 +222,7 @@ describe('Fixture Loader', () => {
|
|
|
222
222
|
|
|
223
223
|
const fixture: Fixture = {
|
|
224
224
|
businesses: {
|
|
225
|
-
businesses: [createBusiness({ id: businessId
|
|
225
|
+
businesses: [createBusiness({ id: businessId })],
|
|
226
226
|
},
|
|
227
227
|
// No tax categories, accounts, charges, etc.
|
|
228
228
|
};
|
|
@@ -245,7 +245,7 @@ describe('Fixture Loader', () => {
|
|
|
245
245
|
|
|
246
246
|
const fixture: Fixture = {
|
|
247
247
|
businesses: {
|
|
248
|
-
businesses: [createBusiness({ id: businessId
|
|
248
|
+
businesses: [createBusiness({ id: businessId })],
|
|
249
249
|
},
|
|
250
250
|
charges: {
|
|
251
251
|
charges: [
|
|
@@ -322,14 +322,14 @@ describe('Fixture Loader', () => {
|
|
|
322
322
|
const fixture: Fixture = {
|
|
323
323
|
businesses: {
|
|
324
324
|
businesses: [
|
|
325
|
-
createBusiness({ id: biz1,
|
|
326
|
-
createBusiness({ id: biz2,
|
|
325
|
+
createBusiness({ id: biz1, hebrewName: 'Business 1' }),
|
|
326
|
+
createBusiness({ id: biz2, hebrewName: 'Business 2' }),
|
|
327
327
|
],
|
|
328
328
|
},
|
|
329
329
|
taxCategories: {
|
|
330
330
|
taxCategories: [
|
|
331
|
-
createTaxCategory({ id: tax1,
|
|
332
|
-
createTaxCategory({ id: tax2,
|
|
331
|
+
createTaxCategory({ id: tax1, hashavshevetName: 'Tax 1' }),
|
|
332
|
+
createTaxCategory({ id: tax2, hashavshevetName: 'Tax 2' }),
|
|
333
333
|
],
|
|
334
334
|
},
|
|
335
335
|
charges: {
|
|
@@ -366,7 +366,7 @@ describe('Fixture Loader', () => {
|
|
|
366
366
|
|
|
367
367
|
const fixture: Fixture = {
|
|
368
368
|
businesses: {
|
|
369
|
-
businesses: [createBusiness({ id: businessId,
|
|
369
|
+
businesses: [createBusiness({ id: businessId, hebrewName: 'Original Name' })],
|
|
370
370
|
},
|
|
371
371
|
};
|
|
372
372
|
|
|
@@ -376,7 +376,7 @@ describe('Fixture Loader', () => {
|
|
|
376
376
|
// Insert again (should not error due to ON CONFLICT DO NOTHING)
|
|
377
377
|
const fixtureModified: Fixture = {
|
|
378
378
|
businesses: {
|
|
379
|
-
businesses: [createBusiness({ id: businessId,
|
|
379
|
+
businesses: [createBusiness({ id: businessId, hebrewName: 'Modified Name' })],
|
|
380
380
|
},
|
|
381
381
|
};
|
|
382
382
|
|
|
@@ -386,10 +386,10 @@ describe('Fixture Loader', () => {
|
|
|
386
386
|
|
|
387
387
|
// Original data should be preserved (ON CONFLICT DO NOTHING)
|
|
388
388
|
const result = await client.query(
|
|
389
|
-
`SELECT * FROM ${qualifyTable('
|
|
389
|
+
`SELECT * FROM ${qualifyTable('businesses')} WHERE id = $1`,
|
|
390
390
|
[businessId],
|
|
391
391
|
);
|
|
392
|
-
expect(result.rows[0].
|
|
392
|
+
expect(result.rows[0].hebrew_name).toBe('Original Name');
|
|
393
393
|
}));
|
|
394
394
|
|
|
395
395
|
it('should insert transactions with generated source_id', () =>
|
|
@@ -402,10 +402,10 @@ describe('Fixture Loader', () => {
|
|
|
402
402
|
|
|
403
403
|
const fixture: Fixture = {
|
|
404
404
|
businesses: {
|
|
405
|
-
businesses: [createBusiness({ id: businessId
|
|
405
|
+
businesses: [createBusiness({ id: businessId })],
|
|
406
406
|
},
|
|
407
407
|
taxCategories: {
|
|
408
|
-
taxCategories: [createTaxCategory({ id: taxCatId
|
|
408
|
+
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
409
409
|
},
|
|
410
410
|
accounts: {
|
|
411
411
|
accounts: [
|
|
@@ -148,13 +148,12 @@ export async function insertFixture(
|
|
|
148
148
|
await executeSavepointSection('businesses', async () => {
|
|
149
149
|
for (const business of fixture.businesses!.businesses) {
|
|
150
150
|
// Insert financial entity first (type='business')
|
|
151
|
-
// Field mapping: business.name used for display (required); hebrewName is legacy/optional
|
|
152
151
|
const entityResult = await client.query(
|
|
153
152
|
`INSERT INTO ${qualifyTable('financial_entities')} (id, name, type)
|
|
154
153
|
VALUES ($1, $2, 'business')
|
|
155
154
|
ON CONFLICT (id) DO NOTHING
|
|
156
155
|
RETURNING id`,
|
|
157
|
-
[business.id, business.
|
|
156
|
+
[business.id, business.hebrewName || business.id],
|
|
158
157
|
);
|
|
159
158
|
|
|
160
159
|
// Insert business details - note: vat_number column maps to governmentId field
|
|
@@ -5,18 +5,16 @@
|
|
|
5
5
|
* database state for integration tests. Each fixture represents a complete
|
|
6
6
|
* scenario with all related entities (businesses, charges, transactions, documents, etc.).
|
|
7
7
|
*
|
|
8
|
-
* **Type Independence**: These types are decoupled from pgtyped-generated database types
|
|
9
|
-
* to maintain test independence and flexibility. Fixtures define their own minimal interfaces
|
|
10
|
-
* that are converted to database-specific structures by the fixture-loader.
|
|
11
|
-
*
|
|
12
8
|
* @see packages/server/src/__tests__/helpers/fixture-validation.ts for validation logic
|
|
13
9
|
* @see packages/server/src/__tests__/helpers/fixture-loader.ts for insertion logic
|
|
14
10
|
*/
|
|
15
11
|
|
|
12
|
+
import type { IInsertBusinessesParams } from '../../modules/financial-entities/__generated__/businesses.types.js';
|
|
13
|
+
import type { IInsertTaxCategoryParams } from '../../modules/financial-entities/__generated__/tax-categories.types.js';
|
|
14
|
+
import type { IInsertFinancialAccountsParams } from '../../modules/financial-accounts/__generated__/financial-accounts.types.js';
|
|
16
15
|
import type { ChargeInsertParams } from '../factories/charge.js';
|
|
17
16
|
import type { TransactionInsertParams } from '../factories/transaction.js';
|
|
18
17
|
import type { DocumentInsertParams } from '../factories/document.js';
|
|
19
|
-
import type { financial_account_type } from '../../modules/transactions/types.js';
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* Business entities in a fixture
|
|
@@ -31,23 +29,7 @@ export interface FixtureBusinesses {
|
|
|
31
29
|
* Each business must have a unique id. The id will be referenced by
|
|
32
30
|
* charges (owner_id), transactions (business_id), and documents (creditor_id/debtor_id).
|
|
33
31
|
*/
|
|
34
|
-
businesses:
|
|
35
|
-
id: string,
|
|
36
|
-
name: string,
|
|
37
|
-
hebrewName?: string | null,
|
|
38
|
-
address?: string | null,
|
|
39
|
-
email?: string | null,
|
|
40
|
-
website?: string | null,
|
|
41
|
-
phoneNumber?: string | null,
|
|
42
|
-
governmentId?: string | null,
|
|
43
|
-
exemptDealer?: boolean | null,
|
|
44
|
-
suggestions?: object | null,
|
|
45
|
-
optionalVat?: boolean | null,
|
|
46
|
-
country?: string | null,
|
|
47
|
-
pcn874RecordTypeOverride?: unknown | null,
|
|
48
|
-
isReceiptEnough?: boolean | null,
|
|
49
|
-
isDocumentsOptional?: boolean | null;
|
|
50
|
-
}>;
|
|
32
|
+
businesses: IInsertBusinessesParams['businesses'];
|
|
51
33
|
}
|
|
52
34
|
|
|
53
35
|
/**
|
|
@@ -62,12 +44,7 @@ export interface FixtureTaxCategories {
|
|
|
62
44
|
* Each tax category must have a unique id. The id will be referenced by
|
|
63
45
|
* charges (tax_category_id) and financial accounts.
|
|
64
46
|
*/
|
|
65
|
-
taxCategories:
|
|
66
|
-
id: string;
|
|
67
|
-
name: string;
|
|
68
|
-
hashavshevetName?: string | null;
|
|
69
|
-
taxExcluded?: boolean | null;
|
|
70
|
-
}>;
|
|
47
|
+
taxCategories: IInsertTaxCategoryParams[];
|
|
71
48
|
}
|
|
72
49
|
|
|
73
50
|
/**
|
|
@@ -83,12 +60,7 @@ export interface FixtureAccounts {
|
|
|
83
60
|
* Each account must have a unique id. The id will be referenced by
|
|
84
61
|
* transactions (account_id).
|
|
85
62
|
*/
|
|
86
|
-
accounts:
|
|
87
|
-
accountNumber?: string | null,
|
|
88
|
-
name?: string | null,
|
|
89
|
-
privateBusiness?: string | null,
|
|
90
|
-
ownerId?: string | null,
|
|
91
|
-
type?: financial_account_type | null}>;
|
|
63
|
+
accounts: IInsertFinancialAccountsParams['bankAccounts'];
|
|
92
64
|
}
|
|
93
65
|
|
|
94
66
|
/**
|
|
@@ -245,7 +217,7 @@ export interface LedgerExpectation {
|
|
|
245
217
|
* const expenseScenarioA: Fixture = {
|
|
246
218
|
* businesses: {
|
|
247
219
|
* businesses: [
|
|
248
|
-
* createBusiness({ id: makeUUID('
|
|
220
|
+
* createBusiness({ id: makeUUID('supplier-1'), hebrewName: 'Local Supplier Ltd' }),
|
|
249
221
|
* ],
|
|
250
222
|
* },
|
|
251
223
|
* charges: {
|
|
@@ -256,8 +228,8 @@ export interface LedgerExpectation {
|
|
|
256
228
|
* transactions: {
|
|
257
229
|
* transactions: [
|
|
258
230
|
* createTransaction({
|
|
259
|
-
* charge_id: makeUUID('charge
|
|
260
|
-
* business_id: makeUUID('
|
|
231
|
+
* charge_id: makeUUID('charge-1'),
|
|
232
|
+
* business_id: makeUUID('supplier-1'),
|
|
261
233
|
* amount: '-1000.00',
|
|
262
234
|
* currency: 'ILS',
|
|
263
235
|
* event_date: '2024-01-15',
|
|
@@ -267,8 +239,8 @@ export interface LedgerExpectation {
|
|
|
267
239
|
* documents: {
|
|
268
240
|
* documents: [
|
|
269
241
|
* createDocument({
|
|
270
|
-
* charge_id: makeUUID('charge
|
|
271
|
-
* creditor_id: makeUUID('
|
|
242
|
+
* charge_id: makeUUID('charge-1'),
|
|
243
|
+
* creditor_id: makeUUID('supplier-1'),
|
|
272
244
|
* debtor_id: ADMIN_ID,
|
|
273
245
|
* type: 'RECEIPT',
|
|
274
246
|
* total_amount: 1000.0,
|
|
@@ -280,7 +252,7 @@ export interface LedgerExpectation {
|
|
|
280
252
|
* expectations: {
|
|
281
253
|
* ledger: [
|
|
282
254
|
* {
|
|
283
|
-
* chargeId: makeUUID('charge
|
|
255
|
+
* chargeId: makeUUID('charge-1'),
|
|
284
256
|
* recordCount: 2,
|
|
285
257
|
* debitEntities: [EXPENSE_TAX_CATEGORY_ID],
|
|
286
258
|
* creditEntities: [BANK_TAX_CATEGORY_ID],
|
|
@@ -21,12 +21,12 @@ describe('Fixture Validation', () => {
|
|
|
21
21
|
const fixture: Fixture = {
|
|
22
22
|
businesses: {
|
|
23
23
|
businesses: [
|
|
24
|
-
createBusiness({ id: adminId
|
|
25
|
-
createBusiness({ id: supplierId
|
|
24
|
+
createBusiness({ id: adminId }),
|
|
25
|
+
createBusiness({ id: supplierId }),
|
|
26
26
|
],
|
|
27
27
|
},
|
|
28
28
|
taxCategories: {
|
|
29
|
-
taxCategories: [createTaxCategory({ id: taxCatId
|
|
29
|
+
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
30
30
|
},
|
|
31
31
|
accounts: {
|
|
32
32
|
accounts: [createFinancialAccount({ accountNumber: accountId, ownerId: adminId })],
|
|
@@ -73,10 +73,10 @@ describe('Fixture Validation', () => {
|
|
|
73
73
|
|
|
74
74
|
const fixture: Fixture = {
|
|
75
75
|
businesses: {
|
|
76
|
-
businesses: [createBusiness({ id: adminId
|
|
76
|
+
businesses: [createBusiness({ id: adminId })],
|
|
77
77
|
},
|
|
78
78
|
taxCategories: {
|
|
79
|
-
taxCategories: [createTaxCategory({ id: taxCatId
|
|
79
|
+
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
80
80
|
},
|
|
81
81
|
charges: {
|
|
82
82
|
charges: [
|
|
@@ -96,7 +96,7 @@ describe('Fixture Validation', () => {
|
|
|
96
96
|
|
|
97
97
|
const fixture: Fixture = {
|
|
98
98
|
businesses: {
|
|
99
|
-
businesses: [createBusiness({ id: adminId
|
|
99
|
+
businesses: [createBusiness({ id: adminId }), createBusiness({ id: supplierId })],
|
|
100
100
|
},
|
|
101
101
|
transactions: {
|
|
102
102
|
transactions: [
|
|
@@ -127,7 +127,7 @@ describe('Fixture Validation', () => {
|
|
|
127
127
|
|
|
128
128
|
const fixture: Fixture = {
|
|
129
129
|
businesses: {
|
|
130
|
-
businesses: [createBusiness({ id: adminId
|
|
130
|
+
businesses: [createBusiness({ id: adminId }), createBusiness({ id: supplierId })],
|
|
131
131
|
},
|
|
132
132
|
documents: {
|
|
133
133
|
documents: [
|
|
@@ -181,7 +181,7 @@ describe('Fixture Validation', () => {
|
|
|
181
181
|
|
|
182
182
|
const fixture: Fixture = {
|
|
183
183
|
businesses: {
|
|
184
|
-
businesses: [createBusiness({ id: adminId
|
|
184
|
+
businesses: [createBusiness({ id: adminId })],
|
|
185
185
|
},
|
|
186
186
|
charges: {
|
|
187
187
|
charges: [
|
|
@@ -209,7 +209,7 @@ describe('Fixture Validation', () => {
|
|
|
209
209
|
|
|
210
210
|
const fixture: Fixture = {
|
|
211
211
|
businesses: {
|
|
212
|
-
businesses: [createBusiness({ id: adminId
|
|
212
|
+
businesses: [createBusiness({ id: adminId })],
|
|
213
213
|
},
|
|
214
214
|
charges: {
|
|
215
215
|
charges: [createCharge({ owner_id: adminId }, { id: chargeId })],
|
|
@@ -243,7 +243,7 @@ describe('Fixture Validation', () => {
|
|
|
243
243
|
|
|
244
244
|
const fixture: Fixture = {
|
|
245
245
|
businesses: {
|
|
246
|
-
businesses: [createBusiness({ id: adminId
|
|
246
|
+
businesses: [createBusiness({ id: adminId })],
|
|
247
247
|
},
|
|
248
248
|
charges: {
|
|
249
249
|
charges: [createCharge({ owner_id: adminId }, { id: chargeId })],
|
|
@@ -280,7 +280,7 @@ describe('Fixture Validation', () => {
|
|
|
280
280
|
|
|
281
281
|
const fixture: Fixture = {
|
|
282
282
|
businesses: {
|
|
283
|
-
businesses: [createBusiness({ id: adminId
|
|
283
|
+
businesses: [createBusiness({ id: adminId }), createBusiness({ id: supplierId })],
|
|
284
284
|
},
|
|
285
285
|
charges: {
|
|
286
286
|
charges: [createCharge({ owner_id: adminId }, { id: chargeId })],
|
|
@@ -342,7 +342,7 @@ describe('Fixture Validation', () => {
|
|
|
342
342
|
|
|
343
343
|
const fixture: Fixture = {
|
|
344
344
|
businesses: {
|
|
345
|
-
businesses: [createBusiness({ id: adminId
|
|
345
|
+
businesses: [createBusiness({ id: adminId })],
|
|
346
346
|
},
|
|
347
347
|
charges: {
|
|
348
348
|
charges: [createCharge({ owner_id: adminId }, { id: chargeId })],
|
|
@@ -384,7 +384,7 @@ describe('Fixture Validation', () => {
|
|
|
384
384
|
|
|
385
385
|
const fixture: Fixture = {
|
|
386
386
|
businesses: {
|
|
387
|
-
businesses: [createBusiness({ id: adminId
|
|
387
|
+
businesses: [createBusiness({ id: adminId })],
|
|
388
388
|
},
|
|
389
389
|
charges: {
|
|
390
390
|
charges: [createCharge({ owner_id: adminId }, { id: chargeId })],
|
|
@@ -435,8 +435,8 @@ describe('Fixture Validation', () => {
|
|
|
435
435
|
const fixture: Fixture = {
|
|
436
436
|
businesses: {
|
|
437
437
|
businesses: [
|
|
438
|
-
createBusiness({ id: duplicateId
|
|
439
|
-
createBusiness({ id: duplicateId
|
|
438
|
+
createBusiness({ id: duplicateId }),
|
|
439
|
+
createBusiness({ id: duplicateId }), // Duplicate
|
|
440
440
|
],
|
|
441
441
|
},
|
|
442
442
|
};
|
|
@@ -454,7 +454,7 @@ describe('Fixture Validation', () => {
|
|
|
454
454
|
|
|
455
455
|
const fixture: Fixture = {
|
|
456
456
|
businesses: {
|
|
457
|
-
businesses: [createBusiness({ id: adminId
|
|
457
|
+
businesses: [createBusiness({ id: adminId })],
|
|
458
458
|
},
|
|
459
459
|
charges: {
|
|
460
460
|
charges: [
|
|
@@ -514,10 +514,10 @@ describe('Fixture Validation', () => {
|
|
|
514
514
|
|
|
515
515
|
const fixture: Fixture = {
|
|
516
516
|
businesses: {
|
|
517
|
-
businesses: [createBusiness({ id: adminId
|
|
517
|
+
businesses: [createBusiness({ id: adminId })],
|
|
518
518
|
},
|
|
519
519
|
taxCategories: {
|
|
520
|
-
taxCategories: [createTaxCategory({ id: taxCatId
|
|
520
|
+
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
521
521
|
},
|
|
522
522
|
charges: {
|
|
523
523
|
charges: [
|