feat(server): wip printing financial reports

This commit is contained in:
Ahmed Bouhuolia
2024-02-10 22:20:54 +02:00
parent ecaf8c99bb
commit 9395ef094a
36 changed files with 738 additions and 6 deletions

View File

@@ -0,0 +1,34 @@
import { Inject, Service } from 'typedi';
import { IBalanceSheetQuery } from '@/interfaces';
import { BalanceSheetTableInjectable } from './BalanceSheetTableInjectable';
import { TableSheetPdf } from '../TableSheetPdf';
@Service()
export class BalanceSheetPdfInjectable {
@Inject()
private balanceSheetTable: BalanceSheetTableInjectable;
@Inject()
private tableSheetPdf: TableSheetPdf;
/**
* Converts the given balance sheet table to pdf.
* @param {number} tenantId - Tenant ID.
* @param {IBalanceSheetQuery} query - Balance sheet query.
* @returns {Promise<Buffer>}
*/
public async pdf(
tenantId: number,
query: IBalanceSheetQuery
): Promise<Buffer> {
const table = await this.balanceSheetTable.table(tenantId, query);
const sheetName = 'Balance Sheet';
return this.tableSheetPdf.convertToPdf(
tenantId,
table.table,
sheetName,
table.meta.baseCurrency
);
}
}