mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
85 lines
1.8 KiB
TypeScript
85 lines
1.8 KiB
TypeScript
import { Transformer } from '../Transformer/Transformer';
|
|
|
|
export class ItemInvoicesTransactionsTransformer extends Transformer {
|
|
/**
|
|
* Include these attributes to sale invoice object.
|
|
* @returns {Array}
|
|
*/
|
|
public includeAttributes = (): string[] => {
|
|
return [
|
|
'formattedAmount',
|
|
'formattedInvoiceDate',
|
|
'formattedRate',
|
|
'formattedCost',
|
|
];
|
|
};
|
|
|
|
/**
|
|
* Formatted sell price.
|
|
* @param item
|
|
* @returns {string}
|
|
*/
|
|
public formattedAmount(item): string {
|
|
return this.formatNumber(item.amount, {
|
|
currencyCode: item.invoice.currencyCode,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Formatted invoice date.
|
|
* @param item
|
|
* @returns
|
|
*/
|
|
public formattedInvoiceDate = (entry): string => {
|
|
return this.formatDate(entry.invoice.invoiceDate);
|
|
};
|
|
|
|
/**
|
|
* Formatted item quantity.
|
|
* @returns {string}
|
|
*/
|
|
public formattedQuantity = (entry): string => {
|
|
return entry.quantity;
|
|
};
|
|
|
|
/**
|
|
* Formatted date.
|
|
* @param entry
|
|
* @returns {string}
|
|
*/
|
|
public formattedRate = (entry): string => {
|
|
return this.formatNumber(entry.rate, {
|
|
currencyCode: entry.invoice.currencyCode,
|
|
});
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param {any} entry
|
|
* @returns {any}
|
|
*/
|
|
public transform = (entry) => {
|
|
return {
|
|
invoiceId: entry.invoice.id,
|
|
|
|
invoiceNumber: entry.invoice.invoiceNo,
|
|
referenceNumber: entry.invoice.referenceNo,
|
|
|
|
invoiceDate: entry.invoice.invoiceDate,
|
|
formattedInvoiceDate: entry.formattedInvoiceDate,
|
|
|
|
amount: entry.amount,
|
|
formattedAmount: entry.formattedAmount,
|
|
|
|
quantity: entry.quantity,
|
|
formattedQuantity: entry.formattedQuantity,
|
|
|
|
rate: entry.rate,
|
|
formattedRate: entry.formattedRate,
|
|
|
|
customerDisplayName: entry.invoice.customer.displayName,
|
|
customerCurrencyCode: entry.invoice.customer.currencyCode,
|
|
};
|
|
};
|
|
}
|