From bd3eb6397e42970d3f08018a05dbc69f76337337 Mon Sep 17 00:00:00 2001 From: Gabsousa2203 Date: Thu, 16 Jan 2025 19:33:41 -0400 Subject: [PATCH] refactor: :recycle: make currency field optional and default to 'usd' in payment DTOs --- src/order/infraestructure/controller/order.controller.ts | 8 ++++++-- src/order/infraestructure/dto/payment-entry-dto.ts | 3 +-- src/order/infraestructure/dto/wallet-payment-entry-dto.ts | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/order/infraestructure/controller/order.controller.ts b/src/order/infraestructure/controller/order.controller.ts index a5cb33f2..4b6ffbab 100644 --- a/src/order/infraestructure/controller/order.controller.ts +++ b/src/order/infraestructure/controller/order.controller.ts @@ -344,7 +344,9 @@ export class OrderController { paymentId: data.paymentId ? data.paymentId : paymentId, - currency: data.currency.toLowerCase(), + currency: data.currency ? + data.currency.toLowerCase() + : 'usd', paymentMethod: data.paymentMethod, directionId: data.idUserDirection, products: data.products, @@ -427,7 +429,9 @@ export class OrderController { paymentId: data.paymentId ? data.paymentId : paymentId, - currency: data.currency.toLowerCase(), + currency: data.currency ? + data.currency.toLowerCase() + : 'usd', paymentMethod: data.paymentMethod, directionId: data.idUserDirection, products: data.products, diff --git a/src/order/infraestructure/dto/payment-entry-dto.ts b/src/order/infraestructure/dto/payment-entry-dto.ts index 0d4af252..34769401 100644 --- a/src/order/infraestructure/dto/payment-entry-dto.ts +++ b/src/order/infraestructure/dto/payment-entry-dto.ts @@ -18,8 +18,7 @@ export class PaymentEntryDto { }) @IsString() @IsOptional() - @Transform(({ value }) => value ?? 'usd') - currency: string; + currency?: string; @ApiProperty({ example: 'credit', description: 'The method of payment used' }) @Transform(({ value }) => value ?? 'credit') diff --git a/src/order/infraestructure/dto/wallet-payment-entry-dto.ts b/src/order/infraestructure/dto/wallet-payment-entry-dto.ts index cfbb4c7d..6cbe9aa8 100644 --- a/src/order/infraestructure/dto/wallet-payment-entry-dto.ts +++ b/src/order/infraestructure/dto/wallet-payment-entry-dto.ts @@ -16,7 +16,8 @@ export class WalletPaymentEntryDto { description: 'The currency in which the payment is made, only use USD, EUR or BSF', }) @IsString() - currency: string; + @IsOptional() + currency?: string; @ApiProperty({ example: 'card', description: 'The method of payment used' }) @IsString()