mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
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;
|
|
}
|
|
}
|