feat(server): wip priting financial reports

This commit is contained in:
Ahmed Bouhuolia
2024-02-11 01:14:31 +02:00
parent 9395ef094a
commit b11c531cf5
23 changed files with 438 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import {
import { TransactionsByCustomersTableInjectable } from './TransactionsByCustomersTableInjectable';
import { TransactionsByCustomersExportInjectable } from './TransactionsByCustomersExportInjectable';
import { TransactionsByCustomersSheet } from './TransactionsByCustomersService';
import { TransactionsByCustomersPdf } from './TransactionsByCustomersPdf';
@Service()
export class TransactionsByCustomerApplication {
@@ -18,6 +19,9 @@ export class TransactionsByCustomerApplication {
@Inject()
private transactionsByCustomersSheet: TransactionsByCustomersSheet;
@Inject()
private transactionsByCustomersPdf: TransactionsByCustomersPdf;
/**
* Retrieves the transactions by customers sheet in json format.
* @param {number} tenantId
@@ -69,4 +73,17 @@ export class TransactionsByCustomerApplication {
): Promise<Buffer> {
return this.transactionsByCustomersExport.xlsx(tenantId, query);
}
/**
* Retrieves the transactions by vendors sheet in PDF format.
* @param {number} tenantId
* @param {ITransactionsByCustomersFilter} query
* @returns {Promise<Buffer>}
*/
public pdf(
tenantId: number,
query: ITransactionsByCustomersFilter
): Promise<Buffer> {
return this.transactionsByCustomersPdf.pdf(tenantId, query);
}
}

View File

@@ -0,0 +1,36 @@
import { ITransactionsByCustomersFilter } from '@/interfaces';
import { Inject } from 'typedi';
import { TableSheetPdf } from '../TableSheetPdf';
import { TransactionsByCustomersTableInjectable } from './TransactionsByCustomersTableInjectable';
export class TransactionsByCustomersPdf {
@Inject()
private transactionsByCustomersTable: TransactionsByCustomersTableInjectable;
@Inject()
private tableSheetPdf: TableSheetPdf;
/**
* Retrieves the transactions by customers in PDF format.
* @param {number} tenantId - Tenant ID.
* @param {IBalanceSheetQuery} query - Balance sheet query.
* @returns {Promise<Buffer>}
*/
public async pdf(
tenantId: number,
query: ITransactionsByCustomersFilter
): Promise<Buffer> {
const table = await this.transactionsByCustomersTable.table(
tenantId,
query
);
const sheetName = 'Transactions By Customers';
return this.tableSheetPdf.convertToPdf(
tenantId,
table.table,
sheetName,
table.meta.baseCurrency
);
}
}