Skip to content

Commit 576cb55

Browse files
authored
Merge pull request #2957 from DFXswiss/develop
Release: develop -> main
2 parents 0b4db60 + 1774499 commit 576cb55

4 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
3+
* @typedef {import('typeorm').QueryRunner} QueryRunner
4+
*/
5+
6+
/**
7+
* @class
8+
* @implements {MigrationInterface}
9+
*/
10+
module.exports = class SetFinanceFarmAmlRules1768503536967 {
11+
name = 'SetFinanceFarmAmlRules1768503536967'
12+
13+
/**
14+
* Add RULE_15 (Force Manual Check) to FinanceFarm wallet (ID 42).
15+
*
16+
* Current state: amlRules = '2' (RULE_2: KycLevel 30)
17+
* New state: amlRules = '2;15' (RULE_2 + RULE_15: Force Manual Check)
18+
*
19+
* @param {QueryRunner} queryRunner
20+
*/
21+
async up(queryRunner) {
22+
// Only add RULE_15 if it's not already present
23+
// Check for exact match: '15', '15;...', '...;15', '...;15;...'
24+
await queryRunner.query(`
25+
UPDATE "dbo"."wallet"
26+
SET "amlRules" = CASE
27+
WHEN "amlRules" IS NULL OR "amlRules" = '' OR "amlRules" = '0' THEN '15'
28+
WHEN "amlRules" = '15' THEN "amlRules"
29+
WHEN "amlRules" LIKE '15;%' THEN "amlRules"
30+
WHEN "amlRules" LIKE '%;15' THEN "amlRules"
31+
WHEN "amlRules" LIKE '%;15;%' THEN "amlRules"
32+
ELSE "amlRules" + ';15'
33+
END
34+
WHERE "id" = 42 AND "name" = 'FinanceFarm'
35+
`);
36+
}
37+
38+
/**
39+
* Remove RULE_15 from FinanceFarm wallet.
40+
*
41+
* @param {QueryRunner} queryRunner
42+
*/
43+
async down(queryRunner) {
44+
// Remove RULE_15 from amlRules (handles: '15', '2;15', '15;2', '2;15;3')
45+
await queryRunner.query(`
46+
UPDATE "dbo"."wallet"
47+
SET "amlRules" = CASE
48+
WHEN "amlRules" = '15' THEN '0'
49+
WHEN "amlRules" LIKE '15;%' THEN STUFF("amlRules", 1, 3, '')
50+
WHEN "amlRules" LIKE '%;15' THEN LEFT("amlRules", LEN("amlRules") - 3)
51+
WHEN "amlRules" LIKE '%;15;%' THEN REPLACE("amlRules", ';15;', ';')
52+
ELSE "amlRules"
53+
END
54+
WHERE "id" = 42 AND "name" = 'FinanceFarm'
55+
`);
56+
}
57+
}

src/subdomains/core/aml/enums/aml-error.enum.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export enum AmlError {
6464
IP_COUNTRY_MISMATCH = 'IpCountryMismatch',
6565
TRADE_APPROVAL_DATE_MISSING = 'TradeApprovalDateMissing',
6666
BANK_TX_CUSTOMER_NAME_MISSING = 'BankTxCustomerNameMissing',
67+
FORCE_MANUAL_CHECK = 'ForceManualCheck',
6768
}
6869

6970
export const DelayResultError = [
@@ -310,4 +311,9 @@ export const AmlErrorResult: {
310311
amlCheck: CheckStatus.FAIL,
311312
amlReason: AmlReason.INTERMEDIARY_WITHOUT_SENDER,
312313
},
314+
[AmlError.FORCE_MANUAL_CHECK]: {
315+
type: AmlErrorType.SINGLE,
316+
amlCheck: CheckStatus.PENDING,
317+
amlReason: AmlReason.MANUAL_CHECK,
318+
},
313319
};

src/subdomains/core/aml/enums/aml-rule.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export enum AmlRule {
1515
RULE_12 = 12, // Checkout BankTransactionVerificationDate & KycLevel 30
1616
RULE_13 = 13, // Checkout BankTransactionVerificationDate & KycLevel 50
1717
RULE_14 = 14, // No phoneCallCheck
18+
RULE_15 = 15, // Force Manual Check
1819
}
1920

2021
export const SpecialIpCountries = ['CH'];

src/subdomains/core/aml/services/aml-helper.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ export class AmlHelperService {
431431
}
432432

433433
break;
434+
435+
case AmlRule.RULE_15:
436+
errors.push(AmlError.FORCE_MANUAL_CHECK);
437+
break;
434438
}
435439

436440
return errors;

0 commit comments

Comments
 (0)