mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat(server): wip printing financial reports
This commit is contained in:
@@ -54,4 +54,14 @@ export class BalanceSheetApplication {
|
||||
public csv(tenantId: number, query: IBalanceSheetQuery): Promise<string> {
|
||||
return this.balanceSheetExport.csv(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the balance sheet in pdf format.
|
||||
* @param {number} tenantId
|
||||
* @param {IBalanceSheetQuery} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(tenantId: number, query: IBalanceSheetQuery) {
|
||||
return this.balanceSheetExport.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,16 @@ import { Inject, Service } from 'typedi';
|
||||
import { BalanceSheetTableInjectable } from './BalanceSheetTableInjectable';
|
||||
import { TableSheet } from '@/lib/Xlsx/TableSheet';
|
||||
import { IBalanceSheetQuery } from '@/interfaces';
|
||||
import { BalanceSheetPdfInjectable } from './BalanceSheetPdfInjectable';
|
||||
|
||||
@Service()
|
||||
export class BalanceSheetExportInjectable {
|
||||
@Inject()
|
||||
private balanceSheetTable: BalanceSheetTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private balanceSheetPdf: BalanceSheetPdfInjectable;
|
||||
|
||||
/**
|
||||
* Retrieves the trial balance sheet in XLSX format.
|
||||
* @param {number} tenantId
|
||||
@@ -40,4 +44,17 @@ export class BalanceSheetExportInjectable {
|
||||
|
||||
return tableCsv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the balance sheet in pdf format.
|
||||
* @param {number} tenantId
|
||||
* @param {IBalanceSheetQuery} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: IBalanceSheetQuery
|
||||
): Promise<Buffer> {
|
||||
return this.balanceSheetPdf.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -43,13 +43,13 @@ export default class BalanceSheetTable extends R.compose(
|
||||
/**
|
||||
* @param {}
|
||||
*/
|
||||
reportData: IBalanceSheetStatementData;
|
||||
private reportData: IBalanceSheetStatementData;
|
||||
|
||||
/**
|
||||
* Balance sheet query.
|
||||
* @parma {}
|
||||
*/
|
||||
query: BalanceSheetQuery;
|
||||
private query: BalanceSheetQuery;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
|
||||
Reference in New Issue
Block a user