mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat(server): wip priting financial reports
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
import { GeneralLedgerTableInjectable } from './GeneralLedgerTableInjectable';
|
||||
import { GeneralLedgerExportInjectable } from './GeneralLedgerExport';
|
||||
import { GeneralLedgerService } from './GeneralLedgerService';
|
||||
import { GeneralLedgerPdf } from './GeneralLedgerPdf';
|
||||
|
||||
export class GeneralLedgerApplication {
|
||||
@Inject()
|
||||
@@ -17,6 +18,9 @@ export class GeneralLedgerApplication {
|
||||
@Inject()
|
||||
private GLSheet: GeneralLedgerService;
|
||||
|
||||
@Inject()
|
||||
private GLPdf: GeneralLedgerPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the G/L sheet in json format.
|
||||
* @param {number} tenantId
|
||||
@@ -63,4 +67,17 @@ export class GeneralLedgerApplication {
|
||||
): Promise<string> {
|
||||
return this.GLExport.csv(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the G/L sheet in pdf format.
|
||||
* @param {number} tenantId
|
||||
* @param {IGeneralLedgerSheetQuery} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(
|
||||
tenantId: number,
|
||||
query: IGeneralLedgerSheetQuery
|
||||
): Promise<Buffer> {
|
||||
return this.GLPdf.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Inject, Service } from "typedi";
|
||||
import { TableSheetPdf } from "../TableSheetPdf";
|
||||
import { GeneralLedgerTableInjectable } from "./GeneralLedgerTableInjectable";
|
||||
import { IGeneralLedgerSheetQuery } from "@/interfaces";
|
||||
|
||||
@Service()
|
||||
export class GeneralLedgerPdf {
|
||||
@Inject()
|
||||
private generalLedgerTable: GeneralLedgerTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private tableSheetPdf: TableSheetPdf;
|
||||
|
||||
/**
|
||||
* Converts the general ledger sheet table to pdf.
|
||||
* @param {number} tenantId - Tenant ID.
|
||||
* @param {IGeneralLedgerSheetQuery} query -
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: IGeneralLedgerSheetQuery
|
||||
): Promise<Buffer> {
|
||||
const table = await this.generalLedgerTable.table(tenantId, query);
|
||||
const sheetName = 'General Ledger';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { Inject, Service } from 'typedi';
|
||||
import { InventoryDetailsExportInjectable } from './InventoryDetailsExportInjectable';
|
||||
import { InventoryDetailsTableInjectable } from './InventoryDetailsTableInjectable';
|
||||
import { InventoryDetailsService } from './InventoryDetailsService';
|
||||
import { InventoryDetailsTablePdf } from './InventoryDetailsTablePdf';
|
||||
|
||||
@Service()
|
||||
export class InventortyDetailsApplication {
|
||||
@@ -18,6 +19,9 @@ export class InventortyDetailsApplication {
|
||||
@Inject()
|
||||
private inventoryDetails: InventoryDetailsService;
|
||||
|
||||
@Inject()
|
||||
private inventoryDetailsPdf: InventoryDetailsTablePdf;
|
||||
|
||||
/**
|
||||
* Retrieves the inventory details report in sheet format.
|
||||
* @param {number} tenantId
|
||||
@@ -63,4 +67,14 @@ export class InventortyDetailsApplication {
|
||||
public csv(tenantId: number, query: IInventoryDetailsQuery): Promise<string> {
|
||||
return this.inventoryDetailsExport.csv(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the inventory details report in PDF format.
|
||||
* @param {number} tenantId
|
||||
* @param {IInventoryDetailsQuery} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(tenantId: number, query: IInventoryDetailsQuery) {
|
||||
return this.inventoryDetailsPdf.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Inject, Service } from "typedi";
|
||||
import { InventoryDetailsTableInjectable } from "./InventoryDetailsTableInjectable";
|
||||
import { TableSheetPdf } from "../TableSheetPdf";
|
||||
import { IInventoryDetailsQuery } from "@/interfaces";
|
||||
|
||||
|
||||
@Service()
|
||||
export class InventoryDetailsTablePdf {
|
||||
@Inject()
|
||||
private inventoryDetailsTable: InventoryDetailsTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private tableSheetPdf: TableSheetPdf;
|
||||
|
||||
/**
|
||||
* Converts the given inventory details sheet table to pdf.
|
||||
* @param {number} tenantId - Tenant ID.
|
||||
* @param {IBalanceSheetQuery} query - Balance sheet query.
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: IInventoryDetailsQuery
|
||||
): Promise<Buffer> {
|
||||
const table = await this.inventoryDetailsTable.table(tenantId, query);
|
||||
const sheetName = 'Inventory Items Details';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@/interfaces/PurchasesByItemsSheet';
|
||||
import { PurchasesByItemsTableInjectable } from './PurchasesByItemsTableInjectable';
|
||||
import { PurchasesByItemsService } from './PurchasesByItemsService';
|
||||
import { PurchasesByItemsPdf } from './PurchasesByItemsPdf';
|
||||
|
||||
@Service()
|
||||
export class PurcahsesByItemsApplication {
|
||||
@@ -19,6 +20,9 @@ export class PurcahsesByItemsApplication {
|
||||
@Inject()
|
||||
private purchasesByItemsExport: PurchasesByItemsExport;
|
||||
|
||||
@Inject()
|
||||
private purchasesByItemsPdf: PurchasesByItemsPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the purchases by items in json format.
|
||||
* @param {number} tenantId
|
||||
@@ -70,4 +74,17 @@ export class PurcahsesByItemsApplication {
|
||||
): Promise<Buffer> {
|
||||
return this.purchasesByItemsExport.xlsx(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the purchases by items in pdf format.
|
||||
* @param {number} tenantId
|
||||
* @param {IPurchasesByItemsReportQuery} filter
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(
|
||||
tenantId: number,
|
||||
filter: IPurchasesByItemsReportQuery
|
||||
): Promise<Buffer> {
|
||||
return this.purchasesByItemsPdf.pdf(tenantId, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { TableSheetPdf } from '../TableSheetPdf';
|
||||
import { PurchasesByItemsTableInjectable } from './PurchasesByItemsTableInjectable';
|
||||
import { IPurchasesByItemsReportQuery } from '@/interfaces/PurchasesByItemsSheet';
|
||||
|
||||
@Service()
|
||||
export class PurchasesByItemsPdf {
|
||||
@Inject()
|
||||
private purchasesByItemsTable: PurchasesByItemsTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private tableSheetPdf: TableSheetPdf;
|
||||
|
||||
/**
|
||||
* Converts the given journal sheet table to pdf.
|
||||
* @param {number} tenantId - Tenant ID.
|
||||
* @param {IBalanceSheetQuery} query - Balance sheet query.
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: IPurchasesByItemsReportQuery
|
||||
): Promise<Buffer> {
|
||||
const table = await this.purchasesByItemsTable.table(tenantId, query);
|
||||
const sheetName = 'Purchases By Items';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { SalesTaxLiabilitySummaryQuery } from '@/interfaces/SalesTaxLiabilitySum
|
||||
import { SalesTaxLiabilitySummaryTableInjectable } from './SalesTaxLiabilitySummaryTableInjectable';
|
||||
import { SalesTaxLiabilitySummaryExportInjectable } from './SalesTaxLiabilitySummaryExportInjectable';
|
||||
import { SalesTaxLiabilitySummaryService } from './SalesTaxLiabilitySummaryService';
|
||||
import { SalesTaxLiabiltiySummaryPdf } from './SalesTaxLiabiltiySummaryPdf';
|
||||
|
||||
@Service()
|
||||
export class SalesTaxLiabilitySummaryApplication {
|
||||
@@ -15,6 +16,9 @@ export class SalesTaxLiabilitySummaryApplication {
|
||||
@Inject()
|
||||
private salesTaxLiabilityTable: SalesTaxLiabilitySummaryTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private salesTaxLiabiltiyPdf: SalesTaxLiabiltiySummaryPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the sales tax liability summary in json format.
|
||||
* @param {number} tenantId
|
||||
@@ -60,4 +64,17 @@ export class SalesTaxLiabilitySummaryApplication {
|
||||
): Promise<string> {
|
||||
return this.salesTaxLiabilityExport.csv(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the sales tax liability summary in PDF format.
|
||||
* @param {number} tenantId
|
||||
* @param {SalesTaxLiabilitySummaryQuery} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(
|
||||
tenantId: number,
|
||||
query: SalesTaxLiabilitySummaryQuery
|
||||
): Promise<Buffer> {
|
||||
return this.salesTaxLiabiltiyPdf.pdf(tenantId, query):
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { TableSheetPdf } from '../TableSheetPdf';
|
||||
import { SalesTaxLiabilitySummaryTableInjectable } from './SalesTaxLiabilitySummaryTableInjectable';
|
||||
import { ISalesByItemsReportQuery } from '@/interfaces';
|
||||
import { SalesTaxLiabilitySummaryQuery } from '@/interfaces/SalesTaxLiabilitySummary';
|
||||
|
||||
@Service()
|
||||
export class SalesTaxLiabiltiySummaryPdf {
|
||||
@Inject()
|
||||
private salesTaxLiabiltiySummaryTable: SalesTaxLiabilitySummaryTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private tableSheetPdf: TableSheetPdf;
|
||||
|
||||
/**
|
||||
* Converts the given sales tax liability summary table to pdf.
|
||||
* @param {number} tenantId - Tenant ID.
|
||||
* @param {ISalesByItemsReportQuery} query - Balance sheet query.
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: SalesTaxLiabilitySummaryQuery
|
||||
): Promise<Buffer> {
|
||||
const table = await this.salesTaxLiabiltiySummaryTable.table(tenantId, query);
|
||||
const sheetName = 'Sales Tax Liability Summary';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import { TransactionsByCustomersTableInjectable } from './TransactionsByCustomersTableInjectable';
|
||||
import { TransactionsByCustomersExportInjectable } from './TransactionsByCustomersExportInjectable';
|
||||
import { TransactionsByCustomersSheet } from './TransactionsByCustomersService';
|
||||
import { TransactionsByCustomersPdf } from './TransactionsByCustomersPdf';
|
||||
|
||||
@Service()
|
||||
export class TransactionsByCustomerApplication {
|
||||
@@ -18,6 +19,9 @@ export class TransactionsByCustomerApplication {
|
||||
@Inject()
|
||||
private transactionsByCustomersSheet: TransactionsByCustomersSheet;
|
||||
|
||||
@Inject()
|
||||
private transactionsByCustomersPdf: TransactionsByCustomersPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by customers sheet in json format.
|
||||
* @param {number} tenantId
|
||||
@@ -69,4 +73,17 @@ export class TransactionsByCustomerApplication {
|
||||
): Promise<Buffer> {
|
||||
return this.transactionsByCustomersExport.xlsx(tenantId, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by vendors sheet in PDF format.
|
||||
* @param {number} tenantId
|
||||
* @param {ITransactionsByCustomersFilter} query
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public pdf(
|
||||
tenantId: number,
|
||||
query: ITransactionsByCustomersFilter
|
||||
): Promise<Buffer> {
|
||||
return this.transactionsByCustomersPdf.pdf(tenantId, query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { ITransactionsByCustomersFilter } from '@/interfaces';
|
||||
import { Inject } from 'typedi';
|
||||
import { TableSheetPdf } from '../TableSheetPdf';
|
||||
import { TransactionsByCustomersTableInjectable } from './TransactionsByCustomersTableInjectable';
|
||||
|
||||
export class TransactionsByCustomersPdf {
|
||||
@Inject()
|
||||
private transactionsByCustomersTable: TransactionsByCustomersTableInjectable;
|
||||
|
||||
@Inject()
|
||||
private tableSheetPdf: TableSheetPdf;
|
||||
|
||||
/**
|
||||
* Retrieves the transactions by customers in PDF format.
|
||||
* @param {number} tenantId - Tenant ID.
|
||||
* @param {IBalanceSheetQuery} query - Balance sheet query.
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
public async pdf(
|
||||
tenantId: number,
|
||||
query: ITransactionsByCustomersFilter
|
||||
): Promise<Buffer> {
|
||||
const table = await this.transactionsByCustomersTable.table(
|
||||
tenantId,
|
||||
query
|
||||
);
|
||||
const sheetName = 'Transactions By Customers';
|
||||
|
||||
return this.tableSheetPdf.convertToPdf(
|
||||
tenantId,
|
||||
table.table,
|
||||
sheetName,
|
||||
table.meta.baseCurrency
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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