Skip to content

Commit 59b8276

Browse files
authored
Merge pull request #2972 from DFXswiss/develop
Release: develop -> main
2 parents 7ef765e + 1d6d5c6 commit 59b8276

3 files changed

Lines changed: 250 additions & 0 deletions

File tree

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/**
2+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
3+
* @typedef {import('typeorm').QueryRunner} QueryRunner
4+
*/
5+
6+
/**
7+
* Add manual bank transactions for Märki Baumann:
8+
*
9+
* 1. Interest charge (Sollzins) - DocID 42675306
10+
* - Amount: CHF 1.11 (Debit)
11+
* - Date: 31.12.2025
12+
* - Account: CH34 0857 3177 9752 0000 1 (CHF)
13+
*
14+
* 2. Payment return (Zahlungsrückweisung) - DocID 42675333
15+
* - Amount: EUR 57'399.75 (Credit, net after EUR 28.71 fee)
16+
* - Date: 08.12.2025
17+
* - Account: CH68 0857 3177 9752 0181 4 (EUR)
18+
* - Original payment to: Jelly Labs AG, Vaduz
19+
* - DFX Payment: 754427747
20+
*
21+
* @class
22+
* @implements {MigrationInterface}
23+
*/
24+
module.exports = class AddManualBankTransactions1768817558924 {
25+
name = 'AddManualBankTransactions1768817558924'
26+
27+
/**
28+
* @param {QueryRunner} queryRunner
29+
*/
30+
async up(queryRunner) {
31+
// === 1. Interest charge (Sollzins) ===
32+
const existingInterest = await queryRunner.query(`
33+
SELECT "id" FROM "dbo"."bank_tx"
34+
WHERE "accountServiceRef" = '42675306'
35+
`);
36+
37+
if (existingInterest.length > 0) {
38+
console.log('Bank transaction 42675306 (interest charge) already exists, skipping');
39+
} else {
40+
await queryRunner.query(`
41+
INSERT INTO "dbo"."bank_tx" (
42+
"accountServiceRef",
43+
"bookingDate",
44+
"valueDate",
45+
"amount",
46+
"currency",
47+
"creditDebitIndicator",
48+
"instructedAmount",
49+
"instructedCurrency",
50+
"txAmount",
51+
"txCurrency",
52+
"name",
53+
"accountIban",
54+
"remittanceInfo",
55+
"type"
56+
) VALUES (
57+
'42675306',
58+
'2025-12-31T00:00:00.000Z',
59+
'2025-12-31T00:00:00.000Z',
60+
1.11,
61+
'CHF',
62+
'DBIT',
63+
1.11,
64+
'CHF',
65+
1.11,
66+
'CHF',
67+
'Maerki Baumann & Co. AG',
68+
'CH3408573177975200001',
69+
'Sollzins',
70+
'BankAccountFee'
71+
)
72+
`);
73+
console.log('Inserted interest charge transaction 42675306');
74+
}
75+
76+
// === 2. Payment return (Zahlungsrückweisung) ===
77+
const existingReturn = await queryRunner.query(`
78+
SELECT "id" FROM "dbo"."bank_tx"
79+
WHERE "accountServiceRef" = '42675333'
80+
`);
81+
82+
if (existingReturn.length > 0) {
83+
console.log('Bank transaction 42675333 (payment return) already exists, skipping');
84+
} else {
85+
await queryRunner.query(`
86+
INSERT INTO "dbo"."bank_tx" (
87+
"accountServiceRef",
88+
"bookingDate",
89+
"valueDate",
90+
"amount",
91+
"currency",
92+
"creditDebitIndicator",
93+
"instructedAmount",
94+
"instructedCurrency",
95+
"txAmount",
96+
"txCurrency",
97+
"chargeAmount",
98+
"chargeCurrency",
99+
"name",
100+
"addressLine1",
101+
"country",
102+
"accountIban",
103+
"remittanceInfo",
104+
"type"
105+
) VALUES (
106+
'42675333',
107+
'2025-12-08T00:00:00.000Z',
108+
'2025-12-08T00:00:00.000Z',
109+
57399.75,
110+
'EUR',
111+
'CRDT',
112+
57428.46,
113+
'EUR',
114+
57399.75,
115+
'EUR',
116+
28.71,
117+
'EUR',
118+
'BADEN-WUERTTEMBERGISCHE BANK',
119+
'STUTTGART',
120+
'DE',
121+
'CH6808573177975201814',
122+
'Rueckverguetung Zahlung z.G. Jelly Labs AG - DFX Payment: 754427747',
123+
'Pending'
124+
)
125+
`);
126+
console.log('Inserted payment return transaction 42675333');
127+
}
128+
}
129+
130+
/**
131+
* @param {QueryRunner} queryRunner
132+
*/
133+
async down(queryRunner) {
134+
await queryRunner.query(`
135+
DELETE FROM "dbo"."bank_tx"
136+
WHERE "accountServiceRef" IN ('42675306', '42675333')
137+
`);
138+
139+
console.log('Deleted manual bank transactions 42675306, 42675333');
140+
}
141+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
3+
* @typedef {import('typeorm').QueryRunner} QueryRunner
4+
*/
5+
6+
/**
7+
* Fix 6 bank transactions with inconsistent data:
8+
* DBIT indicator with negative amounts.
9+
*
10+
* For DBIT (debit) transactions, the amount should be positive
11+
* (the indicator determines the direction). These 6 transactions
12+
* have negative amounts with DBIT indicator, causing calculation errors.
13+
*
14+
* Affected transactions:
15+
* - ID 173381: ZV20251014/918520/1, -0.21 EUR -> 0.21 EUR
16+
* - ID 173380: ZV20251014/918518/1, -0.21 EUR -> 0.21 EUR
17+
* - ID 171434: ZV20250929/910632/1, -0.20 EUR -> 0.20 EUR
18+
* - ID 164288: ZV20250806/885809/1, -0.20 EUR -> 0.20 EUR
19+
* - ID 158783: ZV20250623/864252/1, -0.11 EUR -> 0.11 EUR
20+
* - ID 155408: ZV20250521/850592/1, -0.20 EUR -> 0.20 EUR
21+
*
22+
* @class
23+
* @implements {MigrationInterface}
24+
*/
25+
module.exports = class FixBankTxDbitNegativeAmounts1768819785000 {
26+
name = 'FixBankTxDbitNegativeAmounts1768819785000';
27+
28+
/**
29+
* @param {QueryRunner} queryRunner
30+
*/
31+
async up(queryRunner) {
32+
// Fix the 6 DBIT transactions with negative amounts
33+
const result = await queryRunner.query(`
34+
UPDATE "dbo"."bank_tx"
35+
SET "amount" = ABS("amount"),
36+
"instructedAmount" = ABS("instructedAmount"),
37+
"txAmount" = ABS("txAmount")
38+
WHERE "id" IN (173381, 173380, 171434, 164288, 158783, 155408)
39+
AND "amount" < 0
40+
AND "creditDebitIndicator" = 'DBIT'
41+
`);
42+
43+
console.log('Fixed DBIT transactions with negative amounts:', result);
44+
}
45+
46+
/**
47+
* @param {QueryRunner} queryRunner
48+
*/
49+
async down(queryRunner) {
50+
// Revert to negative amounts
51+
await queryRunner.query(`
52+
UPDATE "dbo"."bank_tx"
53+
SET "amount" = -ABS("amount"),
54+
"instructedAmount" = -ABS("instructedAmount"),
55+
"txAmount" = -ABS("txAmount")
56+
WHERE "id" IN (173381, 173380, 171434, 164288, 158783, 155408)
57+
AND "creditDebitIndicator" = 'DBIT'
58+
`);
59+
60+
console.log('Reverted DBIT transactions to negative amounts');
61+
}
62+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
3+
* @typedef {import('typeorm').QueryRunner} QueryRunner
4+
*/
5+
6+
/**
7+
* Fix valueDate for 2 bank transactions that have incorrect valueDate.
8+
*
9+
* These transactions have bookingDate 2025-01-03 but valueDate 2024-12-31,
10+
* causing them to be excluded from exports filtered by date range.
11+
*
12+
* Affected transactions:
13+
* - ID 142397: 233.11 EUR (ZV20241231/791326/1)
14+
* - ID 142392: 39.79 EUR (ZV20241231/791337/1)
15+
*
16+
* @class
17+
* @implements {MigrationInterface}
18+
*/
19+
module.exports = class FixBankTxValueDate1768820385000 {
20+
name = 'FixBankTxValueDate1768820385000';
21+
22+
/**
23+
* @param {QueryRunner} queryRunner
24+
*/
25+
async up(queryRunner) {
26+
await queryRunner.query(`
27+
UPDATE "dbo"."bank_tx"
28+
SET "valueDate" = '2025-01-03T00:00:00.000Z'
29+
WHERE "id" IN (142397, 142392)
30+
`);
31+
32+
console.log('Fixed valueDate for transactions 142397, 142392');
33+
}
34+
35+
/**
36+
* @param {QueryRunner} queryRunner
37+
*/
38+
async down(queryRunner) {
39+
await queryRunner.query(`
40+
UPDATE "dbo"."bank_tx"
41+
SET "valueDate" = '2024-12-31T00:00:00.000Z'
42+
WHERE "id" IN (142397, 142392)
43+
`);
44+
45+
console.log('Reverted valueDate for transactions 142397, 142392');
46+
}
47+
};

0 commit comments

Comments
 (0)