mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat(server): wip printing financial reports
This commit is contained in:
@@ -3,6 +3,7 @@ import { ProfitLossSheetExportInjectable } from './ProfitLossSheetExportInjectab
|
||||
import { ProfitLossSheetTableInjectable } from './ProfitLossSheetTableInjectable';
|
||||
import { IProfitLossSheetQuery, IProfitLossSheetTable } from '@/interfaces';
|
||||
import ProfitLossSheetService from './ProfitLossSheetService';
|
||||
import { ProfitLossTablePdfInjectable } from './ProfitLossTablePdfInjectable';
|
||||
|
||||
@Service()
|
||||
export class ProfitLossSheetApplication {
|
||||
@@ -15,6 +16,9 @@ export class ProfitLossSheetApplication {
|
||||
@Inject()
|
||||
private profitLossSheet: ProfitLossSheetService;
|
||||
|
||||
@Inject()
|
||||
private profitLossPdf: ProfitLossTablePdfInjectable;
|
||||
|
||||
/**
|
||||
* Retreives the profit/loss sheet.
|
||||
* @param {number} tenantId
|
||||
@@ -57,4 +61,14 @@ export class ProfitLossSheetApplication {
|
||||
public xlsx(tenantId: number, query: IProfitLossSheetQuery): Promise<Buffer> {
|
||||
return this.profitLossExport.xlsx(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the profit/loss sheet in pdf format.
|
||||
* @param {number} tenantId
|
||||
* @param {IProfitLossSheetQuery} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(tenantId: number, query: IProfitLossSheetQuery): Promise<Buffer> {
|
||||
return this.profitLossPdf.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,11 @@ export class ProfitLossSheetExportInjectable {
|
||||
|
||||
return tableCsv;
|
||||
}
|
||||
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: IProfitLossSheetQuery
|
||||
): Promise<Buffer> {
|
||||
const table = await this.profitLossSheetTable.table(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { IProfitLossSheetQuery } from '@/interfaces';
|
||||
import { ProfitLossSheetTableInjectable } from './ProfitLossSheetTableInjectable';
|
||||
import { TableSheetPdf } from '../TableSheetPdf';
|
||||
|
||||
@Service()
|
||||
export class ProfitLossTablePdfInjectable {
|
||||
@Inject()
|
||||
private profitLossTable: ProfitLossSheetTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private tableSheetPdf: TableSheetPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the profit/loss sheet in pdf format.
|
||||
* @param {number} tenantId
|
||||
* @param {number} query
|
||||
* @returns {Promise<IBalanceSheetTable>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: IProfitLossSheetQuery
|
||||
): Promise<Buffer> {
|
||||
const table = await this.profitLossTable.table(tenantId, query);
|
||||
const sheetName = 'Profit & Loss Sheet';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user