mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: discount formatted attributes of sale transactions
This commit is contained in:
@@ -3,6 +3,7 @@ import { formatNumber } from 'utils';
|
||||
import { SaleInvoiceTaxEntryTransformer } from './SaleInvoiceTaxEntryTransformer';
|
||||
import { ItemEntryTransformer } from './ItemEntryTransformer';
|
||||
import { AttachmentTransformer } from '@/services/Attachments/AttachmentTransformer';
|
||||
import { DiscountType } from '@/interfaces';
|
||||
|
||||
export class SaleInvoiceTransformer extends Transformer {
|
||||
/**
|
||||
@@ -23,6 +24,9 @@ export class SaleInvoiceTransformer extends Transformer {
|
||||
'subtotalExludingTaxFormatted',
|
||||
'taxAmountWithheldFormatted',
|
||||
'taxAmountWithheldLocalFormatted',
|
||||
'discountAmountFormatted',
|
||||
'discountPercentageFormatted',
|
||||
'adjustmentFormatted',
|
||||
'totalFormatted',
|
||||
'totalLocalFormatted',
|
||||
'taxes',
|
||||
@@ -158,6 +162,39 @@ export class SaleInvoiceTransformer extends Transformer {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted discount amount.
|
||||
* @param invoice
|
||||
* @returns {string}
|
||||
*/
|
||||
protected discountAmountFormatted = (invoice): string => {
|
||||
return formatNumber(invoice.discountAmount, {
|
||||
currencyCode: invoice.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted discount percentage.
|
||||
* @param invoice
|
||||
* @returns {string}
|
||||
*/
|
||||
protected discountPercentageFormatted = (invoice): string => {
|
||||
return invoice.discountType === DiscountType.Percentage
|
||||
? `${invoice.discount}%`
|
||||
: '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves formatted adjustment amount.
|
||||
* @param invoice
|
||||
* @returns {string}
|
||||
*/
|
||||
protected adjustmentFormatted = (invoice): string => {
|
||||
return this.formatMoney(invoice.adjustment, {
|
||||
currencyCode: invoice.currencyCode,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves formatted total in foreign currency.
|
||||
* @param invoice
|
||||
|
||||
Reference in New Issue
Block a user