Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions migration/1767888333076-AddUserData301484ToZchfFee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const { MigrationInterface, QueryRunner } = require("typeorm");

module.exports = class AddUserData301484ToZchfFee1767888333076 {
name = 'AddUserData301484ToZchfFee1767888333076'

async up(queryRunner) {
// 1. Rename fee label to be generic (remove UserData 363001 reference)
await queryRunner.query(`
UPDATE "dbo"."fee"
SET "label" = 'Special ZCHF 0.5%'
WHERE "label" = 'Special ZCHF 0.5% UserData 363001'
`);

// 2. Add fee to userData 301484
await queryRunner.query(`
UPDATE "dbo"."user_data"
SET "individualFees" = CASE
WHEN "individualFees" IS NULL OR "individualFees" = ''
THEN CAST((SELECT id FROM "dbo"."fee" WHERE "label" = 'Special ZCHF 0.5%') AS VARCHAR)
ELSE "individualFees" + ';' + CAST((SELECT id FROM "dbo"."fee" WHERE "label" = 'Special ZCHF 0.5%') AS VARCHAR)
END
WHERE "id" = 301484
`);
}

async down(queryRunner) {
// 1. Get the fee ID
const feeIdResult = await queryRunner.query(`
SELECT id FROM "dbo"."fee" WHERE "label" = 'Special ZCHF 0.5%'
`);

if (feeIdResult.length > 0) {
const feeId = feeIdResult[0].id.toString();

// 2. Remove fee ID from userData 301484 individualFees
await queryRunner.query(`
UPDATE "dbo"."user_data"
SET "individualFees" = CASE
WHEN "individualFees" = '${feeId}' THEN NULL
WHEN "individualFees" LIKE '${feeId};%' THEN STUFF("individualFees", 1, LEN('${feeId};'), '')
WHEN "individualFees" LIKE '%;${feeId}' THEN LEFT("individualFees", LEN("individualFees") - LEN(';${feeId}'))
WHEN "individualFees" LIKE '%;${feeId};%' THEN REPLACE("individualFees", ';${feeId};', ';')
ELSE "individualFees"
END
WHERE "id" = 301484
`);
}

// 3. Restore original label
await queryRunner.query(`
UPDATE "dbo"."fee"
SET "label" = 'Special ZCHF 0.5% UserData 363001'
WHERE "label" = 'Special ZCHF 0.5%'
`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export enum QuoteError {
LIMIT_EXCEEDED = 'LimitExceeded',
NATIONALITY_NOT_ALLOWED = 'NationalityNotAllowed',
NAME_REQUIRED = 'NameRequired',
VIDEO_IDENT_REQUIRED = 'VideoIdentRequired',
IBAN_CURRENCY_MISMATCH = 'IbanCurrencyMismatch',
RECOMMENDATION_REQUIRED = 'RecommendationRequired',
EMAIL_REQUIRED = 'EmailRequired',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { BuyService } from 'src/subdomains/core/buy-crypto/routes/buy/buy.servic
import { RefundDataDto } from 'src/subdomains/core/history/dto/refund-data.dto';
import { BuyFiat } from 'src/subdomains/core/sell-crypto/process/buy-fiat.entity';
import { BuyFiatService } from 'src/subdomains/core/sell-crypto/process/services/buy-fiat.service';
import { AccountType } from 'src/subdomains/generic/user/models/user-data/account-type.enum';
import { KycIdentificationType } from 'src/subdomains/generic/user/models/user-data/kyc-identification-type.enum';
import { UserData } from 'src/subdomains/generic/user/models/user-data/user-data.entity';
import { KycLevel, UserDataStatus } from 'src/subdomains/generic/user/models/user-data/user-data.enum';
import { User } from 'src/subdomains/generic/user/models/user/user.entity';
Expand Down Expand Up @@ -928,13 +926,6 @@ export class TransactionHelper implements OnModuleInit {
)
return QuoteError.NAME_REQUIRED;

if (
txAmountChf > Config.tradingLimits.monthlyDefaultWoKyc &&
user?.userData?.accountType === AccountType.ORGANIZATION &&
user?.userData?.identificationType === KycIdentificationType.ONLINE_ID
)
return QuoteError.VIDEO_IDENT_REQUIRED;

if (
((isSell && to.name !== 'CHF') || paymentMethodIn === FiatPaymentMethod.CARD || isSwap) &&
user &&
Expand Down
Loading