mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feat(server): wip priting financial reports
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
import { TransactionsByVendorExportInjectable } from './TransactionsByVendorExportInjectable';
|
||||
import { TransactionsByVendorTableInjectable } from './TransactionsByVendorTableInjectable';
|
||||
import { TransactionsByVendorsInjectable } from './TransactionsByVendorInjectable';
|
||||
import { TransactionsByVendorsPdf } from './TransactionsByVendorPdf';
|
||||
|
||||
@Service()
|
||||
export class TransactionsByVendorApplication {
|
||||
@@ -19,6 +20,9 @@ export class TransactionsByVendorApplication {
|
||||
@Inject()
|
||||
private transactionsByVendorSheet: TransactionsByVendorsInjectable;
|
||||
|
||||
@Inject()
|
||||
private transactionsByVendorPdf: TransactionsByVendorsPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by vendor in sheet format.
|
||||
* @param {number} tenantId
|
||||
@@ -72,4 +76,14 @@ export class TransactionsByVendorApplication {
|
||||
): Promise<Buffer> {
|
||||
return this.transactionsByVendorExport.xlsx(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by vendor in PDF format.
|
||||
* @param {number} tenantId
|
||||
* @param {ITransactionsByVendorsFilter} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(tenantId: number, query: ITransactionsByVendorsFilter) {
|
||||
return this.transactionsByVendorPdf.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { ITransactionsByVendorsFilter } from '@/interfaces';
|
||||
import { TableSheetPdf } from '../TableSheetPdf';
|
||||
import { TransactionsByVendorTableInjectable } from './TransactionsByVendorTableInjectable';
|
||||
|
||||
@Service()
|
||||
export class TransactionsByVendorsPdf {
|
||||
@Inject()
|
||||
private transactionsByVendorTable: TransactionsByVendorTableInjectable;
|
||||
|
||||
@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: ITransactionsByVendorsFilter
|
||||
): Promise<Buffer> {
|
||||
const table = await this.transactionsByVendorTable.table(tenantId, query);
|
||||
const sheetName = 'Transactions By Vendors';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user