mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { IManualJournal } from '@/interfaces';
|
|
import { Transformer } from '@/lib/Transformer/Transformer';
|
|
import { formatNumber } from 'utils';
|
|
import { AttachmentTransformer } from '../Attachments/AttachmentTransformer';
|
|
|
|
export class ManualJournalTransfromer extends Transformer {
|
|
/**
|
|
* Include these attributes to expense object.
|
|
* @returns {Array}
|
|
*/
|
|
public includeAttributes = (): string[] => {
|
|
return [
|
|
'formattedAmount',
|
|
'formattedDate',
|
|
'formattedPublishedAt',
|
|
'attachments',
|
|
];
|
|
};
|
|
|
|
/**
|
|
* Retrieve formatted journal amount.
|
|
* @param {IManualJournal} manualJournal
|
|
* @returns {string}
|
|
*/
|
|
protected formattedAmount = (manualJorunal: IManualJournal): string => {
|
|
return formatNumber(manualJorunal.amount, {
|
|
currencyCode: manualJorunal.currencyCode,
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Retrieve formatted date.
|
|
* @param {IManualJournal} manualJournal
|
|
* @returns {string}
|
|
*/
|
|
protected formattedDate = (manualJorunal: IManualJournal): string => {
|
|
return this.formatDate(manualJorunal.date);
|
|
};
|
|
|
|
/**
|
|
* Retrieve formatted published at date.
|
|
* @param {IManualJournal} manualJournal
|
|
* @returns {string}
|
|
*/
|
|
protected formattedPublishedAt = (manualJorunal: IManualJournal): string => {
|
|
return this.formatDate(manualJorunal.publishedAt);
|
|
};
|
|
|
|
/**
|
|
* Retrieves the manual journal attachments.
|
|
* @param {ISaleInvoice} invoice
|
|
* @returns
|
|
*/
|
|
protected attachments = (manualJorunal: IManualJournal) => {
|
|
return this.item(manualJorunal.attachments, new AttachmentTransformer());
|
|
};
|
|
}
|