mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-23 00:00:31 +00:00
fix: formatted money attributes
This commit is contained in:
@@ -104,6 +104,12 @@ export class BillPaymentResponseDto {
|
|||||||
@ApiProperty({ description: 'The formatted amount', example: '100.00 USD' })
|
@ApiProperty({ description: 'The formatted amount', example: '100.00 USD' })
|
||||||
formattedAmount: string;
|
formattedAmount: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'The formatted total', example: '100.00 USD' })
|
||||||
|
formattedTotal: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'The formatted subtotal', example: '100.00 USD' })
|
||||||
|
formattedSubtotal: string;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description: 'The date when the payment was created',
|
description: 'The date when the payment was created',
|
||||||
example: '2024-01-01T12:00:00Z',
|
example: '2024-01-01T12:00:00Z',
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ export class BillPaymentTransformer extends Transformer {
|
|||||||
'formattedPaymentDate',
|
'formattedPaymentDate',
|
||||||
'formattedCreatedAt',
|
'formattedCreatedAt',
|
||||||
'formattedAmount',
|
'formattedAmount',
|
||||||
|
'formattedTotal',
|
||||||
|
'formattedSubtotal',
|
||||||
'entries',
|
'entries',
|
||||||
'attachments',
|
'attachments',
|
||||||
];
|
];
|
||||||
@@ -47,6 +49,29 @@ export class BillPaymentTransformer extends Transformer {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the formatted total.
|
||||||
|
* @param {IBillPayment} billPayment
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
protected formattedTotal = (billPayment: BillPayment): string => {
|
||||||
|
return this.formatNumber(billPayment.amount, {
|
||||||
|
currencyCode: billPayment.currencyCode,
|
||||||
|
money: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the formatted subtotal.
|
||||||
|
* @param {IBillPayment} billPayment
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
protected formattedSubtotal = (billPayment: BillPayment): string => {
|
||||||
|
return this.formatNumber(billPayment.amount, {
|
||||||
|
currencyCode: billPayment.currencyCode,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retreives the bill payment entries.
|
* Retreives the bill payment entries.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export class BillTransformer extends Transformer {
|
|||||||
protected formattedDueAmount = (bill: Bill): string => {
|
protected formattedDueAmount = (bill: Bill): string => {
|
||||||
return this.formatNumber(bill.dueAmount, {
|
return this.formatNumber(bill.dueAmount, {
|
||||||
currencyCode: bill.currencyCode,
|
currencyCode: bill.currencyCode,
|
||||||
|
money: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -169,6 +170,7 @@ export class BillTransformer extends Transformer {
|
|||||||
protected totalFormatted = (bill: Bill): string => {
|
protected totalFormatted = (bill: Bill): string => {
|
||||||
return this.formatNumber(bill.total, {
|
return this.formatNumber(bill.total, {
|
||||||
currencyCode: bill.currencyCode,
|
currencyCode: bill.currencyCode,
|
||||||
|
money: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export class CreditNoteTransformer extends Transformer {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
protected formattedSubtotal = (credit): string => {
|
protected formattedSubtotal = (credit): string => {
|
||||||
return this.formatNumber(credit.amount, { money: false });
|
return this.formatNumber(credit.amount);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +130,7 @@ export class CreditNoteTransformer extends Transformer {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
protected adjustmentFormatted = (credit): string => {
|
protected adjustmentFormatted = (credit): string => {
|
||||||
return this.formatMoney(credit.adjustment, {
|
return this.formatNumber(credit.adjustment, {
|
||||||
currencyCode: credit.currencyCode,
|
currencyCode: credit.currencyCode,
|
||||||
excerptZero: true,
|
excerptZero: true,
|
||||||
});
|
});
|
||||||
@@ -156,6 +156,7 @@ export class CreditNoteTransformer extends Transformer {
|
|||||||
protected totalFormatted = (credit): string => {
|
protected totalFormatted = (credit): string => {
|
||||||
return this.formatNumber(credit.total, {
|
return this.formatNumber(credit.total, {
|
||||||
currencyCode: credit.currencyCode,
|
currencyCode: credit.currencyCode,
|
||||||
|
money: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -167,6 +168,7 @@ export class CreditNoteTransformer extends Transformer {
|
|||||||
protected totalLocalFormatted = (credit): string => {
|
protected totalLocalFormatted = (credit): string => {
|
||||||
return this.formatNumber(credit.totalLocal, {
|
return this.formatNumber(credit.totalLocal, {
|
||||||
currencyCode: credit.currencyCode,
|
currencyCode: credit.currencyCode,
|
||||||
|
money: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ export class PaymentReceivedResponseDto {
|
|||||||
@ApiProperty({ description: 'The formatted amount', example: '100.00' })
|
@ApiProperty({ description: 'The formatted amount', example: '100.00' })
|
||||||
formattedAmount: string;
|
formattedAmount: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'The formatted total', example: '100.00 USD' })
|
||||||
|
formattedTotal: string;
|
||||||
|
|
||||||
@ApiProperty({ description: 'The currency code', example: 'USD' })
|
@ApiProperty({ description: 'The currency code', example: 'USD' })
|
||||||
currencyCode: string;
|
currencyCode: string;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export class PaymentReceiveTransfromer extends Transformer {
|
|||||||
public includeAttributes = (): string[] => {
|
public includeAttributes = (): string[] => {
|
||||||
return [
|
return [
|
||||||
'subtotalFormatted',
|
'subtotalFormatted',
|
||||||
|
'formatttedTotal',
|
||||||
'formattedPaymentDate',
|
'formattedPaymentDate',
|
||||||
'formattedCreatedAt',
|
'formattedCreatedAt',
|
||||||
'formattedAmount',
|
'formattedAmount',
|
||||||
@@ -45,7 +46,18 @@ export class PaymentReceiveTransfromer extends Transformer {
|
|||||||
protected subtotalFormatted = (payment: PaymentReceived): string => {
|
protected subtotalFormatted = (payment: PaymentReceived): string => {
|
||||||
return this.formatNumber(payment.amount, {
|
return this.formatNumber(payment.amount, {
|
||||||
currencyCode: payment.currencyCode,
|
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}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
protected formattedExchangeRate = (payment: PaymentReceived): string => {
|
protected formattedExchangeRate = (payment: PaymentReceived): string => {
|
||||||
return this.formatNumber(payment.exchangeRate, { money: false });
|
return this.formatNumber(payment.exchangeRate);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export class SaleEstimateTransfromer extends Transformer {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
protected adjustmentFormatted = (estimate: SaleEstimate): string => {
|
protected adjustmentFormatted = (estimate: SaleEstimate): string => {
|
||||||
return this.formatMoney(estimate.adjustment, {
|
return this.formatNumber(estimate.adjustment, {
|
||||||
currencyCode: estimate.currencyCode,
|
currencyCode: estimate.currencyCode,
|
||||||
excerptZero: true,
|
excerptZero: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export class SaleInvoiceTransformer extends Transformer {
|
|||||||
protected dueAmountFormatted = (invoice: SaleInvoice): string => {
|
protected dueAmountFormatted = (invoice: SaleInvoice): string => {
|
||||||
return this.formatNumber(invoice.dueAmount, {
|
return this.formatNumber(invoice.dueAmount, {
|
||||||
currencyCode: invoice.currencyCode,
|
currencyCode: invoice.currencyCode,
|
||||||
|
money: true
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,7 +114,6 @@ export class SaleInvoiceTransformer extends Transformer {
|
|||||||
protected subtotalFormatted = (invoice: SaleInvoice): string => {
|
protected subtotalFormatted = (invoice: SaleInvoice): string => {
|
||||||
return this.formatNumber(invoice.subtotal, {
|
return this.formatNumber(invoice.subtotal, {
|
||||||
currencyCode: this.context.organization.baseCurrency,
|
currencyCode: this.context.organization.baseCurrency,
|
||||||
money: false,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -170,6 +170,7 @@ export class SaleInvoiceTransformer extends Transformer {
|
|||||||
protected totalFormatted = (invoice: SaleInvoice): string => {
|
protected totalFormatted = (invoice: SaleInvoice): string => {
|
||||||
return this.formatNumber(invoice.total, {
|
return this.formatNumber(invoice.total, {
|
||||||
currencyCode: invoice.currencyCode,
|
currencyCode: invoice.currencyCode,
|
||||||
|
money: true
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -212,7 +213,7 @@ export class SaleInvoiceTransformer extends Transformer {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
protected adjustmentFormatted = (invoice: SaleInvoice): string => {
|
protected adjustmentFormatted = (invoice: SaleInvoice): string => {
|
||||||
return this.formatMoney(invoice.adjustment, {
|
return this.formatNumber(invoice.adjustment, {
|
||||||
currencyCode: invoice.currencyCode,
|
currencyCode: invoice.currencyCode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ export class Transformer<T = {}, ExtraContext = {}> {
|
|||||||
protected formatMoney(money, options?) {
|
protected formatMoney(money, options?) {
|
||||||
return formatNumber(money, {
|
return formatNumber(money, {
|
||||||
currencyCode: this.context.organization.baseCurrency,
|
currencyCode: this.context.organization.baseCurrency,
|
||||||
|
money: true,
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user