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

@@ -7,6 +7,7 @@ import { Inject, Service } from 'typedi';
import { InventoryValuationSheetService } from './InventoryValuationSheetService';
import { InventoryValuationSheetTableInjectable } from './InventoryValuationSheetTableInjectable';
import { InventoryValuationSheetExportable } from './InventoryValuationSheetExportable';
import { InventoryValuationSheetPdf } from './InventoryValuationSheetPdf';
@Service()
export class InventoryValuationSheetApplication {
@@ -19,6 +20,9 @@ export class InventoryValuationSheetApplication {
@Inject()
private inventoryValuationExport: InventoryValuationSheetExportable;
@Inject()
private inventoryValuationPdf: InventoryValuationSheetPdf;
/**
* Retrieves the inventory valuation json format.
* @param {number} tenantId
@@ -73,4 +77,17 @@ export class InventoryValuationSheetApplication {
): Promise<string> {
return this.inventoryValuationExport.csv(tenantId, query);
}
/**
* Retrieves the inventory valuation pdf format.
* @param {number} tenantId
* @param {IInventoryValuationReportQuery} query
* @returns {Promise<Buffer>}
*/
public pdf(
tenantId: number,
query: IInventoryValuationReportQuery
): Promise<Buffer> {
return this.inventoryValuationPdf.pdf(tenantId, query);
}
}

View File

@@ -0,0 +1,35 @@
import { Inject, Service } from "typedi";
import { InventoryValuationSheetTableInjectable } from "./InventoryValuationSheetTableInjectable";
import { TableSheetPdf } from "../TableSheetPdf";
import { IInventoryValuationReportQuery } from "@/interfaces";
@Service()
export class InventoryValuationSheetPdf {
@Inject()
private inventoryValuationTable: InventoryValuationSheetTableInjectable;
@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: IInventoryValuationReportQuery
): Promise<Buffer> {
const table = await this.inventoryValuationTable.table(tenantId, query);
const sheetName = 'Inventory Valuation Sheet';
return this.tableSheetPdf.convertToPdf(
tenantId,
table.table,
sheetName,
table.meta.baseCurrency
);
}
}