mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat(server): wip priting financial reports
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user