@accounter/server 0.0.9-alpha-20251210203829-57f49a64dd7ec3eb26b1ebac959531c02728c50b → 0.0.9-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e

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 (54) hide show
  1. package/CHANGELOG.md +22 -5
  2. package/dist/server/src/__tests__/factories/business.d.ts +5 -4
  3. package/dist/server/src/__tests__/factories/business.js +6 -2
  4. package/dist/server/src/__tests__/factories/business.js.map +1 -1
  5. package/dist/server/src/__tests__/factories/business.test.js +4 -4
  6. package/dist/server/src/__tests__/factories/business.test.js.map +1 -1
  7. package/dist/server/src/__tests__/factories/charge.d.ts +3 -1
  8. package/dist/server/src/__tests__/factories/charge.js +2 -1
  9. package/dist/server/src/__tests__/factories/charge.js.map +1 -1
  10. package/dist/server/src/__tests__/factories/financial-account.d.ts +3 -3
  11. package/dist/server/src/__tests__/factories/financial-account.js +1 -1
  12. package/dist/server/src/__tests__/factories/financial-account.js.map +1 -1
  13. package/dist/server/src/__tests__/factories/index.test.js +7 -7
  14. package/dist/server/src/__tests__/factories/index.test.js.map +1 -1
  15. package/dist/server/src/__tests__/factories/tax-category.d.ts +3 -2
  16. package/dist/server/src/__tests__/factories/tax-category.js +4 -0
  17. package/dist/server/src/__tests__/factories/tax-category.js.map +1 -1
  18. package/dist/server/src/__tests__/factories/tax-category.test.js +6 -6
  19. package/dist/server/src/__tests__/factories/tax-category.test.js.map +1 -1
  20. package/dist/server/src/__tests__/factories/transaction.d.ts +3 -1
  21. package/dist/server/src/__tests__/factories/transaction.js +1 -0
  22. package/dist/server/src/__tests__/factories/transaction.js.map +1 -1
  23. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js +4 -4
  24. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js.map +1 -1
  25. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js +4 -4
  26. package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js.map +1 -1
  27. package/dist/server/src/__tests__/helpers/fixture-loader.d.ts +7 -3
  28. package/dist/server/src/__tests__/helpers/fixture-loader.js +30 -21
  29. package/dist/server/src/__tests__/helpers/fixture-loader.js.map +1 -1
  30. package/dist/server/src/__tests__/helpers/fixture-loader.test.js +19 -19
  31. package/dist/server/src/__tests__/helpers/fixture-loader.test.js.map +1 -1
  32. package/dist/server/src/__tests__/helpers/fixture-types.d.ts +42 -15
  33. package/dist/server/src/__tests__/helpers/fixture-types.js +4 -0
  34. package/dist/server/src/__tests__/helpers/fixture-types.js.map +1 -1
  35. package/dist/server/src/__tests__/helpers/fixture-validation.test.js +18 -18
  36. package/dist/server/src/__tests__/helpers/fixture-validation.test.js.map +1 -1
  37. package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js +4 -4
  38. package/package.json +1 -1
  39. package/src/__tests__/factories/business.test.ts +4 -4
  40. package/src/__tests__/factories/business.ts +9 -5
  41. package/src/__tests__/factories/charge.ts +4 -2
  42. package/src/__tests__/factories/financial-account.ts +5 -5
  43. package/src/__tests__/factories/index.test.ts +7 -7
  44. package/src/__tests__/factories/tax-category.test.ts +6 -6
  45. package/src/__tests__/factories/tax-category.ts +8 -4
  46. package/src/__tests__/factories/transaction.ts +3 -1
  47. package/src/__tests__/fixtures/expenses/expense-scenario-a.ts +4 -4
  48. package/src/__tests__/fixtures/expenses/expense-scenario-b.ts +4 -4
  49. package/src/__tests__/helpers/fixture-loader.test.ts +19 -19
  50. package/src/__tests__/helpers/fixture-loader.ts +32 -23
  51. package/src/__tests__/helpers/fixture-types.ts +41 -15
  52. package/src/__tests__/helpers/fixture-validation.test.ts +18 -18
  53. package/src/modules/ledger/__tests__/helpers/ledger-assertions.ts +4 -5
  54. package/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.ts +2 -2
@@ -8,7 +8,7 @@
8
8
  * @see packages/server/src/__tests__/helpers/fixture-validation.ts for validation logic
9
9
  */
10
10
 
11
- import type { PoolClient } from 'pg';
11
+ import type { Client, PoolClient } from 'pg';
12
12
  import type { Fixture } from './fixture-types.js';
13
13
  import { assertValidFixture } from './fixture-validation.js';
14
14
  import { qualifyTable } from './test-db-config.js';
@@ -85,12 +85,16 @@ export type FixtureIdMapping = Map<string, string>;
85
85
  * - Checks referential integrity (charge IDs, business IDs, etc.)
86
86
  * - Validates required fields
87
87
  *
88
- * @param client - PostgreSQL client within an active transaction
88
+ * @param client - PostgreSQL client (PoolClient or standalone Client) within an active transaction
89
89
  * @param fixture - Complete fixture to insert
90
90
  * @returns Promise resolving to ID mapping (fixture ID → database ID)
91
91
  * @throws {Error} If fixture validation fails (via assertValidFixture)
92
92
  * @throws {FixtureInsertionError} If any insertion section fails
93
93
  *
94
+ * @remarks
95
+ * Type Safety: Accepts both PoolClient and Client to support both test transactions
96
+ * (pool.connect()) and standalone connections (new pg.Client()) used in seed scripts.
97
+ *
94
98
  * @example
95
99
  * ```typescript
96
100
  * import { withTestTransaction } from './test-transaction.js';
@@ -112,7 +116,7 @@ export type FixtureIdMapping = Map<string, string>;
112
116
  * ```
113
117
  */
114
118
  export async function insertFixture(
115
- client: PoolClient,
119
+ client: PoolClient | Client,
116
120
  fixture: Fixture,
117
121
  ): Promise<FixtureIdMapping> {
118
122
  // Validate fixture before insertion
@@ -148,12 +152,13 @@ export async function insertFixture(
148
152
  await executeSavepointSection('businesses', async () => {
149
153
  for (const business of fixture.businesses!.businesses) {
150
154
  // Insert financial entity first (type='business')
155
+ // Field mapping: business.name used for display (required); hebrewName is legacy/optional
151
156
  const entityResult = await client.query(
152
157
  `INSERT INTO ${qualifyTable('financial_entities')} (id, name, type)
153
158
  VALUES ($1, $2, 'business')
154
159
  ON CONFLICT (id) DO NOTHING
155
160
  RETURNING id`,
156
- [business.id, business.hebrewName || business.id],
161
+ [business.id, business.name || business.id],
157
162
  );
158
163
 
159
164
  // Insert business details - note: vat_number column maps to governmentId field
@@ -173,13 +178,13 @@ export async function insertFixture(
173
178
  business.website,
174
179
  business.phoneNumber,
175
180
  business.governmentId, // Maps to vat_number column
176
- business.exemptDealer,
177
- business.suggestions,
178
- business.optionalVat,
179
- business.country,
180
- business.pcn874RecordTypeOverride,
181
- business.isReceiptEnough,
182
- business.isDocumentsOptional,
181
+ business.exemptDealer ?? false,
182
+ business.suggestions ?? null,
183
+ business.optionalVat ?? false,
184
+ business.country ?? 'ISR',
185
+ business.pcn874RecordTypeOverride ?? null,
186
+ business.isReceiptEnough ?? false,
187
+ business.isDocumentsOptional ?? false,
183
188
  ],
184
189
  );
185
190
 
@@ -213,7 +218,7 @@ export async function insertFixture(
213
218
  )
214
219
  VALUES ($1, $2, $3)
215
220
  ON CONFLICT (id) DO NOTHING`,
216
- [taxCategory.id, taxCategory.hashavshevetName, taxCategory.taxExcluded],
221
+ [taxCategory.id, taxCategory.hashavshevetName, taxCategory.taxExcluded ?? false],
217
222
  );
218
223
 
219
224
  if (entityResult.rows.length > 0) {
@@ -292,19 +297,21 @@ export async function insertFixture(
292
297
  await client.query(
293
298
  `INSERT INTO ${qualifyTable('charges')} (
294
299
  id, owner_id, type, accountant_status, user_description,
295
- tax_category_id, optional_vat, documents_optional_flag
300
+ tax_category_id, optional_vat, documents_optional_flag,
301
+ is_property, created_at, updated_at
296
302
  )
297
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
303
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, NOW(), NOW())
298
304
  ON CONFLICT (id) DO NOTHING`,
299
305
  [
300
306
  charge.id,
301
307
  charge.owner_id,
302
- charge.type,
303
- charge.accountant_status,
308
+ charge.type ?? null,
309
+ charge.accountant_status ?? 'PENDING',
304
310
  charge.user_description,
305
- charge.tax_category_id,
306
- charge.optional_vat,
307
- charge.documents_optional_flag,
311
+ charge.tax_category_id ?? null,
312
+ charge.optional_vat ?? false,
313
+ charge.documents_optional_flag ?? false,
314
+ charge.is_property ?? false,
308
315
  ],
309
316
  );
310
317
 
@@ -348,9 +355,10 @@ export async function insertFixture(
348
355
  `INSERT INTO ${qualifyTable('transactions')} (
349
356
  id, account_id, charge_id, source_id, source_description,
350
357
  currency, event_date, debit_date, amount, current_balance,
351
- business_id, is_fee, source_reference, source_origin, origin_key
358
+ business_id, is_fee, source_reference, source_origin, origin_key,
359
+ currency_rate, created_at, updated_at
352
360
  )
353
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
361
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, NOW(), NOW())
354
362
  ON CONFLICT (id) DO NOTHING`,
355
363
  [
356
364
  transaction.id,
@@ -362,12 +370,13 @@ export async function insertFixture(
362
370
  transaction.event_date,
363
371
  transaction.debit_date,
364
372
  transaction.amount,
365
- transaction.current_balance,
373
+ transaction.current_balance ?? '0',
366
374
  transaction.business_id,
367
- transaction.is_fee,
375
+ transaction.is_fee ?? false,
368
376
  'TEST-REF', // source_reference (NOT NULL)
369
377
  'TEST', // source_origin (NOT NULL)
370
378
  dummyEtherscanId, // origin_key (NOT NULL) - must match etherscan_id in raw list
379
+ transaction.currency_rate ?? 1,
371
380
  ],
372
381
  );
373
382
 
@@ -5,16 +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
+ *
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
- import type { ChargeInsertParams } from '../factories/charge.js';
16
- import type { TransactionInsertParams } from '../factories/transaction.js';
17
- import type { DocumentInsertParams } from '../factories/document.js';
16
+ import type { ChargeInsertParams, TransactionInsertParams, DocumentInsertParams } from '../factories/index.js';
17
+ import type { financial_account_type } from '../../modules/transactions/types.js';
18
18
 
19
19
  /**
20
20
  * Business entities in a fixture
@@ -29,7 +29,23 @@ export interface FixtureBusinesses {
29
29
  * Each business must have a unique id. The id will be referenced by
30
30
  * charges (owner_id), transactions (business_id), and documents (creditor_id/debtor_id).
31
31
  */
32
- businesses: IInsertBusinessesParams['businesses'];
32
+ businesses: Array<{
33
+ id: string,
34
+ name: string,
35
+ hebrewName?: string | null,
36
+ address?: string | null,
37
+ email?: string | null,
38
+ website?: string | null,
39
+ phoneNumber?: string | null,
40
+ governmentId?: string | null,
41
+ exemptDealer?: boolean | null,
42
+ suggestions?: object | null,
43
+ optionalVat?: boolean | null,
44
+ country?: string | null,
45
+ pcn874RecordTypeOverride?: unknown | null,
46
+ isReceiptEnough?: boolean | null,
47
+ isDocumentsOptional?: boolean | null;
48
+ }>;
33
49
  }
34
50
 
35
51
  /**
@@ -44,7 +60,12 @@ export interface FixtureTaxCategories {
44
60
  * Each tax category must have a unique id. The id will be referenced by
45
61
  * charges (tax_category_id) and financial accounts.
46
62
  */
47
- taxCategories: IInsertTaxCategoryParams[];
63
+ taxCategories: Array<{
64
+ id: string;
65
+ name: string;
66
+ hashavshevetName?: string | null;
67
+ taxExcluded?: boolean | null;
68
+ }>;
48
69
  }
49
70
 
50
71
  /**
@@ -60,7 +81,12 @@ export interface FixtureAccounts {
60
81
  * Each account must have a unique id. The id will be referenced by
61
82
  * transactions (account_id).
62
83
  */
63
- accounts: IInsertFinancialAccountsParams['bankAccounts'];
84
+ accounts: Array<{
85
+ accountNumber?: string | null,
86
+ name?: string | null,
87
+ privateBusiness?: string | null,
88
+ ownerId?: string | null,
89
+ type?: financial_account_type | null}>;
64
90
  }
65
91
 
66
92
  /**
@@ -217,7 +243,7 @@ export interface LedgerExpectation {
217
243
  * const expenseScenarioA: Fixture = {
218
244
  * businesses: {
219
245
  * businesses: [
220
- * createBusiness({ id: makeUUID('supplier-1'), hebrewName: 'Local Supplier Ltd' }),
246
+ * createBusiness({ id: makeUUID('business', 'supplier-1'), hebrewName: 'Local Supplier Ltd' }),
221
247
  * ],
222
248
  * },
223
249
  * charges: {
@@ -228,8 +254,8 @@ export interface LedgerExpectation {
228
254
  * transactions: {
229
255
  * transactions: [
230
256
  * createTransaction({
231
- * charge_id: makeUUID('charge-1'),
232
- * business_id: makeUUID('supplier-1'),
257
+ * charge_id: makeUUID('charge', 'charge-1'),
258
+ * business_id: makeUUID('business', 'supplier-1'),
233
259
  * amount: '-1000.00',
234
260
  * currency: 'ILS',
235
261
  * event_date: '2024-01-15',
@@ -239,8 +265,8 @@ export interface LedgerExpectation {
239
265
  * documents: {
240
266
  * documents: [
241
267
  * createDocument({
242
- * charge_id: makeUUID('charge-1'),
243
- * creditor_id: makeUUID('supplier-1'),
268
+ * charge_id: makeUUID('charge', 'charge-1'),
269
+ * creditor_id: makeUUID('business', 'supplier-1'),
244
270
  * debtor_id: ADMIN_ID,
245
271
  * type: 'RECEIPT',
246
272
  * total_amount: 1000.0,
@@ -252,7 +278,7 @@ export interface LedgerExpectation {
252
278
  * expectations: {
253
279
  * ledger: [
254
280
  * {
255
- * chargeId: makeUUID('charge-1'),
281
+ * chargeId: makeUUID('charge', 'charge-1'),
256
282
  * recordCount: 2,
257
283
  * debitEntities: [EXPENSE_TAX_CATEGORY_ID],
258
284
  * 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: [
@@ -324,18 +324,17 @@ export function assertForeignExpenseScenario(records: LedgerRecord[], params: {
324
324
  const legCountApprox = Math.round(params.expectedLocalTotal / impliedPerLeg);
325
325
  // Validate each leg amount close to impliedPerLeg (within 5%)
326
326
  debitLegs.forEach((amt, i) => {
327
- expectClose(amt, impliedPerLeg, impliedPerLeg * 0.05, `Debit leg ${i} amount mismatch`);
327
+ expectClose(amt, impliedPerLeg, impliedPerLeg + 0.05, `Debit leg ${i} amount mismatch`);
328
328
  });
329
329
  creditLegs.forEach((amt, i) => {
330
- expectClose(amt, impliedPerLeg, impliedPerLeg * 0.05, `Credit leg ${i} amount mismatch`);
330
+ expectClose(amt, impliedPerLeg, impliedPerLeg + 0.05, `Credit leg ${i} amount mismatch`);
331
331
  });
332
332
  // Aggregate totals
333
333
  const totalDebit = debitLegs.reduce((a, b) => a + b, 0);
334
334
  const totalCredit = creditLegs.reduce((a, b) => a + b, 0);
335
- expectClose(totalDebit, params.expectedLocalTotal, params.expectedLocalTotal * 0.05, 'Aggregate debit total mismatch');
336
- expectClose(totalCredit, params.expectedLocalTotal, params.expectedLocalTotal * 0.05, 'Aggregate credit total mismatch');
335
+ expectClose(totalDebit, params.expectedLocalTotal, params.expectedLocalTotal + 0.05, 'Aggregate debit total mismatch');
336
+ expectClose(totalCredit, params.expectedLocalTotal, params.expectedLocalTotal + 0.05, 'Aggregate credit total mismatch');
337
337
  // Leg count heuristic
338
338
  expect(Math.abs(debitLegs.length - legCountApprox), 'Unexpected number of debit legs').toBeLessThanOrEqual(1);
339
339
  expect(Math.abs(creditLegs.length - legCountApprox), 'Unexpected number of credit legs').toBeLessThanOrEqual(1);
340
340
  }
341
-
@@ -46,7 +46,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
46
46
  const chargeId = makeUUID('charge', 'charge-office-supplies');
47
47
  await client.query(
48
48
  `DELETE FROM ${qualifyTable('ledger_records')} WHERE charge_id = $1`,
49
- [chargeId],
49
+ [chargeId]
50
50
  );
51
51
  // Also clear the scenario's fixture rows to keep DB tidy
52
52
  await client.query(
@@ -55,7 +55,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
55
55
  );
56
56
  await client.query(
57
57
  `DELETE FROM ${qualifyTable('transactions')} WHERE charge_id = $1`,
58
- [chargeId],
58
+ [chargeId]
59
59
  );
60
60
  await client.query(
61
61
  `DELETE FROM ${qualifyTable('charges')} WHERE id = $1`,