mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
85 lines
1.8 KiB
TypeScript
85 lines
1.8 KiB
TypeScript
import { Transformer } from '@/lib/Transformer/Transformer';
|
|
import { formatNumber } from 'utils';
|
|
|
|
export class ItemReceiptTransactionTransformer extends Transformer {
|
|
/**
|
|
* Include these attributes to sale invoice object.
|
|
* @returns {Array}
|
|
*/
|
|
public includeAttributes = (): string[] => {
|
|
return [
|
|
'formattedAmount',
|
|
'formattedReceiptDate',
|
|
'formattedRate',
|
|
'formattedCost',
|
|
];
|
|
};
|
|
|
|
/**
|
|
* Formatted sell price.
|
|
* @param item
|
|
* @returns {string}
|
|
*/
|
|
public formattedAmount(item): string {
|
|
return formatNumber(item.amount, {
|
|
currencyCode: item.receipt.currencyCode,
|
|
});
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param item
|
|
* @returns
|
|
*/
|
|
public formattedReceiptDate = (entry): string => {
|
|
return this.formatDate(entry.receipt.receiptDate);
|
|
};
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public formattedQuantity = (entry): string => {
|
|
return entry.quantity;
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param entry
|
|
* @returns
|
|
*/
|
|
public formattedRate = (entry): string => {
|
|
return formatNumber(entry.rate, {
|
|
currencyCode: entry.receipt.currencyCode,
|
|
});
|
|
};
|
|
|
|
/**
|
|
*
|
|
* @param entry
|
|
* @returns
|
|
*/
|
|
public transform = (entry) => {
|
|
return {
|
|
receiptId: entry.receipt.id,
|
|
|
|
receipNumber: entry.receipt.receiptNumber,
|
|
referenceNumber: entry.receipt.referenceNo,
|
|
|
|
receiptDate: entry.receipt.receiptDate,
|
|
formattedReceiptDate: entry.formattedReceiptDate,
|
|
|
|
amount: entry.amount,
|
|
formattedAmount: entry.formattedAmount,
|
|
|
|
quantity: entry.quantity,
|
|
formattedQuantity: entry.formattedQuantity,
|
|
|
|
rate: entry.rate,
|
|
formattedRate: entry.formattedRate,
|
|
|
|
customerDisplayName: entry.receipt.customer.displayName,
|
|
customerCurrencyCode: entry.receipt.customer.currencyCode,
|
|
};
|
|
};
|
|
}
|