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

@@ -152,6 +152,19 @@ export class SaleReceiptApplication {
);
}
/**
* Retrieves the given sale receipt html.
* @param {number} tenantId
* @param {number} saleReceiptId
* @returns {Promise<string>}
*/
public getSaleReceiptHtml(tenantId: number, saleReceiptId: number) {
return this.getSaleReceiptPdfService.saleReceiptHtml(
tenantId,
saleReceiptId
);
}
/**
* Notify receipt customer by SMS of the given sale receipt.
* @param {number} tenantId

View File

@@ -8,6 +8,7 @@ import { transformReceiptToBrandingTemplateAttributes } from './utils';
import { ISaleReceiptBrandingTemplateAttributes } from '@/interfaces';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import events from '@/subscribers/events';
import { renderReceiptPaperTemplateHtml } from '@bigcapital/pdf-templates';
@Service()
export class SaleReceiptsPdf {
@@ -29,6 +30,19 @@ export class SaleReceiptsPdf {
@Inject()
private eventPublisher: EventPublisher;
/**
* Retrieves sale receipt html content.
* @param {number} tennatId
* @param {number} saleReceiptId
*/
public async saleReceiptHtml(tennatId: number, saleReceiptId: number) {
const brandingAttributes = await this.getReceiptBrandingAttributes(
tennatId,
saleReceiptId
);
return renderReceiptPaperTemplateHtml(brandingAttributes);
}
/**
* Retrieves sale invoice pdf content.
* @param {number} tenantId -
@@ -41,16 +55,9 @@ export class SaleReceiptsPdf {
): Promise<[Buffer, string]> {
const filename = await this.getSaleReceiptFilename(tenantId, saleReceiptId);
const brandingAttributes = await this.getReceiptBrandingAttributes(
tenantId,
saleReceiptId
);
// Converts the receipt template to html content.
const htmlContent = await this.templateInjectable.render(
tenantId,
'modules/receipt-regular',
brandingAttributes
);
const htmlContent = await this.saleReceiptHtml(tenantId, saleReceiptId);
// Renders the html content to pdf document.
const content = await this.chromiumlyTenancy.convertHtmlContent(
tenantId,