feat: invoice, estimate and receipt printing.

This commit is contained in:
a.bouhuolia
2021-08-17 10:47:04 +02:00
parent 70939c5741
commit 160b8b6a1b
50 changed files with 3607 additions and 120 deletions

View 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;
}
}