feat: PDF templates company/customer address

This commit is contained in:
Ahmed Bouhuolia
2024-09-29 19:31:00 +02:00
parent 6b6027a588
commit 776b69475c
10 changed files with 101 additions and 79 deletions

View File

@@ -185,23 +185,10 @@ export const defaultEstimatePdfBrandingAttributes = {
companyName: '',
billedToAddress: [
'Bigcapital Technology, Inc.',
'131 Continental Dr Suite 305 Newark,',
'Delaware 19713',
'United States',
'+1 762-339-5634',
'ahmed@bigcapital.app',
],
billedFromAddress: [
'131 Continental Dr Suite 305 Newark,',
'Delaware 19713',
'United States',
'+1 762-339-5634',
'ahmed@bigcapital.app',
],
showBilledFromAddress: true,
showBilledToAddress: true,
customerAddress: '',
companyAddress: '',
showCustomerAddress: true,
showCompanyAddress: true,
billedToLabel: 'Billed To',
total: '$1000.00',

View File

@@ -2,12 +2,16 @@ import { Inject, Service } from 'typedi';
import { mergePdfTemplateWithDefaultAttributes } from './utils';
import { GetPdfTemplate } from '@/services/PdfTemplate/GetPdfTemplate';
import { defaultEstimatePdfBrandingAttributes } from '../Estimates/constants';
import { GetOrganizationBrandingAttributes } from '@/services/PdfTemplate/GetOrganizationBrandingAttributes';
@Service()
export class SaleEstimatePdfTemplate {
@Inject()
private getPdfTemplateService: GetPdfTemplate;
@Inject()
private getOrgBrandingAttrs: GetOrganizationBrandingAttributes;
/**
* Retrieves the estimate pdf template.
* @param {number} tenantId
@@ -19,9 +23,19 @@ export class SaleEstimatePdfTemplate {
tenantId,
estimateTemplateId
);
// Retreives the organization branding attributes.
const commonOrgBrandingAttrs =
await this.getOrgBrandingAttrs.getOrganizationBrandingAttributes(
tenantId
);
const orgainizationBrandingAttrs = {
...defaultEstimatePdfBrandingAttributes,
...commonOrgBrandingAttrs,
};
const attributes = mergePdfTemplateWithDefaultAttributes(
template.attributes,
defaultEstimatePdfBrandingAttributes
orgainizationBrandingAttrs
);
return {
...template,