refactor: financial reports to nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-01-18 22:32:45 +02:00
parent 6dd854178d
commit dfc5674088
151 changed files with 5264 additions and 1296 deletions

View File

@@ -0,0 +1,37 @@
import { Injectable } from '@nestjs/common';
import { CashflowTableInjectable } from './CashflowTableInjectable';
import { ICashFlowStatementQuery } from './Cashflow.types';
import { TableSheet } from '../../common/TableSheet';
@Injectable()
export class CashflowExportInjectable {
constructor(private readonly cashflowSheetTable: CashflowTableInjectable) {}
/**
* Retrieves the cashflow sheet in XLSX format.
* @param {ICashFlowStatementQuery} query - Cashflow statement query.
* @returns {Promise<Buffer>}
*/
public async xlsx(query: ICashFlowStatementQuery): Promise<Buffer> {
const table = await this.cashflowSheetTable.table(query);
const tableSheet = new TableSheet(table.table);
const tableCsv = tableSheet.convertToXLSX();
return tableSheet.convertToBuffer(tableCsv, 'xlsx');
}
/**
* Retrieves the cashflow sheet in CSV format.
* @param {ICashFlowStatementQuery} query - Cashflow statement query.
* @returns {Promise<Buffer>}
*/
public async csv(query: ICashFlowStatementQuery): Promise<string> {
const table = await this.cashflowSheetTable.table(query);
const tableSheet = new TableSheet(table.table);
const tableCsv = tableSheet.convertToCSV();
return tableCsv;
}
}