mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: add paid amount attr and formatting to SaleReceipt transformer
This commit is contained in:
@@ -55,6 +55,9 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
||||
'discountAmount',
|
||||
'discountPercentage',
|
||||
|
||||
'paid',
|
||||
'paidLocal',
|
||||
|
||||
'isClosed',
|
||||
'isDraft',
|
||||
];
|
||||
@@ -130,6 +133,22 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
||||
return this.adjustment * this.exchangeRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt paid amount.
|
||||
* @returns {number}
|
||||
*/
|
||||
get paid() {
|
||||
return this.total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt paid amount in local currency.
|
||||
* @returns {number}
|
||||
*/
|
||||
get paidLocal() {
|
||||
return this.paid * this.exchangeRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detarmine whether the sale receipt closed.
|
||||
* @return {boolean}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user