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

@@ -48,8 +48,8 @@ block head
box-sizing: border-box;
display: flex;
flex-flow: wrap;
-webkit-box-align: center;
align-items: center;
-webkit-box-align: flex-start;
align-items: flex-start;
-webkit-box-pack: start;
justify-content: flex-start;
gap: 10px;

View File

@@ -47,9 +47,7 @@ block head
box-sizing: border-box;
display: flex;
flex-flow: wrap;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: start;
align-items: flex-start;
justify-content: flex-start;
gap: 10px;
margin-bottom: 24px;

View File

@@ -48,9 +48,7 @@ block head
box-sizing: border-box;
display: flex;
flex-flow: wrap;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: start;
align-items: flex-start;
justify-content: flex-start;
gap: 10px;
margin-bottom: 24px;

View File

@@ -46,9 +46,7 @@ block head
box-sizing: border-box;
display: flex;
flex-flow: wrap;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: start;
align-items: flex-start;
justify-content: flex-start;
gap: 10px;
margin-bottom: 24px;

View File

@@ -46,8 +46,8 @@ block head
box-sizing: border-box;
display: flex;
flex-flow: wrap;
-webkit-box-align: center;
align-items: center;
-webkit-box-align: flex-start;
align-items: flex-start;
-webkit-box-pack: start;
justify-content: flex-start;
gap: 10px;

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,

View File

@@ -120,19 +120,18 @@ PaperTemplate.MutedText = () => {};
PaperTemplate.Text = () => {};
PaperTemplate.AddressesGroup = (props: GroupProps) => {
return <Group spacing={10} {...props} className={styles.addressRoot} />;
};
PaperTemplate.Address = ({
children,
}: {
children: React.ReactNode;
}) => {
return (
<Box>
{children}
</Box>
<Group
spacing={10}
align={'flex-start'}
{...props}
className={styles.addressRoot}
/>
);
};
PaperTemplate.Address = ({ children }: { children: React.ReactNode }) => {
return <Box>{children}</Box>;
};
PaperTemplate.Statement = ({
label,

View File

@@ -14,17 +14,19 @@ export const initialValues = {
showPaymentReceivedNumber: true,
paymentReceivedNumberLabel: 'Payment number',
// Payment number
showPaymentReceivedDate: true,
paymentReceivedDateLabel: 'Date of Issue',
// Company name
companyName: 'Bigcapital Technology, Inc.',
// Addresses
showCustomerAddress: true,
// Customer address
showCompanyAddress: true,
customerAddress: '',
companyAddress: '',
// Company address
showCustomerAddress: true,
billedToLabel: 'Billed To',
// Entries
@@ -33,10 +35,11 @@ export const initialValues = {
itemRateLabel: 'Rate',
itemTotalLabel: 'Total',
// Totals
// Subtotal
showSubtotal: true,
subtotalLabel: 'Subtotal',
// Total
showTotal: true,
totalLabel: 'Total',
};

View File

@@ -12,18 +12,23 @@ export interface PaymentReceivedCustomizeValues extends BrandingTemplateValues {
showInvoiceNumber?: boolean;
invoiceNumberLabel?: string;
// # Issue date
showDateIssue?: boolean;
dateIssueLabel?: string;
// # Due date
showDueDate?: boolean;
dueDateLabel?: string;
// Company name
// # Company name
companyName?: string;
// Addresses
showBilledFromAddress?: boolean;
showBillingToAddress?: boolean;
// # Customer address
showCustomerAddress?: boolean;
// # Company address
showCompanyAddress?: boolean;
companyAddress?: string;
billedToLabel?: string;
// Entries
@@ -54,6 +59,7 @@ export interface PaymentReceivedCustomizeValues extends BrandingTemplateValues {
termsConditionsLabel?: string;
showTermsConditions?: boolean;
// # Statement
statementLabel?: string;
showStatement?: boolean;
}