mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
feat: invoice, estimate and receipt printing.
This commit is contained in:
43
server/src/services/Sales/Estimates/SaleEstimatesPdf.ts
Normal file
43
server/src/services/Sales/Estimates/SaleEstimatesPdf.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import PdfService from 'services/PDF/PdfService';
|
||||
import { templateRender } from 'utils';
|
||||
import HasTenancyService from 'services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export default class SaleEstimatesPdf {
|
||||
@Inject()
|
||||
pdfService: PdfService;
|
||||
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Retrieve sale invoice pdf content.
|
||||
* @param {} saleInvoice -
|
||||
*/
|
||||
async saleEstimatePdf(tenantId: number, saleEstimate) {
|
||||
const i18n = this.tenancy.i18n(tenantId);
|
||||
const settings = this.tenancy.settings(tenantId);
|
||||
|
||||
const organizationName = settings.get({
|
||||
group: 'organization',
|
||||
key: 'name',
|
||||
});
|
||||
const organizationEmail = settings.get({
|
||||
group: 'organization',
|
||||
key: 'email',
|
||||
});
|
||||
const htmlContent = templateRender('modules/estimate-regular', {
|
||||
saleEstimate,
|
||||
organizationName,
|
||||
organizationEmail,
|
||||
...i18n,
|
||||
});
|
||||
|
||||
console.log(htmlContent, 'XXX');
|
||||
|
||||
const pdfContent = await this.pdfService.pdfDocument(htmlContent);
|
||||
|
||||
return pdfContent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user