diff --git a/migration/1768503536967-SetFinanceFarmAmlRules.js b/migration/1768503536967-SetFinanceFarmAmlRules.js new file mode 100644 index 0000000000..900a24abc2 --- /dev/null +++ b/migration/1768503536967-SetFinanceFarmAmlRules.js @@ -0,0 +1,57 @@ +/** + * @typedef {import('typeorm').MigrationInterface} MigrationInterface + * @typedef {import('typeorm').QueryRunner} QueryRunner + */ + +/** + * @class + * @implements {MigrationInterface} + */ +module.exports = class SetFinanceFarmAmlRules1768503536967 { + name = 'SetFinanceFarmAmlRules1768503536967' + + /** + * Add RULE_15 (Force Manual Check) to FinanceFarm wallet (ID 42). + * + * Current state: amlRules = '2' (RULE_2: KycLevel 30) + * New state: amlRules = '2;15' (RULE_2 + RULE_15: Force Manual Check) + * + * @param {QueryRunner} queryRunner + */ + async up(queryRunner) { + // Only add RULE_15 if it's not already present + // Check for exact match: '15', '15;...', '...;15', '...;15;...' + await queryRunner.query(` + UPDATE "dbo"."wallet" + SET "amlRules" = CASE + WHEN "amlRules" IS NULL OR "amlRules" = '' OR "amlRules" = '0' THEN '15' + WHEN "amlRules" = '15' THEN "amlRules" + WHEN "amlRules" LIKE '15;%' THEN "amlRules" + WHEN "amlRules" LIKE '%;15' THEN "amlRules" + WHEN "amlRules" LIKE '%;15;%' THEN "amlRules" + ELSE "amlRules" + ';15' + END + WHERE "id" = 42 AND "name" = 'FinanceFarm' + `); + } + + /** + * Remove RULE_15 from FinanceFarm wallet. + * + * @param {QueryRunner} queryRunner + */ + async down(queryRunner) { + // Remove RULE_15 from amlRules (handles: '15', '2;15', '15;2', '2;15;3') + await queryRunner.query(` + UPDATE "dbo"."wallet" + SET "amlRules" = CASE + WHEN "amlRules" = '15' THEN '0' + WHEN "amlRules" LIKE '15;%' THEN STUFF("amlRules", 1, 3, '') + WHEN "amlRules" LIKE '%;15' THEN LEFT("amlRules", LEN("amlRules") - 3) + WHEN "amlRules" LIKE '%;15;%' THEN REPLACE("amlRules", ';15;', ';') + ELSE "amlRules" + END + WHERE "id" = 42 AND "name" = 'FinanceFarm' + `); + } +} diff --git a/src/subdomains/core/aml/enums/aml-error.enum.ts b/src/subdomains/core/aml/enums/aml-error.enum.ts index 8c75ff38a5..367bee6b8d 100644 --- a/src/subdomains/core/aml/enums/aml-error.enum.ts +++ b/src/subdomains/core/aml/enums/aml-error.enum.ts @@ -64,6 +64,7 @@ export enum AmlError { IP_COUNTRY_MISMATCH = 'IpCountryMismatch', TRADE_APPROVAL_DATE_MISSING = 'TradeApprovalDateMissing', BANK_TX_CUSTOMER_NAME_MISSING = 'BankTxCustomerNameMissing', + FORCE_MANUAL_CHECK = 'ForceManualCheck', } export const DelayResultError = [ @@ -310,4 +311,9 @@ export const AmlErrorResult: { amlCheck: CheckStatus.FAIL, amlReason: AmlReason.INTERMEDIARY_WITHOUT_SENDER, }, + [AmlError.FORCE_MANUAL_CHECK]: { + type: AmlErrorType.SINGLE, + amlCheck: CheckStatus.PENDING, + amlReason: AmlReason.MANUAL_CHECK, + }, }; diff --git a/src/subdomains/core/aml/enums/aml-rule.enum.ts b/src/subdomains/core/aml/enums/aml-rule.enum.ts index b19ad24f4e..ec0ecbad54 100644 --- a/src/subdomains/core/aml/enums/aml-rule.enum.ts +++ b/src/subdomains/core/aml/enums/aml-rule.enum.ts @@ -15,6 +15,7 @@ export enum AmlRule { RULE_12 = 12, // Checkout BankTransactionVerificationDate & KycLevel 30 RULE_13 = 13, // Checkout BankTransactionVerificationDate & KycLevel 50 RULE_14 = 14, // No phoneCallCheck + RULE_15 = 15, // Force Manual Check } export const SpecialIpCountries = ['CH']; diff --git a/src/subdomains/core/aml/services/aml-helper.service.ts b/src/subdomains/core/aml/services/aml-helper.service.ts index 2a021e9ee2..41f55c6d84 100644 --- a/src/subdomains/core/aml/services/aml-helper.service.ts +++ b/src/subdomains/core/aml/services/aml-helper.service.ts @@ -431,6 +431,10 @@ export class AmlHelperService { } break; + + case AmlRule.RULE_15: + errors.push(AmlError.FORCE_MANUAL_CHECK); + break; } return errors;