@accounter/server 0.0.9-alpha-20251210153039-1cfd8df346dd211c95a70c76c63465a29236849b → 0.0.9-alpha-20251210155614-e6e65aaecafef9e8fedd0b933f613ffcf478cecf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -27
- package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
- package/dist/server/src/__tests__/factories/business.d.ts +2 -2
- package/dist/server/src/__tests__/factories/business.js +4 -5
- package/dist/server/src/__tests__/factories/business.js.map +1 -1
- package/dist/server/src/__tests__/factories/business.test.js +2 -2
- package/dist/server/src/__tests__/factories/business.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/charge.d.ts +9 -9
- package/dist/server/src/__tests__/factories/charge.js +15 -15
- package/dist/server/src/__tests__/factories/charge.js.map +1 -1
- package/dist/server/src/__tests__/factories/charge.test.js +14 -14
- package/dist/server/src/__tests__/factories/charge.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/document.d.ts +9 -9
- package/dist/server/src/__tests__/factories/document.js +11 -11
- package/dist/server/src/__tests__/factories/document.js.map +1 -1
- package/dist/server/src/__tests__/factories/document.test.js +38 -38
- package/dist/server/src/__tests__/factories/document.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/financial-account.js +2 -2
- package/dist/server/src/__tests__/factories/financial-account.js.map +1 -1
- package/dist/server/src/__tests__/factories/financial-account.test.js +7 -7
- package/dist/server/src/__tests__/factories/financial-account.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/ids.d.ts +22 -0
- package/dist/server/src/__tests__/factories/ids.js +46 -0
- package/dist/server/src/__tests__/factories/ids.js.map +1 -0
- package/dist/server/src/__tests__/factories/ids.test.js +71 -0
- package/dist/server/src/__tests__/factories/ids.test.js.map +1 -0
- package/dist/server/src/__tests__/factories/index.d.ts +2 -2
- package/dist/server/src/__tests__/factories/index.js +2 -2
- package/dist/server/src/__tests__/factories/index.js.map +1 -1
- package/dist/server/src/__tests__/factories/index.test.js +12 -12
- package/dist/server/src/__tests__/factories/index.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/tax-category.d.ts +3 -3
- package/dist/server/src/__tests__/factories/tax-category.js +5 -6
- package/dist/server/src/__tests__/factories/tax-category.js.map +1 -1
- package/dist/server/src/__tests__/factories/tax-category.test.js +4 -4
- package/dist/server/src/__tests__/factories/tax-category.test.js.map +1 -1
- package/dist/server/src/__tests__/factories/transaction.d.ts +7 -7
- package/dist/server/src/__tests__/factories/transaction.js +11 -11
- package/dist/server/src/__tests__/factories/transaction.js.map +1 -1
- package/dist/server/src/__tests__/factories/transaction.test.js +27 -27
- package/dist/server/src/__tests__/factories/transaction.test.js.map +1 -1
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-a.js +20 -20
- 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 +20 -20
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.js.map +1 -1
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.test.js +8 -8
- package/dist/server/src/__tests__/fixtures/expenses/expense-scenario-b.test.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-loader.js +2 -2
- package/dist/server/src/__tests__/helpers/fixture-loader.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-loader.test.js +29 -32
- package/dist/server/src/__tests__/helpers/fixture-loader.test.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-validation.test.js +50 -50
- package/dist/server/src/__tests__/helpers/fixture-validation.test.js.map +1 -1
- package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.d.ts +2 -0
- package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js +4 -0
- package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js.map +1 -1
- package/dist/server/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.js +20 -20
- package/dist/server/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.js.map +1 -1
- package/dist/server/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.js +21 -21
- package/dist/server/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/factories/business.test.ts +3 -3
- package/src/__tests__/factories/business.ts +4 -5
- package/src/__tests__/factories/charge.test.ts +14 -14
- package/src/__tests__/factories/charge.ts +16 -16
- package/src/__tests__/factories/document.test.ts +38 -38
- package/src/__tests__/factories/document.ts +11 -11
- package/src/__tests__/factories/financial-account.test.ts +7 -7
- package/src/__tests__/factories/financial-account.ts +3 -3
- package/src/__tests__/factories/ids.test.ts +80 -0
- package/src/__tests__/factories/ids.ts +49 -0
- package/src/__tests__/factories/index.test.ts +12 -12
- package/src/__tests__/factories/index.ts +2 -2
- package/src/__tests__/factories/tax-category.test.ts +4 -4
- package/src/__tests__/factories/tax-category.ts +6 -7
- package/src/__tests__/factories/transaction.test.ts +27 -27
- package/src/__tests__/factories/transaction.ts +11 -11
- package/src/__tests__/fixtures/expenses/expense-scenario-a.ts +20 -20
- package/src/__tests__/fixtures/expenses/expense-scenario-b.test.ts +8 -8
- package/src/__tests__/fixtures/expenses/expense-scenario-b.ts +20 -20
- package/src/__tests__/helpers/fixture-loader.test.ts +29 -31
- package/src/__tests__/helpers/fixture-loader.ts +2 -2
- package/src/__tests__/helpers/fixture-validation.test.ts +50 -50
- package/src/modules/ledger/__tests__/helpers/ledger-assertions.ts +5 -0
- package/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.ts +20 -20
- package/src/modules/ledger/__tests__/ledger-scenario-b.integration.test.ts +21 -21
- package/dist/server/src/demo-fixtures/__tests__/deterministic-uuid.test.js +0 -58
- package/dist/server/src/demo-fixtures/__tests__/deterministic-uuid.test.js.map +0 -1
- package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.d.ts +0 -50
- package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.js +0 -66
- package/dist/server/src/demo-fixtures/helpers/deterministic-uuid.js.map +0 -1
- package/src/demo-fixtures/__tests__/deterministic-uuid.test.ts +0 -75
- package/src/demo-fixtures/helpers/deterministic-uuid.ts +0 -68
- /package/dist/server/src/{demo-fixtures/__tests__/deterministic-uuid.test.d.ts → __tests__/factories/ids.test.d.ts} +0 -0
|
@@ -5,18 +5,18 @@ import { createDocument } from '../factories/document.js';
|
|
|
5
5
|
import { createFinancialAccount } from '../factories/financial-account.js';
|
|
6
6
|
import { createTaxCategory } from '../factories/tax-category.js';
|
|
7
7
|
import { createTransaction } from '../factories/transaction.js';
|
|
8
|
-
import { makeUUID } from '
|
|
8
|
+
import { makeUUID } from '../factories/ids.js';
|
|
9
9
|
import type { Fixture } from './fixture-types.js';
|
|
10
10
|
import { assertValidFixture, validateFixture } from './fixture-validation.js';
|
|
11
11
|
|
|
12
12
|
describe('Fixture Validation', () => {
|
|
13
13
|
describe('validateFixture', () => {
|
|
14
14
|
it('should validate a complete valid fixture', () => {
|
|
15
|
-
const adminId = makeUUID('
|
|
16
|
-
const supplierId = makeUUID('
|
|
17
|
-
const taxCatId = makeUUID('tax-
|
|
18
|
-
const chargeId = makeUUID('charge'
|
|
19
|
-
const accountId = makeUUID('account'
|
|
15
|
+
const adminId = makeUUID('admin');
|
|
16
|
+
const supplierId = makeUUID('supplier');
|
|
17
|
+
const taxCatId = makeUUID('tax-cat');
|
|
18
|
+
const chargeId = makeUUID('charge');
|
|
19
|
+
const accountId = makeUUID('account');
|
|
20
20
|
|
|
21
21
|
const fixture: Fixture = {
|
|
22
22
|
businesses: {
|
|
@@ -67,9 +67,9 @@ describe('Fixture Validation', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it('should validate a minimal fixture with just charges', () => {
|
|
70
|
-
const adminId = makeUUID('
|
|
71
|
-
const chargeId = makeUUID('charge'
|
|
72
|
-
const taxCatId = makeUUID('tax-
|
|
70
|
+
const adminId = makeUUID('admin');
|
|
71
|
+
const chargeId = makeUUID('charge');
|
|
72
|
+
const taxCatId = makeUUID('tax-cat');
|
|
73
73
|
|
|
74
74
|
const fixture: Fixture = {
|
|
75
75
|
businesses: {
|
|
@@ -90,9 +90,9 @@ describe('Fixture Validation', () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('should fail when transaction references non-existent charge', () => {
|
|
93
|
-
const adminId = makeUUID('
|
|
94
|
-
const supplierId = makeUUID('
|
|
95
|
-
const nonExistentChargeId = makeUUID('
|
|
93
|
+
const adminId = makeUUID('admin');
|
|
94
|
+
const supplierId = makeUUID('supplier');
|
|
95
|
+
const nonExistentChargeId = makeUUID('non-existent-charge');
|
|
96
96
|
|
|
97
97
|
const fixture: Fixture = {
|
|
98
98
|
businesses: {
|
|
@@ -121,9 +121,9 @@ describe('Fixture Validation', () => {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
it('should fail when document references non-existent charge', () => {
|
|
124
|
-
const adminId = makeUUID('
|
|
125
|
-
const supplierId = makeUUID('
|
|
126
|
-
const nonExistentChargeId = makeUUID('
|
|
124
|
+
const adminId = makeUUID('admin');
|
|
125
|
+
const supplierId = makeUUID('supplier');
|
|
126
|
+
const nonExistentChargeId = makeUUID('non-existent-charge');
|
|
127
127
|
|
|
128
128
|
const fixture: Fixture = {
|
|
129
129
|
businesses: {
|
|
@@ -154,8 +154,8 @@ describe('Fixture Validation', () => {
|
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
it('should fail when charge references non-existent business', () => {
|
|
157
|
-
const nonExistentBusinessId = makeUUID('
|
|
158
|
-
const chargeId = makeUUID('charge'
|
|
157
|
+
const nonExistentBusinessId = makeUUID('non-existent-business');
|
|
158
|
+
const chargeId = makeUUID('charge');
|
|
159
159
|
|
|
160
160
|
const fixture: Fixture = {
|
|
161
161
|
charges: {
|
|
@@ -175,9 +175,9 @@ describe('Fixture Validation', () => {
|
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
it('should fail when charge references non-existent tax category', () => {
|
|
178
|
-
const adminId = makeUUID('
|
|
179
|
-
const chargeId = makeUUID('charge'
|
|
180
|
-
const nonExistentTaxCatId = makeUUID('
|
|
178
|
+
const adminId = makeUUID('admin');
|
|
179
|
+
const chargeId = makeUUID('charge');
|
|
180
|
+
const nonExistentTaxCatId = makeUUID('non-existent-tax-cat');
|
|
181
181
|
|
|
182
182
|
const fixture: Fixture = {
|
|
183
183
|
businesses: {
|
|
@@ -203,9 +203,9 @@ describe('Fixture Validation', () => {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
it('should fail when transaction references non-existent business', () => {
|
|
206
|
-
const adminId = makeUUID('
|
|
207
|
-
const chargeId = makeUUID('charge'
|
|
208
|
-
const nonExistentBusinessId = makeUUID('
|
|
206
|
+
const adminId = makeUUID('admin');
|
|
207
|
+
const chargeId = makeUUID('charge');
|
|
208
|
+
const nonExistentBusinessId = makeUUID('non-existent-business');
|
|
209
209
|
|
|
210
210
|
const fixture: Fixture = {
|
|
211
211
|
businesses: {
|
|
@@ -237,9 +237,9 @@ describe('Fixture Validation', () => {
|
|
|
237
237
|
});
|
|
238
238
|
|
|
239
239
|
it('should fail when document references non-existent creditor', () => {
|
|
240
|
-
const adminId = makeUUID('
|
|
241
|
-
const chargeId = makeUUID('charge'
|
|
242
|
-
const nonExistentCreditorId = makeUUID('
|
|
240
|
+
const adminId = makeUUID('admin');
|
|
241
|
+
const chargeId = makeUUID('charge');
|
|
242
|
+
const nonExistentCreditorId = makeUUID('non-existent-creditor');
|
|
243
243
|
|
|
244
244
|
const fixture: Fixture = {
|
|
245
245
|
businesses: {
|
|
@@ -273,10 +273,10 @@ describe('Fixture Validation', () => {
|
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
it('should fail when document references non-existent debtor', () => {
|
|
276
|
-
const adminId = makeUUID('
|
|
277
|
-
const supplierId = makeUUID('
|
|
278
|
-
const chargeId = makeUUID('charge'
|
|
279
|
-
const nonExistentDebtorId = makeUUID('
|
|
276
|
+
const adminId = makeUUID('admin');
|
|
277
|
+
const supplierId = makeUUID('supplier');
|
|
278
|
+
const chargeId = makeUUID('charge');
|
|
279
|
+
const nonExistentDebtorId = makeUUID('non-existent-debtor');
|
|
280
280
|
|
|
281
281
|
const fixture: Fixture = {
|
|
282
282
|
businesses: {
|
|
@@ -310,7 +310,7 @@ describe('Fixture Validation', () => {
|
|
|
310
310
|
});
|
|
311
311
|
|
|
312
312
|
it('should fail when charge is missing owner_id', () => {
|
|
313
|
-
const chargeId = makeUUID('charge'
|
|
313
|
+
const chargeId = makeUUID('charge');
|
|
314
314
|
|
|
315
315
|
const fixture: Fixture = {
|
|
316
316
|
charges: {
|
|
@@ -337,8 +337,8 @@ describe('Fixture Validation', () => {
|
|
|
337
337
|
});
|
|
338
338
|
|
|
339
339
|
it('should fail when transaction is missing required fields', () => {
|
|
340
|
-
const adminId = makeUUID('
|
|
341
|
-
const chargeId = makeUUID('charge'
|
|
340
|
+
const adminId = makeUUID('admin');
|
|
341
|
+
const chargeId = makeUUID('charge');
|
|
342
342
|
|
|
343
343
|
const fixture: Fixture = {
|
|
344
344
|
businesses: {
|
|
@@ -350,10 +350,10 @@ describe('Fixture Validation', () => {
|
|
|
350
350
|
transactions: {
|
|
351
351
|
transactions: [
|
|
352
352
|
{
|
|
353
|
-
id: makeUUID('
|
|
354
|
-
account_id: makeUUID('account'
|
|
353
|
+
id: makeUUID('tx'),
|
|
354
|
+
account_id: makeUUID('account'),
|
|
355
355
|
charge_id: '', // Missing
|
|
356
|
-
source_id: makeUUID('source'
|
|
356
|
+
source_id: makeUUID('source'),
|
|
357
357
|
currency: '', // Missing
|
|
358
358
|
event_date: '', // Missing
|
|
359
359
|
amount: '', // Will be caught as missing
|
|
@@ -379,8 +379,8 @@ describe('Fixture Validation', () => {
|
|
|
379
379
|
});
|
|
380
380
|
|
|
381
381
|
it('should fail when document is missing required fields', () => {
|
|
382
|
-
const adminId = makeUUID('
|
|
383
|
-
const chargeId = makeUUID('charge'
|
|
382
|
+
const adminId = makeUUID('admin');
|
|
383
|
+
const chargeId = makeUUID('charge');
|
|
384
384
|
|
|
385
385
|
const fixture: Fixture = {
|
|
386
386
|
businesses: {
|
|
@@ -392,7 +392,7 @@ describe('Fixture Validation', () => {
|
|
|
392
392
|
documents: {
|
|
393
393
|
documents: [
|
|
394
394
|
{
|
|
395
|
-
id: makeUUID('
|
|
395
|
+
id: makeUUID('doc'),
|
|
396
396
|
charge_id: '', // Missing
|
|
397
397
|
creditor_id: '', // Missing
|
|
398
398
|
debtor_id: '', // Missing
|
|
@@ -430,7 +430,7 @@ describe('Fixture Validation', () => {
|
|
|
430
430
|
});
|
|
431
431
|
|
|
432
432
|
it('should detect duplicate business IDs', () => {
|
|
433
|
-
const duplicateId = makeUUID('
|
|
433
|
+
const duplicateId = makeUUID('duplicate-business');
|
|
434
434
|
|
|
435
435
|
const fixture: Fixture = {
|
|
436
436
|
businesses: {
|
|
@@ -449,8 +449,8 @@ describe('Fixture Validation', () => {
|
|
|
449
449
|
});
|
|
450
450
|
|
|
451
451
|
it('should detect duplicate charge IDs', () => {
|
|
452
|
-
const adminId = makeUUID('
|
|
453
|
-
const duplicateChargeId = makeUUID('
|
|
452
|
+
const adminId = makeUUID('admin');
|
|
453
|
+
const duplicateChargeId = makeUUID('duplicate-charge');
|
|
454
454
|
|
|
455
455
|
const fixture: Fixture = {
|
|
456
456
|
businesses: {
|
|
@@ -472,8 +472,8 @@ describe('Fixture Validation', () => {
|
|
|
472
472
|
});
|
|
473
473
|
|
|
474
474
|
it('should validate financial account owner reference', () => {
|
|
475
|
-
const nonExistentOwnerId = makeUUID('
|
|
476
|
-
const accountNumber = makeUUID('account'
|
|
475
|
+
const nonExistentOwnerId = makeUUID('non-existent-owner');
|
|
476
|
+
const accountNumber = makeUUID('account');
|
|
477
477
|
|
|
478
478
|
const fixture: Fixture = {
|
|
479
479
|
accounts: {
|
|
@@ -493,7 +493,7 @@ describe('Fixture Validation', () => {
|
|
|
493
493
|
});
|
|
494
494
|
|
|
495
495
|
it('should allow financial account without owner', () => {
|
|
496
|
-
const accountNumber = makeUUID('account'
|
|
496
|
+
const accountNumber = makeUUID('account');
|
|
497
497
|
|
|
498
498
|
const fixture: Fixture = {
|
|
499
499
|
accounts: {
|
|
@@ -508,9 +508,9 @@ describe('Fixture Validation', () => {
|
|
|
508
508
|
|
|
509
509
|
describe('assertValidFixture', () => {
|
|
510
510
|
it('should not throw for valid fixture', () => {
|
|
511
|
-
const adminId = makeUUID('
|
|
512
|
-
const chargeId = makeUUID('charge'
|
|
513
|
-
const taxCatId = makeUUID('tax-
|
|
511
|
+
const adminId = makeUUID('admin');
|
|
512
|
+
const chargeId = makeUUID('charge');
|
|
513
|
+
const taxCatId = makeUUID('tax-cat');
|
|
514
514
|
|
|
515
515
|
const fixture: Fixture = {
|
|
516
516
|
businesses: {
|
|
@@ -530,8 +530,8 @@ describe('Fixture Validation', () => {
|
|
|
530
530
|
});
|
|
531
531
|
|
|
532
532
|
it('should throw for invalid fixture with formatted error message', () => {
|
|
533
|
-
const nonExistentBusinessId = makeUUID('
|
|
534
|
-
const chargeId = makeUUID('charge'
|
|
533
|
+
const nonExistentBusinessId = makeUUID('non-existent-business');
|
|
534
|
+
const chargeId = makeUUID('charge');
|
|
535
535
|
|
|
536
536
|
const fixture: Fixture = {
|
|
537
537
|
charges: {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { expect } from 'vitest';
|
|
2
|
+
// Adjusted relative path: helper is one directory deeper than scenario tests
|
|
3
|
+
import { makeUUID } from '../../../../__tests__/factories/ids.js';
|
|
2
4
|
|
|
3
5
|
// Minimal ledger record type based on DB result interface
|
|
4
6
|
export interface LedgerRecord {
|
|
@@ -241,6 +243,9 @@ export function assertExpenseScenarioLogic(records: LedgerRecord[], opts: {
|
|
|
241
243
|
});
|
|
242
244
|
}
|
|
243
245
|
|
|
246
|
+
/** Helper to prepare deterministic UUID sets for known fixture aliases */
|
|
247
|
+
export function fixtureUUID(alias: string): string { return makeUUID(alias); }
|
|
248
|
+
|
|
244
249
|
/** Combined high-level assertion for typical simple local expense scenario */
|
|
245
250
|
export function assertSimpleLocalExpenseScenario(records: LedgerRecord[], params: {
|
|
246
251
|
chargeId: string;
|
|
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
|
|
|
2
2
|
import { TestDatabase } from '../../../__tests__/helpers/db-setup.js';
|
|
3
3
|
import { insertFixture } from '../../../__tests__/helpers/fixture-loader.js';
|
|
4
4
|
import { expenseScenarioA } from '../../../__tests__/fixtures/expenses/expense-scenario-a.js';
|
|
5
|
-
import { makeUUID } from '../../../
|
|
5
|
+
import { makeUUID } from '../../../__tests__/factories/ids.js';
|
|
6
6
|
import { qualifyTable } from '../../../__tests__/helpers/test-db-config.js';
|
|
7
7
|
import { buildAdminContextFromDb } from '../../../__tests__/helpers/admin-context-builder.js';
|
|
8
8
|
import { env } from '../../../environment.js';
|
|
@@ -43,7 +43,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
43
43
|
afterEach(async () => {
|
|
44
44
|
const client = await db.getPool().connect();
|
|
45
45
|
try {
|
|
46
|
-
const chargeId = makeUUID('charge
|
|
46
|
+
const chargeId = makeUUID('charge-office-supplies');
|
|
47
47
|
await client.query(
|
|
48
48
|
`DELETE FROM ${qualifyTable('ledger_records')} WHERE charge_id = $1`,
|
|
49
49
|
[chargeId],
|
|
@@ -65,7 +65,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
65
65
|
await client.query(
|
|
66
66
|
`DELETE FROM ${qualifyTable('financial_accounts_tax_categories')}
|
|
67
67
|
WHERE tax_category_id IN ($1, $2)`,
|
|
68
|
-
[makeUUID('
|
|
68
|
+
[makeUUID('expense-general'), makeUUID('bank-account-tax-category')],
|
|
69
69
|
);
|
|
70
70
|
await client.query(
|
|
71
71
|
`DELETE FROM ${qualifyTable('financial_accounts')} WHERE account_number = $1`,
|
|
@@ -73,19 +73,19 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
73
73
|
);
|
|
74
74
|
await client.query(
|
|
75
75
|
`DELETE FROM ${qualifyTable('tax_categories')} WHERE id IN ($1, $2)`,
|
|
76
|
-
[makeUUID('
|
|
76
|
+
[makeUUID('expense-general'), makeUUID('bank-account-tax-category')],
|
|
77
77
|
);
|
|
78
78
|
await client.query(
|
|
79
79
|
`DELETE FROM ${qualifyTable('businesses')} WHERE id IN ($1, $2)`,
|
|
80
|
-
[makeUUID('
|
|
80
|
+
[makeUUID('admin-business'), makeUUID('supplier-local-ltd')],
|
|
81
81
|
);
|
|
82
82
|
await client.query(
|
|
83
83
|
`DELETE FROM ${qualifyTable('financial_entities')} WHERE id IN ($1, $2, $3, $4)`,
|
|
84
84
|
[
|
|
85
|
-
makeUUID('
|
|
86
|
-
makeUUID('
|
|
87
|
-
makeUUID('
|
|
88
|
-
makeUUID('
|
|
85
|
+
makeUUID('admin-business'),
|
|
86
|
+
makeUUID('supplier-local-ltd'),
|
|
87
|
+
makeUUID('expense-general'),
|
|
88
|
+
makeUUID('bank-account-tax-category'),
|
|
89
89
|
],
|
|
90
90
|
);
|
|
91
91
|
} finally {
|
|
@@ -101,7 +101,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
101
101
|
|
|
102
102
|
await insertFixture(insertClient, expenseScenarioA);
|
|
103
103
|
|
|
104
|
-
const chargeId = makeUUID('charge
|
|
104
|
+
const chargeId = makeUUID('charge-office-supplies');
|
|
105
105
|
|
|
106
106
|
// Verify inserts within the same transaction
|
|
107
107
|
const chargeResult = await insertClient.query(
|
|
@@ -137,7 +137,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
137
137
|
// Re-open a new client (outside prior transaction) for verification & generation
|
|
138
138
|
const client = await db.getPool().connect();
|
|
139
139
|
try {
|
|
140
|
-
const chargeId = makeUUID('charge
|
|
140
|
+
const chargeId = makeUUID('charge-office-supplies');
|
|
141
141
|
const chargeResult = await client.query(
|
|
142
142
|
`SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
|
|
143
143
|
[chargeId],
|
|
@@ -192,8 +192,8 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
192
192
|
assertSimpleLocalExpenseScenario(ledgerResult.rows as any, {
|
|
193
193
|
chargeId: charge.id,
|
|
194
194
|
ownerId: charge.owner_id, // Use actual charge owner for ledger record owner assertions
|
|
195
|
-
expenseEntity: makeUUID('
|
|
196
|
-
bankEntity: makeUUID('
|
|
195
|
+
expenseEntity: makeUUID('expense-general'),
|
|
196
|
+
bankEntity: makeUUID('bank-account-tax-category'),
|
|
197
197
|
expectedCurrency: Currency.Ils,
|
|
198
198
|
expectedTotal: ledgerExpectation?.totalDebitLocal || 500.0,
|
|
199
199
|
});
|
|
@@ -212,7 +212,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
212
212
|
it('should be idempotent on repeated ledger generation (no duplicate records)', async () => {
|
|
213
213
|
const client = await db.getPool().connect();
|
|
214
214
|
try {
|
|
215
|
-
const chargeId = makeUUID('charge
|
|
215
|
+
const chargeId = makeUUID('charge-office-supplies');
|
|
216
216
|
// Ensure fixture inserted (if previous test did cleanup, reinsert minimal fixture)
|
|
217
217
|
const existingCharge = await client.query(
|
|
218
218
|
`SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
|
|
@@ -296,7 +296,7 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
296
296
|
expect(expenseScenarioA.expectations?.ledger).toHaveLength(1);
|
|
297
297
|
|
|
298
298
|
const ledgerExpectation = expenseScenarioA.expectations?.ledger?.[0];
|
|
299
|
-
expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge
|
|
299
|
+
expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge-office-supplies'));
|
|
300
300
|
expect(ledgerExpectation?.recordCount).toBe(2);
|
|
301
301
|
expect(ledgerExpectation?.balanced).toBe(true);
|
|
302
302
|
expect(ledgerExpectation?.totalDebitLocal).toBe(500.0);
|
|
@@ -307,11 +307,11 @@ describe('Ledger Generation - Expense Scenario A', () => {
|
|
|
307
307
|
|
|
308
308
|
it('should create deterministic UUIDs for reproducible tests', () => {
|
|
309
309
|
// Verify all IDs are deterministic and match expected values
|
|
310
|
-
const adminBusinessId = makeUUID('
|
|
311
|
-
const supplierId = makeUUID('
|
|
312
|
-
const chargeId = makeUUID('charge
|
|
313
|
-
const transactionId = makeUUID('transaction
|
|
314
|
-
const documentId = makeUUID('document
|
|
310
|
+
const adminBusinessId = makeUUID('admin-business');
|
|
311
|
+
const supplierId = makeUUID('supplier-local-ltd');
|
|
312
|
+
const chargeId = makeUUID('charge-office-supplies');
|
|
313
|
+
const transactionId = makeUUID('transaction-supplies-payment');
|
|
314
|
+
const documentId = makeUUID('document-supplies-receipt');
|
|
315
315
|
|
|
316
316
|
expect(adminBusinessId).toBe(expenseScenarioA.businesses?.businesses[0]?.id);
|
|
317
317
|
expect(supplierId).toBe(expenseScenarioA.businesses?.businesses[1]?.id);
|
|
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
|
|
|
2
2
|
import { TestDatabase } from '../../../__tests__/helpers/db-setup.js';
|
|
3
3
|
import { insertFixture } from '../../../__tests__/helpers/fixture-loader.js';
|
|
4
4
|
import { expenseScenarioB } from '../../../__tests__/fixtures/expenses/expense-scenario-b.js';
|
|
5
|
-
import { makeUUID } from '../../../
|
|
5
|
+
import { makeUUID } from '../../../__tests__/factories/ids.js';
|
|
6
6
|
import { qualifyTable } from '../../../__tests__/helpers/test-db-config.js';
|
|
7
7
|
import { buildAdminContextFromDb } from '../../../__tests__/helpers/admin-context-builder.js';
|
|
8
8
|
import { mockExchangeRate } from '../../../__tests__/helpers/exchange-mock.js';
|
|
@@ -48,7 +48,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
48
48
|
afterEach(async () => {
|
|
49
49
|
const client = await db.getPool().connect();
|
|
50
50
|
try {
|
|
51
|
-
const chargeId = makeUUID('charge
|
|
51
|
+
const chargeId = makeUUID('charge-consulting-services');
|
|
52
52
|
await client.query(
|
|
53
53
|
`DELETE FROM ${qualifyTable('ledger_records')} WHERE charge_id = $1`,
|
|
54
54
|
[chargeId],
|
|
@@ -70,7 +70,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
70
70
|
await client.query(
|
|
71
71
|
`DELETE FROM ${qualifyTable('financial_accounts_tax_categories')}
|
|
72
72
|
WHERE tax_category_id IN ($1, $2)`,
|
|
73
|
-
[makeUUID('
|
|
73
|
+
[makeUUID('expense-consulting'), makeUUID('usd-account-tax-category')],
|
|
74
74
|
);
|
|
75
75
|
await client.query(
|
|
76
76
|
`DELETE FROM ${qualifyTable('financial_accounts')} WHERE account_number = $1`,
|
|
@@ -78,19 +78,19 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
78
78
|
);
|
|
79
79
|
await client.query(
|
|
80
80
|
`DELETE FROM ${qualifyTable('tax_categories')} WHERE id IN ($1, $2)`,
|
|
81
|
-
[makeUUID('
|
|
81
|
+
[makeUUID('expense-consulting'), makeUUID('usd-account-tax-category')],
|
|
82
82
|
);
|
|
83
83
|
await client.query(
|
|
84
84
|
`DELETE FROM ${qualifyTable('businesses')} WHERE id IN ($1, $2)`,
|
|
85
|
-
[makeUUID('
|
|
85
|
+
[makeUUID('admin-business-usd'), makeUUID('supplier-us-vendor-llc')],
|
|
86
86
|
);
|
|
87
87
|
await client.query(
|
|
88
88
|
`DELETE FROM ${qualifyTable('financial_entities')} WHERE id IN ($1, $2, $3, $4)`,
|
|
89
89
|
[
|
|
90
|
-
makeUUID('
|
|
91
|
-
makeUUID('
|
|
92
|
-
makeUUID('
|
|
93
|
-
makeUUID('
|
|
90
|
+
makeUUID('admin-business-usd'),
|
|
91
|
+
makeUUID('supplier-us-vendor-llc'),
|
|
92
|
+
makeUUID('expense-consulting'),
|
|
93
|
+
makeUUID('usd-account-tax-category'),
|
|
94
94
|
],
|
|
95
95
|
);
|
|
96
96
|
} finally {
|
|
@@ -106,7 +106,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
106
106
|
|
|
107
107
|
await insertFixture(insertClient, expenseScenarioB);
|
|
108
108
|
|
|
109
|
-
const chargeId = makeUUID('charge
|
|
109
|
+
const chargeId = makeUUID('charge-consulting-services');
|
|
110
110
|
|
|
111
111
|
// Verify inserts within the same transaction
|
|
112
112
|
const chargeResult = await insertClient.query(
|
|
@@ -143,7 +143,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
143
143
|
// Re-open a new client (outside prior transaction) for verification & generation
|
|
144
144
|
const client = await db.getPool().connect();
|
|
145
145
|
try {
|
|
146
|
-
const chargeId = makeUUID('charge
|
|
146
|
+
const chargeId = makeUUID('charge-consulting-services');
|
|
147
147
|
const chargeResult = await client.query(
|
|
148
148
|
`SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
|
|
149
149
|
[chargeId],
|
|
@@ -200,8 +200,8 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
200
200
|
assertForeignExpenseScenario(ledgerResult.rows as any, {
|
|
201
201
|
chargeId: charge.id,
|
|
202
202
|
ownerId: charge.owner_id, // Use actual charge owner id
|
|
203
|
-
expenseEntity: makeUUID('
|
|
204
|
-
bankEntity: makeUUID('
|
|
203
|
+
expenseEntity: makeUUID('expense-consulting'),
|
|
204
|
+
bankEntity: makeUUID('usd-account-tax-category'),
|
|
205
205
|
expectedCurrency: Currency.Usd,
|
|
206
206
|
expectedForeignAmount: ledgerExpectation?.foreignAmount || 200.0,
|
|
207
207
|
expectedRate: ledgerExpectation?.exchangeRate || 3.5,
|
|
@@ -222,7 +222,7 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
222
222
|
it('should be idempotent on repeated foreign ledger generation (no duplicate records)', async () => {
|
|
223
223
|
const client = await db.getPool().connect();
|
|
224
224
|
try {
|
|
225
|
-
const chargeId = makeUUID('charge
|
|
225
|
+
const chargeId = makeUUID('charge-consulting-services');
|
|
226
226
|
// Ensure fixture inserted if absent
|
|
227
227
|
const existingCharge = await client.query(
|
|
228
228
|
`SELECT * FROM ${qualifyTable('charges')} WHERE id = $1`,
|
|
@@ -310,14 +310,14 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
310
310
|
const accountMapping = expenseScenarioB.accountTaxCategories?.mappings[0];
|
|
311
311
|
expect(accountMapping?.accountNumber).toBe('USD-ACCOUNT-001');
|
|
312
312
|
expect(accountMapping?.currency).toBe(Currency.Usd);
|
|
313
|
-
expect(accountMapping?.taxCategoryId).toBe(makeUUID('
|
|
313
|
+
expect(accountMapping?.taxCategoryId).toBe(makeUUID('usd-account-tax-category'));
|
|
314
314
|
|
|
315
315
|
// Verify expectations are defined
|
|
316
316
|
expect(expenseScenarioB.expectations).toBeDefined();
|
|
317
317
|
expect(expenseScenarioB.expectations?.ledger).toHaveLength(1);
|
|
318
318
|
|
|
319
319
|
const ledgerExpectation = expenseScenarioB.expectations?.ledger?.[0];
|
|
320
|
-
expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge
|
|
320
|
+
expect(ledgerExpectation?.chargeId).toBe(makeUUID('charge-consulting-services'));
|
|
321
321
|
expect(ledgerExpectation?.recordCount).toBe(2);
|
|
322
322
|
expect(ledgerExpectation?.balanced).toBe(true);
|
|
323
323
|
expect(ledgerExpectation?.totalDebitLocal).toBe(1400.0);
|
|
@@ -331,11 +331,11 @@ describe('Ledger Generation - Expense Scenario B (Foreign Currency)', () => {
|
|
|
331
331
|
|
|
332
332
|
it('should create deterministic UUIDs for reproducible tests', () => {
|
|
333
333
|
// Verify all IDs are deterministic and match expected values
|
|
334
|
-
const adminBusinessId = makeUUID('
|
|
335
|
-
const supplierId = makeUUID('
|
|
336
|
-
const chargeId = makeUUID('charge
|
|
337
|
-
const transactionId = makeUUID('transaction
|
|
338
|
-
const documentId = makeUUID('document
|
|
334
|
+
const adminBusinessId = makeUUID('admin-business-usd');
|
|
335
|
+
const supplierId = makeUUID('supplier-us-vendor-llc');
|
|
336
|
+
const chargeId = makeUUID('charge-consulting-services');
|
|
337
|
+
const transactionId = makeUUID('transaction-consulting-payment');
|
|
338
|
+
const documentId = makeUUID('document-consulting-invoice');
|
|
339
339
|
|
|
340
340
|
expect(adminBusinessId).toBe(expenseScenarioB.businesses?.businesses[0]?.id);
|
|
341
341
|
expect(supplierId).toBe(expenseScenarioB.businesses?.businesses[1]?.id);
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { makeUUID } from '../helpers/deterministic-uuid.js';
|
|
3
|
-
describe('deterministic-uuid', () => {
|
|
4
|
-
describe('makeUUID', () => {
|
|
5
|
-
it('generates same UUID for same inputs', () => {
|
|
6
|
-
const uuid1 = makeUUID('business', 'acme-consulting-llc');
|
|
7
|
-
const uuid2 = makeUUID('business', 'acme-consulting-llc');
|
|
8
|
-
expect(uuid1).toBe(uuid2);
|
|
9
|
-
expect(uuid1).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
|
|
10
|
-
});
|
|
11
|
-
it('generates different UUIDs for different names', () => {
|
|
12
|
-
const uuid1 = makeUUID('business', 'acme-llc');
|
|
13
|
-
const uuid2 = makeUUID('business', 'acme-corp');
|
|
14
|
-
expect(uuid1).not.toBe(uuid2);
|
|
15
|
-
});
|
|
16
|
-
it('generates different UUIDs for different namespaces', () => {
|
|
17
|
-
const businessUUID = makeUUID('business', 'acme');
|
|
18
|
-
const chargeUUID = makeUUID('charge', 'acme');
|
|
19
|
-
expect(businessUUID).not.toBe(chargeUUID);
|
|
20
|
-
});
|
|
21
|
-
it('includes namespace in composite key', () => {
|
|
22
|
-
// Same name, different namespace types
|
|
23
|
-
const bizUUID = makeUUID('business', 'test-entity');
|
|
24
|
-
const transactionUUID = makeUUID('transaction', 'test-entity');
|
|
25
|
-
const documentUUID = makeUUID('document', 'test-entity');
|
|
26
|
-
expect(bizUUID).not.toBe(transactionUUID);
|
|
27
|
-
expect(bizUUID).not.toBe(documentUUID);
|
|
28
|
-
expect(transactionUUID).not.toBe(documentUUID);
|
|
29
|
-
});
|
|
30
|
-
it('generates valid UUID v5 format', () => {
|
|
31
|
-
const uuid = makeUUID('charge', 'monthly-invoice-2024-11');
|
|
32
|
-
// UUID v5 format: xxxxxxxx-xxxx-5xxx-yxxx-xxxxxxxxxxxx
|
|
33
|
-
// where y is one of [8, 9, a, b]
|
|
34
|
-
expect(uuid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
|
|
35
|
-
});
|
|
36
|
-
it('handles kebab-case names correctly', () => {
|
|
37
|
-
const uuid1 = makeUUID('business', 'us-supplier-acme-llc');
|
|
38
|
-
const uuid2 = makeUUID('business', 'us-supplier-acme-llc');
|
|
39
|
-
expect(uuid1).toBe(uuid2);
|
|
40
|
-
});
|
|
41
|
-
it('handles numeric components in names', () => {
|
|
42
|
-
const uuid1 = makeUUID('charge', 'invoice-2024-11-15');
|
|
43
|
-
const uuid2 = makeUUID('charge', 'invoice-2024-11-15');
|
|
44
|
-
expect(uuid1).toBe(uuid2);
|
|
45
|
-
});
|
|
46
|
-
it('is case-sensitive for names', () => {
|
|
47
|
-
const uuid1 = makeUUID('business', 'acme-llc');
|
|
48
|
-
const uuid2 = makeUUID('business', 'ACME-LLC');
|
|
49
|
-
expect(uuid1).not.toBe(uuid2);
|
|
50
|
-
});
|
|
51
|
-
it('is case-sensitive for namespaces', () => {
|
|
52
|
-
const uuid1 = makeUUID('business', 'acme');
|
|
53
|
-
const uuid2 = makeUUID('Business', 'acme');
|
|
54
|
-
expect(uuid1).not.toBe(uuid2);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=deterministic-uuid.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deterministic-uuid.test.js","sourceRoot":"","sources":["../../../../../src/demo-fixtures/__tests__/deterministic-uuid.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate deterministic UUID v5 from semantic name.
|
|
3
|
-
*
|
|
4
|
-
* This function creates stable, reproducible UUIDs for demo/staging data entities.
|
|
5
|
-
* The same namespace + name combination will always produce the same UUID across
|
|
6
|
-
* deployments, making it safe to reference these IDs in documentation, screenshots,
|
|
7
|
-
* and external links.
|
|
8
|
-
*
|
|
9
|
-
* @param namespace - Entity type: 'business', 'charge', 'transaction', 'document', etc.
|
|
10
|
-
* @param name - Semantic identifier (kebab-case recommended)
|
|
11
|
-
* @returns UUID v5 string (e.g., '550e8400-e29b-41d4-a716-446655440000')
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Business entity
|
|
16
|
-
* makeUUID('business', 'acme-consulting-llc')
|
|
17
|
-
* // => Always produces same UUID
|
|
18
|
-
*
|
|
19
|
-
* // Charge entity
|
|
20
|
-
* makeUUID('charge', 'consulting-invoice-2024-11')
|
|
21
|
-
* // => Stable across deploys
|
|
22
|
-
*
|
|
23
|
-
* // Financial account
|
|
24
|
-
* makeUUID('financial-account', 'bank-usd-account')
|
|
25
|
-
* // => Different from makeUUID('business', 'bank-usd-account')
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* **Naming Conventions:**
|
|
30
|
-
* - Use kebab-case for all semantic names
|
|
31
|
-
* - Combine entity type + descriptive name ensures no collisions
|
|
32
|
-
* - Never change a semantic name once deployed (breaks external links)
|
|
33
|
-
* - For updates to same entity, append version: `acme-consulting-llc-v2`
|
|
34
|
-
*
|
|
35
|
-
* **Stability Warning:**
|
|
36
|
-
* Once a UUID is generated and used in staging/production, the semantic name
|
|
37
|
-
* MUST NOT be changed. Doing so will generate a different UUID and break:
|
|
38
|
-
* - External documentation with embedded links
|
|
39
|
-
* - Screenshots with visible UUIDs
|
|
40
|
-
* - Any hardcoded references in client applications
|
|
41
|
-
*
|
|
42
|
-
* If you need to modify an entity, create a new semantic name with a version suffix.
|
|
43
|
-
*/
|
|
44
|
-
export declare function makeUUID(namespace: string, name: string): string;
|
|
45
|
-
/**
|
|
46
|
-
* Backward compatible adapter for legacy single-argument API.
|
|
47
|
-
* - When seed is provided, returns deterministic UUID v5 scoped under 'legacy' namespace
|
|
48
|
-
* - When seed omitted, returns a random UUID to preserve previous behavior
|
|
49
|
-
*/
|
|
50
|
-
export declare function makeUUIDLegacy(seed?: string): string;
|