mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: discount formatted attributes of sale transactions
This commit is contained in:
@@ -14,6 +14,9 @@ export class SaleReceiptTransformer extends Transformer {
|
||||
public includeAttributes = (): string[] => {
|
||||
return [
|
||||
'formattedSubtotal',
|
||||
'discountAmountFormatted',
|
||||
'discountPercentageFormatted',
|
||||
'adjustmentFormatted',
|
||||
'formattedAmount',
|
||||
'formattedReceiptDate',
|
||||
'formattedClosedAtDate',
|
||||
@@ -70,6 +73,39 @@ export class SaleReceiptTransformer extends Transformer {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted discount amount.
|
||||
* @param receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected discountAmountFormatted = (receipt: ISaleReceipt): string => {
|
||||
return formatNumber(receipt.discountAmount, {
|
||||
currencyCode: receipt.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted discount percentage.
|
||||
* @param receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected discountPercentageFormatted = (receipt: ISaleReceipt): string => {
|
||||
return receipt.discountPercentage
|
||||
? `${receipt.discountPercentage}%`
|
||||
: '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted adjustment amount.
|
||||
* @param receipt
|
||||
* @returns {string}
|
||||
*/
|
||||
protected adjustmentFormatted = (receipt: ISaleReceipt): string => {
|
||||
return this.formatMoney(receipt.adjustment, {
|
||||
currencyCode: receipt.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the entries of the credit note.
|
||||
* @param {ISaleReceipt} credit
|
||||
|
||||
Reference in New Issue
Block a user