fix: formatted money attributes

This commit is contained in:
Ahmed Bouhuolia
2025-12-14 16:51:06 +02:00
parent 6ecfe1ff12
commit 63922c391a
9 changed files with 60 additions and 8 deletions

View File

@@ -74,6 +74,9 @@ export class PaymentReceivedResponseDto {
@ApiProperty({ description: 'The formatted amount', example: '100.00' })
formattedAmount: string;
@ApiProperty({ description: 'The formatted total', example: '100.00 USD' })
formattedTotal: string;
@ApiProperty({ description: 'The currency code', example: 'USD' })
currencyCode: string;

View File

@@ -11,6 +11,7 @@ export class PaymentReceiveTransfromer extends Transformer {
public includeAttributes = (): string[] => {
return [
'subtotalFormatted',
'formatttedTotal',
'formattedPaymentDate',
'formattedCreatedAt',
'formattedAmount',
@@ -45,7 +46,18 @@ export class PaymentReceiveTransfromer extends Transformer {
protected subtotalFormatted = (payment: PaymentReceived): string => {
return this.formatNumber(payment.amount, {
currencyCode: payment.currencyCode,
money: false,
});
};
/**
* Retrieves the formatted total.
* @param {PaymentReceived} payment
* @returns {string}
*/
protected formatttedTotal = (payment: PaymentReceived): string => {
return this.formatNumber(payment.amount, {
currencyCode: payment.currencyCode,
money: true,
});
};
@@ -66,7 +78,7 @@ export class PaymentReceiveTransfromer extends Transformer {
* @returns {string}
*/
protected formattedExchangeRate = (payment: PaymentReceived): string => {
return this.formatNumber(payment.exchangeRate, { money: false });
return this.formatNumber(payment.exchangeRate);
};
/**