feat: financial reports meta

This commit is contained in:
Ahmed Bouhuolia
2024-02-17 23:58:26 +02:00
parent 06e78db49d
commit 465bb66d6b
12 changed files with 139 additions and 18 deletions

View File

@@ -0,0 +1,36 @@
import moment from 'moment';
import { Inject, Service } from 'typedi';
import { FinancialSheetMeta } from '../FinancialSheetMeta';
import {
ITransactionsByVendorMeta,
ITransactionsByVendorsFilter,
} from '@/interfaces';
@Service()
export class TransactionsByVendorMeta {
@Inject()
private financialSheetMeta: FinancialSheetMeta;
/**
* Retrieves the transactions by vendor meta.
* @param {number} tenantId -
* @returns {Promise<ITransactionsByVendorMeta>}
*/
public async meta(
tenantId: number,
query: ITransactionsByVendorsFilter
): Promise<ITransactionsByVendorMeta> {
const commonMeta = await this.financialSheetMeta.meta(tenantId);
const formattedToDate = moment(query.toDate).format('YYYY/MM/DD');
const formattedFromDate = moment(query.fromDate).format('YYYY/MM/DD');
const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`;
return {
...commonMeta,
sheetName: 'Transactions By Vendor',
formattedFromDate,
formattedToDate,
formattedDateRange,
};
}
}