fix: pdf templates server-side rendered

This commit is contained in:
Ahmed Bouhuolia
2024-09-30 11:15:05 +02:00
parent 863c7ad99f
commit 783387dce6
10 changed files with 46 additions and 42 deletions

View File

@@ -179,14 +179,15 @@ export const defaultInvoicePdfTemplateAttributes = {
dateIssueLabel: 'Date of issue',
showDateIssue: true,
// dateIssue,
// # Invoice number,
invoiceNumberLabel: 'Invoice number',
showInvoiceNumber: true,
// Address
// # Customer address
showCustomerAddress: true,
customerAddress: '',
// # Company address
showCompanyAddress: true,
companyAddress: '',
billedToLabel: 'Billed To',

View File

@@ -10,35 +10,36 @@ export class PaymentReceivedBrandingTemplate {
@Inject()
private getPdfTemplateService: GetPdfTemplate;
@Inject()
private getOrgBrandingAttributes: GetOrganizationBrandingAttributes;
/**
* Retrieves the payment received pdf template.
* @param {number} tenantId
* @param {number} paymentTemplateId
* @returns
* @param {number} tenantId
* @param {number} paymentTemplateId
* @returns
*/
public async getPaymentReceivedPdfTemplate(
tenantId: number,
paymentTemplateId: number
) {
) {
const template = await this.getPdfTemplateService.getPdfTemplate(
tenantId,
paymentTemplateId
);
// Retrieves the organization branding attributes.
const commonOrgBrandingAttrs = this.getOrgBrandingAttributes.getOrganizationBrandingAttributes(tenantId);
const commonOrgBrandingAttrs =
await this.getOrgBrandingAttributes.getOrganizationBrandingAttributes(
tenantId
);
// Merges the default branding attributes with common organization branding attrs.
const organizationBrandingAttrs = {
...defaultPaymentReceivedPdfTemplateAttributes,
...commonOrgBrandingAttrs,
};
const attributes = mergePdfTemplateWithDefaultAttributes(
template.attributes,
organizationBrandingAttrs
organizationBrandingAttrs
);
return {
...template,