@accounter/server 0.0.9-alpha-20251211033737-29a3e4c4c745e562726ab60c423e6cedd9e22c44 → 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.
- package/CHANGELOG.md +5 -5
- package/dist/server/src/__tests__/factories/charge.d.ts +3 -1
- package/dist/server/src/__tests__/factories/charge.js +2 -1
- package/dist/server/src/__tests__/factories/charge.js.map +1 -1
- package/dist/server/src/__tests__/factories/transaction.d.ts +3 -1
- package/dist/server/src/__tests__/factories/transaction.js +1 -0
- package/dist/server/src/__tests__/factories/transaction.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-loader.d.ts +7 -3
- package/dist/server/src/__tests__/helpers/fixture-loader.js +28 -20
- package/dist/server/src/__tests__/helpers/fixture-loader.js.map +1 -1
- package/dist/server/src/__tests__/helpers/fixture-types.d.ts +1 -3
- package/dist/server/src/modules/ledger/__tests__/helpers/ledger-assertions.js +4 -4
- package/package.json +2 -2
- package/src/__tests__/factories/charge.ts +4 -2
- package/src/__tests__/factories/transaction.ts +3 -1
- package/src/__tests__/helpers/fixture-loader.ts +30 -22
- package/src/__tests__/helpers/fixture-types.ts +1 -3
- package/src/modules/ledger/__tests__/helpers/ledger-assertions.ts +4 -5
- package/src/modules/ledger/__tests__/ledger-scenario-a.integration.test.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @accounter/server
|
|
2
2
|
|
|
3
|
-
## 0.0.9-alpha-
|
|
3
|
+
## 0.0.9-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -304,10 +304,10 @@
|
|
|
304
304
|
[`ef68321`](https://github.com/Urigo/accounter-fullstack/commit/ef68321608d60a7208e82a2c413f27beb502e3cc),
|
|
305
305
|
[`ef68321`](https://github.com/Urigo/accounter-fullstack/commit/ef68321608d60a7208e82a2c413f27beb502e3cc),
|
|
306
306
|
[`c7d6f21`](https://github.com/Urigo/accounter-fullstack/commit/c7d6f21ed62658159b1323334501daca03c8d3e5)]:
|
|
307
|
-
- @accounter/green-invoice-graphql@0.8.3-alpha-
|
|
308
|
-
- @accounter/pcn874-generator@0.6.4-alpha-
|
|
309
|
-
- @accounter/shaam-uniform-format-generator@0.2.3-alpha-
|
|
310
|
-
- @accounter/shaam6111-generator@0.1.5-alpha-
|
|
307
|
+
- @accounter/green-invoice-graphql@0.8.3-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e
|
|
308
|
+
- @accounter/pcn874-generator@0.6.4-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e
|
|
309
|
+
- @accounter/shaam-uniform-format-generator@0.2.3-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e
|
|
310
|
+
- @accounter/shaam6111-generator@0.1.5-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e
|
|
311
311
|
|
|
312
312
|
## 0.0.8
|
|
313
313
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Based on charges table schema from migrations and charges.provider.ts:
|
|
7
7
|
* - Required: owner_id
|
|
8
|
-
* - Optional: type, accountant_status, user_description, tax_category_id, optional_vat, documents_optional_flag
|
|
8
|
+
* - Optional: type, accountant_status, user_description, tax_category_id, optional_vat, documents_optional_flag, is_property
|
|
9
9
|
*
|
|
10
10
|
* @see packages/server/src/modules/charges/providers/charges.provider.ts (generateCharge query)
|
|
11
11
|
* @see packages/migrations/src/actions/*-charges-*.ts (migrations)
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
export interface ChargeInsertParams {
|
|
20
20
|
id?: string;
|
|
21
21
|
owner_id: string;
|
|
22
|
+
is_property?: boolean | null;
|
|
22
23
|
type?: string | null;
|
|
23
24
|
accountant_status?: string | null;
|
|
24
25
|
user_description?: string | null;
|
|
@@ -41,6 +42,7 @@ export interface ChargeInsertParams {
|
|
|
41
42
|
* - accountant_status defaults to 'PENDING' (database requires NOT NULL)
|
|
42
43
|
* - optional_vat defaults to false (database requires NOT NULL)
|
|
43
44
|
* - documents_optional_flag defaults to false (database requires NOT NULL)
|
|
45
|
+
* - is_property defaults to null (property-related charges can override to true)
|
|
44
46
|
* - id defaults to deterministic UUID if not provided
|
|
45
47
|
*
|
|
46
48
|
* @example
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Based on charges table schema from migrations and charges.provider.ts:
|
|
7
7
|
* - Required: owner_id
|
|
8
|
-
* - Optional: type, accountant_status, user_description, tax_category_id, optional_vat, documents_optional_flag
|
|
8
|
+
* - Optional: type, accountant_status, user_description, tax_category_id, optional_vat, documents_optional_flag, is_property
|
|
9
9
|
*
|
|
10
10
|
* @see packages/server/src/modules/charges/providers/charges.provider.ts (generateCharge query)
|
|
11
11
|
* @see packages/migrations/src/actions/*-charges-*.ts (migrations)
|
|
@@ -26,6 +26,7 @@ import { makeUUID, makeUUIDLegacy } from '../../demo-fixtures/helpers/determinis
|
|
|
26
26
|
* - accountant_status defaults to 'PENDING' (database requires NOT NULL)
|
|
27
27
|
* - optional_vat defaults to false (database requires NOT NULL)
|
|
28
28
|
* - documents_optional_flag defaults to false (database requires NOT NULL)
|
|
29
|
+
* - is_property defaults to null (property-related charges can override to true)
|
|
29
30
|
* - id defaults to deterministic UUID if not provided
|
|
30
31
|
*
|
|
31
32
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charge.js","sourceRoot":"","sources":["../../../../../src/__tests__/factories/charge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"charge.js","sourceRoot":"","sources":["../../../../../src/__tests__/factories/charge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAoB7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,UAAU,YAAY,CAC1B,MAIC,EACD,SAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,cAAc,EAAE;QACpB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,IAAI;QACV,iBAAiB,EAAE,SAAS;QAC5B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,IAAI;QACjD,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;QAC3F,YAAY,EAAE,KAAK;QACnB,uBAAuB,EAAE,KAAK;QAC9B,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -27,9 +27,10 @@ export interface TransactionInsertParams {
|
|
|
27
27
|
event_date: string;
|
|
28
28
|
debit_date?: string | null;
|
|
29
29
|
amount: string;
|
|
30
|
-
current_balance
|
|
30
|
+
current_balance?: string;
|
|
31
31
|
business_id?: string | null;
|
|
32
32
|
is_fee?: boolean | null;
|
|
33
|
+
currency_rate?: number | null;
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Create a transaction for test fixtures
|
|
@@ -45,6 +46,7 @@ export interface TransactionInsertParams {
|
|
|
45
46
|
* - currency is required (e.g., 'ILS', 'USD', 'EUR')
|
|
46
47
|
* - event_date is required (transaction date)
|
|
47
48
|
* - is_fee defaults to false (regular transaction, not a fee)
|
|
49
|
+
* - currency_rate defaults to null (foreign currency transactions can specify exchange rate)
|
|
48
50
|
* - account_id defaults to deterministic UUID if not provided
|
|
49
51
|
* - source_id defaults to deterministic UUID (raw transaction reference)
|
|
50
52
|
* - source_description defaults to null
|
|
@@ -25,6 +25,7 @@ import { formatNumeric } from './money.js';
|
|
|
25
25
|
* - currency is required (e.g., 'ILS', 'USD', 'EUR')
|
|
26
26
|
* - event_date is required (transaction date)
|
|
27
27
|
* - is_fee defaults to false (regular transaction, not a fee)
|
|
28
|
+
* - currency_rate defaults to null (foreign currency transactions can specify exchange rate)
|
|
28
29
|
* - account_id defaults to deterministic UUID if not provided
|
|
29
30
|
* - source_id defaults to deterministic UUID (raw transaction reference)
|
|
30
31
|
* - source_description defaults to null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../../../src/__tests__/factories/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../../../src/__tests__/factories/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA0B3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAOC,EACD,SAA4C;IAE5C,OAAO;QACL,EAAE,EAAE,cAAc,EAAE;QACpB,UAAU,EAAE,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;QAClD,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,QAAQ,CAAC,oBAAoB,EAAE,eAAe,CAAC;QAC1D,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EACR,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,UAAU;YACnB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QAClD,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QACxF,eAAe,EAAE,GAAG;QACpB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;QAC9B,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see packages/server/src/__tests__/helpers/fixture-types.ts for fixture structure
|
|
8
8
|
* @see packages/server/src/__tests__/helpers/fixture-validation.ts for validation logic
|
|
9
9
|
*/
|
|
10
|
-
import type { PoolClient } from 'pg';
|
|
10
|
+
import type { Client, PoolClient } from 'pg';
|
|
11
11
|
import type { Fixture } from './fixture-types.js';
|
|
12
12
|
/**
|
|
13
13
|
* Custom error for fixture insertion failures
|
|
@@ -67,12 +67,16 @@ export type FixtureIdMapping = Map<string, string>;
|
|
|
67
67
|
* - Checks referential integrity (charge IDs, business IDs, etc.)
|
|
68
68
|
* - Validates required fields
|
|
69
69
|
*
|
|
70
|
-
* @param client - PostgreSQL client within an active transaction
|
|
70
|
+
* @param client - PostgreSQL client (PoolClient or standalone Client) within an active transaction
|
|
71
71
|
* @param fixture - Complete fixture to insert
|
|
72
72
|
* @returns Promise resolving to ID mapping (fixture ID → database ID)
|
|
73
73
|
* @throws {Error} If fixture validation fails (via assertValidFixture)
|
|
74
74
|
* @throws {FixtureInsertionError} If any insertion section fails
|
|
75
75
|
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* Type Safety: Accepts both PoolClient and Client to support both test transactions
|
|
78
|
+
* (pool.connect()) and standalone connections (new pg.Client()) used in seed scripts.
|
|
79
|
+
*
|
|
76
80
|
* @example
|
|
77
81
|
* ```typescript
|
|
78
82
|
* import { withTestTransaction } from './test-transaction.js';
|
|
@@ -93,4 +97,4 @@ export type FixtureIdMapping = Map<string, string>;
|
|
|
93
97
|
* );
|
|
94
98
|
* ```
|
|
95
99
|
*/
|
|
96
|
-
export declare function insertFixture(client: PoolClient, fixture: Fixture): Promise<FixtureIdMapping>;
|
|
100
|
+
export declare function insertFixture(client: PoolClient | Client, fixture: Fixture): Promise<FixtureIdMapping>;
|
|
@@ -70,12 +70,16 @@ export class FixtureInsertionError extends Error {
|
|
|
70
70
|
* - Checks referential integrity (charge IDs, business IDs, etc.)
|
|
71
71
|
* - Validates required fields
|
|
72
72
|
*
|
|
73
|
-
* @param client - PostgreSQL client within an active transaction
|
|
73
|
+
* @param client - PostgreSQL client (PoolClient or standalone Client) within an active transaction
|
|
74
74
|
* @param fixture - Complete fixture to insert
|
|
75
75
|
* @returns Promise resolving to ID mapping (fixture ID → database ID)
|
|
76
76
|
* @throws {Error} If fixture validation fails (via assertValidFixture)
|
|
77
77
|
* @throws {FixtureInsertionError} If any insertion section fails
|
|
78
78
|
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Type Safety: Accepts both PoolClient and Client to support both test transactions
|
|
81
|
+
* (pool.connect()) and standalone connections (new pg.Client()) used in seed scripts.
|
|
82
|
+
*
|
|
79
83
|
* @example
|
|
80
84
|
* ```typescript
|
|
81
85
|
* import { withTestTransaction } from './test-transaction.js';
|
|
@@ -140,13 +144,13 @@ export async function insertFixture(client, fixture) {
|
|
|
140
144
|
business.website,
|
|
141
145
|
business.phoneNumber,
|
|
142
146
|
business.governmentId, // Maps to vat_number column
|
|
143
|
-
business.exemptDealer,
|
|
144
|
-
business.suggestions,
|
|
145
|
-
business.optionalVat,
|
|
146
|
-
business.country,
|
|
147
|
-
business.pcn874RecordTypeOverride,
|
|
148
|
-
business.isReceiptEnough,
|
|
149
|
-
business.isDocumentsOptional,
|
|
147
|
+
business.exemptDealer ?? false,
|
|
148
|
+
business.suggestions ?? null,
|
|
149
|
+
business.optionalVat ?? false,
|
|
150
|
+
business.country ?? 'ISR',
|
|
151
|
+
business.pcn874RecordTypeOverride ?? null,
|
|
152
|
+
business.isReceiptEnough ?? false,
|
|
153
|
+
business.isDocumentsOptional ?? false,
|
|
150
154
|
]);
|
|
151
155
|
if (entityResult.rows.length > 0) {
|
|
152
156
|
idMapping.set(business.id, entityResult.rows[0].id);
|
|
@@ -172,7 +176,7 @@ export async function insertFixture(client, fixture) {
|
|
|
172
176
|
id, hashavshevet_name, tax_excluded
|
|
173
177
|
)
|
|
174
178
|
VALUES ($1, $2, $3)
|
|
175
|
-
ON CONFLICT (id) DO NOTHING`, [taxCategory.id, taxCategory.hashavshevetName, taxCategory.taxExcluded]);
|
|
179
|
+
ON CONFLICT (id) DO NOTHING`, [taxCategory.id, taxCategory.hashavshevetName, taxCategory.taxExcluded ?? false]);
|
|
176
180
|
if (entityResult.rows.length > 0) {
|
|
177
181
|
idMapping.set(taxCategory.id, entityResult.rows[0].id);
|
|
178
182
|
}
|
|
@@ -235,18 +239,20 @@ export async function insertFixture(client, fixture) {
|
|
|
235
239
|
for (const charge of fixture.charges.charges) {
|
|
236
240
|
await client.query(`INSERT INTO ${qualifyTable('charges')} (
|
|
237
241
|
id, owner_id, type, accountant_status, user_description,
|
|
238
|
-
tax_category_id, optional_vat, documents_optional_flag
|
|
242
|
+
tax_category_id, optional_vat, documents_optional_flag,
|
|
243
|
+
is_property, created_at, updated_at
|
|
239
244
|
)
|
|
240
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
245
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, NOW(), NOW())
|
|
241
246
|
ON CONFLICT (id) DO NOTHING`, [
|
|
242
247
|
charge.id,
|
|
243
248
|
charge.owner_id,
|
|
244
|
-
charge.type,
|
|
245
|
-
charge.accountant_status,
|
|
249
|
+
charge.type ?? null,
|
|
250
|
+
charge.accountant_status ?? 'PENDING',
|
|
246
251
|
charge.user_description,
|
|
247
|
-
charge.tax_category_id,
|
|
248
|
-
charge.optional_vat,
|
|
249
|
-
charge.documents_optional_flag,
|
|
252
|
+
charge.tax_category_id ?? null,
|
|
253
|
+
charge.optional_vat ?? false,
|
|
254
|
+
charge.documents_optional_flag ?? false,
|
|
255
|
+
charge.is_property ?? false,
|
|
250
256
|
]);
|
|
251
257
|
idMapping.set(charge.id, charge.id);
|
|
252
258
|
}
|
|
@@ -278,9 +284,10 @@ export async function insertFixture(client, fixture) {
|
|
|
278
284
|
await client.query(`INSERT INTO ${qualifyTable('transactions')} (
|
|
279
285
|
id, account_id, charge_id, source_id, source_description,
|
|
280
286
|
currency, event_date, debit_date, amount, current_balance,
|
|
281
|
-
business_id, is_fee, source_reference, source_origin, origin_key
|
|
287
|
+
business_id, is_fee, source_reference, source_origin, origin_key,
|
|
288
|
+
currency_rate, created_at, updated_at
|
|
282
289
|
)
|
|
283
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
|
|
290
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, NOW(), NOW())
|
|
284
291
|
ON CONFLICT (id) DO NOTHING`, [
|
|
285
292
|
transaction.id,
|
|
286
293
|
accountId,
|
|
@@ -291,12 +298,13 @@ export async function insertFixture(client, fixture) {
|
|
|
291
298
|
transaction.event_date,
|
|
292
299
|
transaction.debit_date,
|
|
293
300
|
transaction.amount,
|
|
294
|
-
transaction.current_balance,
|
|
301
|
+
transaction.current_balance ?? '0',
|
|
295
302
|
transaction.business_id,
|
|
296
|
-
transaction.is_fee,
|
|
303
|
+
transaction.is_fee ?? false,
|
|
297
304
|
'TEST-REF', // source_reference (NOT NULL)
|
|
298
305
|
'TEST', // source_origin (NOT NULL)
|
|
299
306
|
dummyEtherscanId, // origin_key (NOT NULL) - must match etherscan_id in raw list
|
|
307
|
+
transaction.currency_rate ?? 1,
|
|
300
308
|
]);
|
|
301
309
|
idMapping.set(transaction.id, transaction.id);
|
|
302
310
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixture-loader.js","sourceRoot":"","sources":["../../../../../src/__tests__/helpers/fixture-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAE5B;IACA;IACA;IAHlB,YACkB,OAAe,EACf,aAAoB,EACpB,OAAiC;QAEjD,KAAK,CACH,qCAAqC,OAAO,MAAM,aAAa,CAAC,OAAO,EAAE;YACvE,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACpE,CAAC;QAPc,YAAO,GAAP,OAAO,CAAQ;QACf,kBAAa,GAAb,aAAa,CAAO;QACpB,YAAO,GAAP,OAAO,CAA0B;QAMjD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IACzD,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE;gBACb,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI;gBAC7B,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO;aACpC;YACD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;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,CAAC,SAAS;oBAClB,QAAQ,CAAC,WAAW;oBACpB,QAAQ,CAAC,wBAAwB;oBACjC,QAAQ,CAAC,aAAa;oBACtB,QAAQ,CAAC,iBAAiB;oBAC1B,QAAQ,CAAC,sBAAsB;oBAC/B,QAAQ,CAAC,SAAS;iBACnB,CACF,CAAC;gBAEF,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAG,EAAE,QAAQ,CAAC,EAAG,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
* @see packages/server/src/__tests__/helpers/fixture-validation.ts for validation logic
|
|
13
13
|
* @see packages/server/src/__tests__/helpers/fixture-loader.ts for insertion logic
|
|
14
14
|
*/
|
|
15
|
-
import type { ChargeInsertParams } from '../factories/
|
|
16
|
-
import type { TransactionInsertParams } from '../factories/transaction.js';
|
|
17
|
-
import type { DocumentInsertParams } from '../factories/document.js';
|
|
15
|
+
import type { ChargeInsertParams, TransactionInsertParams, DocumentInsertParams } from '../factories/index.js';
|
|
18
16
|
import type { financial_account_type } from '../../modules/transactions/types.js';
|
|
19
17
|
/**
|
|
20
18
|
* Business entities in a fixture
|
|
@@ -263,16 +263,16 @@ export function assertForeignExpenseScenario(records, params) {
|
|
|
263
263
|
const legCountApprox = Math.round(params.expectedLocalTotal / impliedPerLeg);
|
|
264
264
|
// Validate each leg amount close to impliedPerLeg (within 5%)
|
|
265
265
|
debitLegs.forEach((amt, i) => {
|
|
266
|
-
expectClose(amt, impliedPerLeg, impliedPerLeg
|
|
266
|
+
expectClose(amt, impliedPerLeg, impliedPerLeg + 0.05, `Debit leg ${i} amount mismatch`);
|
|
267
267
|
});
|
|
268
268
|
creditLegs.forEach((amt, i) => {
|
|
269
|
-
expectClose(amt, impliedPerLeg, impliedPerLeg
|
|
269
|
+
expectClose(amt, impliedPerLeg, impliedPerLeg + 0.05, `Credit leg ${i} amount mismatch`);
|
|
270
270
|
});
|
|
271
271
|
// Aggregate totals
|
|
272
272
|
const totalDebit = debitLegs.reduce((a, b) => a + b, 0);
|
|
273
273
|
const totalCredit = creditLegs.reduce((a, b) => a + b, 0);
|
|
274
|
-
expectClose(totalDebit, params.expectedLocalTotal, params.expectedLocalTotal
|
|
275
|
-
expectClose(totalCredit, params.expectedLocalTotal, params.expectedLocalTotal
|
|
274
|
+
expectClose(totalDebit, params.expectedLocalTotal, params.expectedLocalTotal + 0.05, 'Aggregate debit total mismatch');
|
|
275
|
+
expectClose(totalCredit, params.expectedLocalTotal, params.expectedLocalTotal + 0.05, 'Aggregate credit total mismatch');
|
|
276
276
|
// Leg count heuristic
|
|
277
277
|
expect(Math.abs(debitLegs.length - legCountApprox), 'Unexpected number of debit legs').toBeLessThanOrEqual(1);
|
|
278
278
|
expect(Math.abs(creditLegs.length - legCountApprox), 'Unexpected number of credit legs').toBeLessThanOrEqual(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accounter/server",
|
|
3
|
-
"version": "0.0.9-alpha-
|
|
3
|
+
"version": "0.0.9-alpha-20251211084417-bd969ff3311bc514c5796ad31c7d5b5691e3645e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@pgtyped/cli": "2.4.3",
|
|
34
34
|
"@pgtyped/runtime": "2.4.2",
|
|
35
35
|
"@whatwg-node/fetch": "0.10.13",
|
|
36
|
-
"ai": "5.0.
|
|
36
|
+
"ai": "5.0.108",
|
|
37
37
|
"basic-auth": "2.0.1",
|
|
38
38
|
"bcrypt": "6.0.0",
|
|
39
39
|
"cloudinary": "2.8.0",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Based on charges table schema from migrations and charges.provider.ts:
|
|
7
7
|
* - Required: owner_id
|
|
8
|
-
* - Optional: type, accountant_status, user_description, tax_category_id, optional_vat, documents_optional_flag
|
|
8
|
+
* - Optional: type, accountant_status, user_description, tax_category_id, optional_vat, documents_optional_flag, is_property
|
|
9
9
|
*
|
|
10
10
|
* @see packages/server/src/modules/charges/providers/charges.provider.ts (generateCharge query)
|
|
11
11
|
* @see packages/migrations/src/actions/*-charges-*.ts (migrations)
|
|
@@ -22,6 +22,7 @@ import { makeUUID, makeUUIDLegacy } from '../../demo-fixtures/helpers/determinis
|
|
|
22
22
|
export interface ChargeInsertParams {
|
|
23
23
|
id?: string;
|
|
24
24
|
owner_id: string;
|
|
25
|
+
is_property?: boolean | null;
|
|
25
26
|
type?: string | null;
|
|
26
27
|
accountant_status?: string | null;
|
|
27
28
|
user_description?: string | null;
|
|
@@ -45,6 +46,7 @@ export interface ChargeInsertParams {
|
|
|
45
46
|
* - accountant_status defaults to 'PENDING' (database requires NOT NULL)
|
|
46
47
|
* - optional_vat defaults to false (database requires NOT NULL)
|
|
47
48
|
* - documents_optional_flag defaults to false (database requires NOT NULL)
|
|
49
|
+
* - is_property defaults to null (property-related charges can override to true)
|
|
48
50
|
* - id defaults to deterministic UUID if not provided
|
|
49
51
|
*
|
|
50
52
|
* @example
|
|
@@ -97,4 +99,4 @@ export function createCharge(
|
|
|
97
99
|
documents_optional_flag: false,
|
|
98
100
|
...overrides,
|
|
99
101
|
};
|
|
100
|
-
}
|
|
102
|
+
}
|
|
@@ -31,9 +31,10 @@ export interface TransactionInsertParams {
|
|
|
31
31
|
event_date: string;
|
|
32
32
|
debit_date?: string | null;
|
|
33
33
|
amount: string; // PostgreSQL numeric -> string
|
|
34
|
-
current_balance
|
|
34
|
+
current_balance?: string; // PostgreSQL numeric -> string
|
|
35
35
|
business_id?: string | null;
|
|
36
36
|
is_fee?: boolean | null;
|
|
37
|
+
currency_rate?: number | null;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -50,6 +51,7 @@ export interface TransactionInsertParams {
|
|
|
50
51
|
* - currency is required (e.g., 'ILS', 'USD', 'EUR')
|
|
51
52
|
* - event_date is required (transaction date)
|
|
52
53
|
* - is_fee defaults to false (regular transaction, not a fee)
|
|
54
|
+
* - currency_rate defaults to null (foreign currency transactions can specify exchange rate)
|
|
53
55
|
* - account_id defaults to deterministic UUID if not provided
|
|
54
56
|
* - source_id defaults to deterministic UUID (raw transaction reference)
|
|
55
57
|
* - source_description defaults to null
|
|
@@ -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
|
|
@@ -174,13 +178,13 @@ export async function insertFixture(
|
|
|
174
178
|
business.website,
|
|
175
179
|
business.phoneNumber,
|
|
176
180
|
business.governmentId, // Maps to vat_number column
|
|
177
|
-
business.exemptDealer,
|
|
178
|
-
business.suggestions,
|
|
179
|
-
business.optionalVat,
|
|
180
|
-
business.country,
|
|
181
|
-
business.pcn874RecordTypeOverride,
|
|
182
|
-
business.isReceiptEnough,
|
|
183
|
-
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,
|
|
184
188
|
],
|
|
185
189
|
);
|
|
186
190
|
|
|
@@ -214,7 +218,7 @@ export async function insertFixture(
|
|
|
214
218
|
)
|
|
215
219
|
VALUES ($1, $2, $3)
|
|
216
220
|
ON CONFLICT (id) DO NOTHING`,
|
|
217
|
-
[taxCategory.id, taxCategory.hashavshevetName, taxCategory.taxExcluded],
|
|
221
|
+
[taxCategory.id, taxCategory.hashavshevetName, taxCategory.taxExcluded ?? false],
|
|
218
222
|
);
|
|
219
223
|
|
|
220
224
|
if (entityResult.rows.length > 0) {
|
|
@@ -293,19 +297,21 @@ export async function insertFixture(
|
|
|
293
297
|
await client.query(
|
|
294
298
|
`INSERT INTO ${qualifyTable('charges')} (
|
|
295
299
|
id, owner_id, type, accountant_status, user_description,
|
|
296
|
-
tax_category_id, optional_vat, documents_optional_flag
|
|
300
|
+
tax_category_id, optional_vat, documents_optional_flag,
|
|
301
|
+
is_property, created_at, updated_at
|
|
297
302
|
)
|
|
298
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
303
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, NOW(), NOW())
|
|
299
304
|
ON CONFLICT (id) DO NOTHING`,
|
|
300
305
|
[
|
|
301
306
|
charge.id,
|
|
302
307
|
charge.owner_id,
|
|
303
|
-
charge.type,
|
|
304
|
-
charge.accountant_status,
|
|
308
|
+
charge.type ?? null,
|
|
309
|
+
charge.accountant_status ?? 'PENDING',
|
|
305
310
|
charge.user_description,
|
|
306
|
-
charge.tax_category_id,
|
|
307
|
-
charge.optional_vat,
|
|
308
|
-
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,
|
|
309
315
|
],
|
|
310
316
|
);
|
|
311
317
|
|
|
@@ -349,9 +355,10 @@ export async function insertFixture(
|
|
|
349
355
|
`INSERT INTO ${qualifyTable('transactions')} (
|
|
350
356
|
id, account_id, charge_id, source_id, source_description,
|
|
351
357
|
currency, event_date, debit_date, amount, current_balance,
|
|
352
|
-
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
|
|
353
360
|
)
|
|
354
|
-
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())
|
|
355
362
|
ON CONFLICT (id) DO NOTHING`,
|
|
356
363
|
[
|
|
357
364
|
transaction.id,
|
|
@@ -363,12 +370,13 @@ export async function insertFixture(
|
|
|
363
370
|
transaction.event_date,
|
|
364
371
|
transaction.debit_date,
|
|
365
372
|
transaction.amount,
|
|
366
|
-
transaction.current_balance,
|
|
373
|
+
transaction.current_balance ?? '0',
|
|
367
374
|
transaction.business_id,
|
|
368
|
-
transaction.is_fee,
|
|
375
|
+
transaction.is_fee ?? false,
|
|
369
376
|
'TEST-REF', // source_reference (NOT NULL)
|
|
370
377
|
'TEST', // source_origin (NOT NULL)
|
|
371
378
|
dummyEtherscanId, // origin_key (NOT NULL) - must match etherscan_id in raw list
|
|
379
|
+
transaction.currency_rate ?? 1,
|
|
372
380
|
],
|
|
373
381
|
);
|
|
374
382
|
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
* @see packages/server/src/__tests__/helpers/fixture-loader.ts for insertion logic
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import type { ChargeInsertParams } from '../factories/
|
|
17
|
-
import type { TransactionInsertParams } from '../factories/transaction.js';
|
|
18
|
-
import type { DocumentInsertParams } from '../factories/document.js';
|
|
16
|
+
import type { ChargeInsertParams, TransactionInsertParams, DocumentInsertParams } from '../factories/index.js';
|
|
19
17
|
import type { financial_account_type } from '../../modules/transactions/types.js';
|
|
20
18
|
|
|
21
19
|
/**
|
|
@@ -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
|
|
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
|
|
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
|
|
336
|
-
expectClose(totalCredit, params.expectedLocalTotal, params.expectedLocalTotal
|
|
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`,
|