mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: estimate, receipt, credit note mail preview
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user