@accounter/server 0.0.9-alpha-20251210203824-9acbe3841d014ef59dda036ae5cbf72f739cfa37 → 0.0.9-alpha-20251211033737-29a3e4c4c745e562726ab60c423e6cedd9e22c44
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 +22 -5
- package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
- package/dist/server/src/__tests__/factories/business.d.ts +5 -4
- package/dist/server/src/__tests__/factories/business.js +6 -2
- 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 +3 -2
- package/dist/server/src/__tests__/factories/tax-category.js +4 -0
- 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 +2 -1
- 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 +41 -12
- package/dist/server/src/__tests__/helpers/fixture-types.js +4 -0
- 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 +3 -3
- package/src/__tests__/factories/business.test.ts +4 -4
- package/src/__tests__/factories/business.ts +9 -5
- 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 +8 -4
- 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 +2 -1
- package/src/__tests__/helpers/fixture-types.ts +40 -12
- 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,
|
|
4
3
|
} from '../../modules/financial-accounts/__generated__/financial-accounts.types.js';
|
|
5
4
|
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 FixtureAccounts['accounts'][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<FixtureAccounts['accounts'][number]>,
|
|
60
|
+
): FixtureAccounts['accounts'][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
|
+
name: 'Local Supplier',
|
|
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'), name: 'Business 1' });
|
|
110
|
+
const business2 = createBusiness({ id: makeUUID('business', 'biz-1'), name: 'Business 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
|
+
name: 'Business',
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
const taxCategory = createTaxCategory({
|
|
178
|
-
|
|
178
|
+
name: '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.name).toBe('Business');
|
|
186
186
|
expect(business.id).toBeDefined();
|
|
187
187
|
|
|
188
|
-
expect(taxCategory.
|
|
188
|
+
expect(taxCategory.name).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
|
+
name: 'משרדיות',
|
|
34
34
|
taxExcluded: true,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
expect(category.id).toBe(customId);
|
|
38
|
-
expect(category.
|
|
38
|
+
expect(category.name).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
|
+
name: 'שכר',
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
expect(category.
|
|
47
|
+
expect(category.name).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
|
+
name: 'הוצאות משרד',
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
expect(category.
|
|
75
|
+
expect(category.name).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';
|
|
2
1
|
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,6 +11,7 @@ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.j
|
|
|
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)
|
|
14
15
|
* - hashavshevetName defaults to null (not integrated with Hashavshevet)
|
|
15
16
|
* - taxExcluded defaults to false (most categories include tax)
|
|
16
17
|
*
|
|
@@ -33,13 +34,16 @@ import { makeUUIDLegacy } from '../../demo-fixtures/helpers/deterministic-uuid.j
|
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
36
|
export function createTaxCategory(
|
|
36
|
-
overrides?: Partial<
|
|
37
|
-
):
|
|
37
|
+
overrides?: Partial<FixtureTaxCategories['taxCategories'][number]>,
|
|
38
|
+
): FixtureTaxCategories['taxCategories'][number] {
|
|
38
39
|
const defaultId = makeUUIDLegacy();
|
|
39
40
|
return {
|
|
40
41
|
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,
|
|
41
45
|
hashavshevetName: null,
|
|
42
46
|
taxExcluded: false,
|
|
43
47
|
...overrides,
|
|
44
48
|
};
|
|
45
|
-
}
|
|
49
|
+
}
|
|
@@ -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
|
+
name: 'Accountancy Management',
|
|
60
60
|
country: CountryCode.Israel,
|
|
61
61
|
}),
|
|
62
62
|
// Supplier business
|
|
63
63
|
createBusiness({
|
|
64
64
|
id: makeUUID('business', 'supplier-local-ltd'),
|
|
65
|
-
|
|
65
|
+
name: 'Local Supplier Ltd',
|
|
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
|
+
name: 'General Expenses',
|
|
78
78
|
}),
|
|
79
79
|
createTaxCategory({
|
|
80
80
|
id: makeUUID('tax-category', 'bank-account-tax-category'),
|
|
81
|
-
|
|
81
|
+
name: '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
|
+
name: 'Accounter Admin',
|
|
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
|
+
name: 'Supplier US Vendor LLC',
|
|
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
|
+
name: 'Consulting Expenses',
|
|
90
90
|
}),
|
|
91
91
|
createTaxCategory({
|
|
92
92
|
id: makeUUID('tax-category', 'usd-account-tax-category'),
|
|
93
|
-
|
|
93
|
+
name: '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
|
+
name: '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
|
+
name: 'Test Tax Category 1',
|
|
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).toBeNull();
|
|
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).toBeNull();
|
|
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, name: 'Supplier Ltd' }),
|
|
119
|
+
createBusiness({ id: customerId, name: 'Customer Inc' }),
|
|
120
120
|
],
|
|
121
121
|
},
|
|
122
122
|
taxCategories: {
|
|
123
|
-
taxCategories: [createTaxCategory({ id: taxCategoryId })],
|
|
123
|
+
taxCategories: [createTaxCategory({ id: taxCategoryId, name: 'Tax Category 1' })],
|
|
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, name: 'Lonely Business' })],
|
|
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, name: 'Test Biz' })],
|
|
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, name: 'Business 1' }),
|
|
326
|
+
createBusiness({ id: biz2, name: 'Business 2' }),
|
|
327
327
|
],
|
|
328
328
|
},
|
|
329
329
|
taxCategories: {
|
|
330
330
|
taxCategories: [
|
|
331
|
-
createTaxCategory({ id: tax1,
|
|
332
|
-
createTaxCategory({ id: tax2,
|
|
331
|
+
createTaxCategory({ id: tax1, name: 'Tax 1' }),
|
|
332
|
+
createTaxCategory({ id: tax2, name: '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, name: '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, name: '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('financial_entities')} WHERE id = $1`,
|
|
390
390
|
[businessId],
|
|
391
391
|
);
|
|
392
|
-
expect(result.rows[0].
|
|
392
|
+
expect(result.rows[0].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, name: 'Biz Tx' })],
|
|
406
406
|
},
|
|
407
407
|
taxCategories: {
|
|
408
|
-
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
408
|
+
taxCategories: [createTaxCategory({ id: taxCatId, name: 'Tax Tx' })],
|
|
409
409
|
},
|
|
410
410
|
accounts: {
|
|
411
411
|
accounts: [
|
|
@@ -148,12 +148,13 @@ 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
|
|
151
152
|
const entityResult = await client.query(
|
|
152
153
|
`INSERT INTO ${qualifyTable('financial_entities')} (id, name, type)
|
|
153
154
|
VALUES ($1, $2, 'business')
|
|
154
155
|
ON CONFLICT (id) DO NOTHING
|
|
155
156
|
RETURNING id`,
|
|
156
|
-
[business.id, business.
|
|
157
|
+
[business.id, business.name || business.id],
|
|
157
158
|
);
|
|
158
159
|
|
|
159
160
|
// Insert business details - note: vat_number column maps to governmentId field
|
|
@@ -5,16 +5,18 @@
|
|
|
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
|
+
*
|
|
8
12
|
* @see packages/server/src/__tests__/helpers/fixture-validation.ts for validation logic
|
|
9
13
|
* @see packages/server/src/__tests__/helpers/fixture-loader.ts for insertion logic
|
|
10
14
|
*/
|
|
11
15
|
|
|
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';
|
|
15
16
|
import type { ChargeInsertParams } from '../factories/charge.js';
|
|
16
17
|
import type { TransactionInsertParams } from '../factories/transaction.js';
|
|
17
18
|
import type { DocumentInsertParams } from '../factories/document.js';
|
|
19
|
+
import type { financial_account_type } from '../../modules/transactions/types.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Business entities in a fixture
|
|
@@ -29,7 +31,23 @@ export interface FixtureBusinesses {
|
|
|
29
31
|
* Each business must have a unique id. The id will be referenced by
|
|
30
32
|
* charges (owner_id), transactions (business_id), and documents (creditor_id/debtor_id).
|
|
31
33
|
*/
|
|
32
|
-
businesses:
|
|
34
|
+
businesses: Array<{
|
|
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
|
+
}>;
|
|
33
51
|
}
|
|
34
52
|
|
|
35
53
|
/**
|
|
@@ -44,7 +62,12 @@ export interface FixtureTaxCategories {
|
|
|
44
62
|
* Each tax category must have a unique id. The id will be referenced by
|
|
45
63
|
* charges (tax_category_id) and financial accounts.
|
|
46
64
|
*/
|
|
47
|
-
taxCategories:
|
|
65
|
+
taxCategories: Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
hashavshevetName?: string | null;
|
|
69
|
+
taxExcluded?: boolean | null;
|
|
70
|
+
}>;
|
|
48
71
|
}
|
|
49
72
|
|
|
50
73
|
/**
|
|
@@ -60,7 +83,12 @@ export interface FixtureAccounts {
|
|
|
60
83
|
* Each account must have a unique id. The id will be referenced by
|
|
61
84
|
* transactions (account_id).
|
|
62
85
|
*/
|
|
63
|
-
accounts:
|
|
86
|
+
accounts: Array<{
|
|
87
|
+
accountNumber?: string | null,
|
|
88
|
+
name?: string | null,
|
|
89
|
+
privateBusiness?: string | null,
|
|
90
|
+
ownerId?: string | null,
|
|
91
|
+
type?: financial_account_type | null}>;
|
|
64
92
|
}
|
|
65
93
|
|
|
66
94
|
/**
|
|
@@ -217,7 +245,7 @@ export interface LedgerExpectation {
|
|
|
217
245
|
* const expenseScenarioA: Fixture = {
|
|
218
246
|
* businesses: {
|
|
219
247
|
* businesses: [
|
|
220
|
-
* createBusiness({ id: makeUUID('supplier-1'), hebrewName: 'Local Supplier Ltd' }),
|
|
248
|
+
* createBusiness({ id: makeUUID('business', 'supplier-1'), hebrewName: 'Local Supplier Ltd' }),
|
|
221
249
|
* ],
|
|
222
250
|
* },
|
|
223
251
|
* charges: {
|
|
@@ -228,8 +256,8 @@ export interface LedgerExpectation {
|
|
|
228
256
|
* transactions: {
|
|
229
257
|
* transactions: [
|
|
230
258
|
* createTransaction({
|
|
231
|
-
* charge_id: makeUUID('charge-1'),
|
|
232
|
-
* business_id: makeUUID('supplier-1'),
|
|
259
|
+
* charge_id: makeUUID('charge', 'charge-1'),
|
|
260
|
+
* business_id: makeUUID('business', 'supplier-1'),
|
|
233
261
|
* amount: '-1000.00',
|
|
234
262
|
* currency: 'ILS',
|
|
235
263
|
* event_date: '2024-01-15',
|
|
@@ -239,8 +267,8 @@ export interface LedgerExpectation {
|
|
|
239
267
|
* documents: {
|
|
240
268
|
* documents: [
|
|
241
269
|
* createDocument({
|
|
242
|
-
* charge_id: makeUUID('charge-1'),
|
|
243
|
-
* creditor_id: makeUUID('supplier-1'),
|
|
270
|
+
* charge_id: makeUUID('charge', 'charge-1'),
|
|
271
|
+
* creditor_id: makeUUID('business', 'supplier-1'),
|
|
244
272
|
* debtor_id: ADMIN_ID,
|
|
245
273
|
* type: 'RECEIPT',
|
|
246
274
|
* total_amount: 1000.0,
|
|
@@ -252,7 +280,7 @@ export interface LedgerExpectation {
|
|
|
252
280
|
* expectations: {
|
|
253
281
|
* ledger: [
|
|
254
282
|
* {
|
|
255
|
-
* chargeId: makeUUID('charge-1'),
|
|
283
|
+
* chargeId: makeUUID('charge', 'charge-1'),
|
|
256
284
|
* recordCount: 2,
|
|
257
285
|
* debitEntities: [EXPENSE_TAX_CATEGORY_ID],
|
|
258
286
|
* 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, name: 'Admin' }),
|
|
25
|
+
createBusiness({ id: supplierId, name: 'Supplier' }),
|
|
26
26
|
],
|
|
27
27
|
},
|
|
28
28
|
taxCategories: {
|
|
29
|
-
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
29
|
+
taxCategories: [createTaxCategory({ id: taxCatId, name: 'Tax Category' })],
|
|
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, name: 'Admin' })],
|
|
77
77
|
},
|
|
78
78
|
taxCategories: {
|
|
79
|
-
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
79
|
+
taxCategories: [createTaxCategory({ id: taxCatId, name: 'Tax Category' })],
|
|
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 }), createBusiness({ id: supplierId })],
|
|
99
|
+
businesses: [createBusiness({ id: adminId, name: 'Admin' }), createBusiness({ id: supplierId, name: 'Supplier' })],
|
|
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 }), createBusiness({ id: supplierId })],
|
|
130
|
+
businesses: [createBusiness({ id: adminId, name: 'Admin' }), createBusiness({ id: supplierId, name: 'Supplier' })],
|
|
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, name: 'Admin' })],
|
|
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, name: 'Admin' })],
|
|
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, name: 'Admin' })],
|
|
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 }), createBusiness({ id: supplierId })],
|
|
283
|
+
businesses: [createBusiness({ id: adminId, name: 'Admin' }), createBusiness({ id: supplierId, name: 'Supplier' })],
|
|
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, name: 'Admin' })],
|
|
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, name: 'Admin' })],
|
|
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 }), // Duplicate
|
|
438
|
+
createBusiness({ id: duplicateId, name: 'Duplicate Business' }),
|
|
439
|
+
createBusiness({ id: duplicateId, name: 'Duplicate Business' }), // 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, name: 'Admin' })],
|
|
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, name: 'Admin' })],
|
|
518
518
|
},
|
|
519
519
|
taxCategories: {
|
|
520
|
-
taxCategories: [createTaxCategory({ id: taxCatId })],
|
|
520
|
+
taxCategories: [createTaxCategory({ id: taxCatId, name: 'Tax Category' })],
|
|
521
521
|
},
|
|
522
522
|
charges: {
|
|
523
523
|
charges: [
|