feat: add paid amount attr and formatting to SaleReceipt transformer

This commit is contained in:
Ahmed Bouhuolia
2024-12-08 17:26:52 +02:00
parent 11d7a40326
commit 0a5115fc20
4 changed files with 35 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ export class SaleReceiptTransformer extends Transformer {
'formattedReceiptDate',
'formattedClosedAtDate',
'formattedCreatedAt',
'paidFormatted',
'entries',
'attachments',
];
@@ -130,6 +131,18 @@ export class SaleReceiptTransformer extends Transformer {
return receipt.discountPercentage ? `${receipt.discountPercentage}%` : '';
};
/**
* Retrieves formatted paid amount.
* @param receipt
* @returns {string}
*/
protected paidFormatted = (receipt: ISaleReceipt): string => {
return formatNumber(receipt.paid, {
currencyCode: receipt.currencyCode,
excerptZero: true,
});
};
/**
* Retrieves formatted adjustment amount.
* @param receipt