feat: estimate, receipt, credit note mail preview

This commit is contained in:
Ahmed Bouhuolia
2024-11-17 15:45:55 +02:00
parent d115ebde12
commit 53ab40a075
37 changed files with 1531 additions and 396 deletions

View File

@@ -8,6 +8,7 @@ import { transformEstimateToPdfTemplate } from './utils';
import { EstimatePdfBrandingAttributes } from './constants';
import events from '@/subscribers/events';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import { renderEstimatePaperTemplateHtml } from '@bigcapital/pdf-templates';
@Service()
export class SaleEstimatesPdf {
@@ -29,6 +30,22 @@ export class SaleEstimatesPdf {
@Inject()
private eventPublisher: EventPublisher;
/**
* Retrieve sale estimate html content.
* @param {number} tenantId -
* @param {number} invoiceId -
*/
public async saleEstimateHtml(
tenantId: number,
estimateId: number
): Promise<string> {
const brandingAttributes = await this.getEstimateBrandingAttributes(
tenantId,
estimateId
);
return renderEstimatePaperTemplateHtml({ ...brandingAttributes });
}
/**
* Retrieve sale invoice pdf content.
* @param {number} tenantId -
@@ -42,15 +59,9 @@ export class SaleEstimatesPdf {
tenantId,
saleEstimateId
);
const brandingAttributes = await this.getEstimateBrandingAttributes(
tenantId,
saleEstimateId
);
const htmlContent = await this.templateInjectable.render(
tenantId,
'modules/estimate-regular',
brandingAttributes
);
// Retireves the sale estimate html.
const htmlContent = await this.saleEstimateHtml(tenantId, saleEstimateId);
const content = await this.chromiumlyTenancy.convertHtmlContent(
tenantId,
htmlContent