diff --git a/packages/server/src/models/SaleInvoice.ts b/packages/server/src/models/SaleInvoice.ts
index 025e7edb5..883b39ce6 100644
--- a/packages/server/src/models/SaleInvoice.ts
+++ b/packages/server/src/models/SaleInvoice.ts
@@ -415,7 +415,8 @@ export default class SaleInvoice extends mixin(TenantModel, [
const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
const {
TransactionPaymentServiceEntry,
- } = require('models/TransactionPaymentServiceEntry');
+ } = require('models/TransactionPaymentServiceEntry');
+ const { PdfTemplate } = require('models/PdfTemplate');
return {
/**
@@ -593,6 +594,18 @@ export default class SaleInvoice extends mixin(TenantModel, [
query.where('reference_type', 'SaleInvoice');
},
},
+
+ /**
+ * Sale invoice may belongs to pdf branding template.
+ */
+ pdfTemplate: {
+ relation: Model.BelongsToOneRelation,
+ modelClass: PdfTemplate,
+ join: {
+ from: 'sales_invoices.pdfTemplateId',
+ to: 'pdf_templates.id',
+ }
+ },
};
}
diff --git a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts
index 740b13d37..6a8f1b388 100644
--- a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts
+++ b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts
@@ -1,10 +1,9 @@
import moment from 'moment';
+import { Inject, Service } from 'typedi';
import { ServiceError } from '@/exceptions';
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { PaymentLink } from '@/system/models';
-import { Inject, Service } from 'typedi';
-import { GeneratePaymentLinkTransformer } from './GeneratePaymentLinkTransformer';
import { GetInvoicePaymentLinkMetaTransformer } from './GetInvoicePaymentLinkTransformer';
import { initalizeTenantServices } from '@/api/middleware/TenantDependencyInjection';
@@ -46,7 +45,7 @@ export class GetInvoicePaymentLinkMetadata {
const invoice = await SaleInvoice.query()
.findById(paymentLink.resourceId)
- .withGraphFetched('entries')
+ .withGraphFetched('entries.item')
.withGraphFetched('customer')
.throwIfNotFound();
diff --git a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts
index 39909a805..0c75a49ae 100644
--- a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts
+++ b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts
@@ -1,3 +1,4 @@
+import { ItemEntryTransformer } from './ItemEntryTransformer';
import { SaleInvoiceTransformer } from './SaleInvoiceTransformer';
export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer {
@@ -33,6 +34,9 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
'dueDate',
'dueDateFormatted',
'invoiceNo',
+ 'invoiceMessage',
+ 'termsConditions',
+ 'entries',
];
};
@@ -43,4 +47,50 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer
public companyName() {
return 'Bigcapital Technology, Inc.';
}
+
+ /**
+ * Retrieves the entries of the sale invoice.
+ * @param {ISaleInvoice} invoice
+ * @returns {}
+ */
+ protected entries = (invoice) => {
+ return this.item(
+ invoice.entries,
+ new GetInvoicePaymentLinkEntryMetaTransformer(),
+ {
+ currencyCode: invoice.currencyCode,
+ }
+ );
+ };
+}
+
+class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer {
+ /**
+ * Include these attributes to item entry object.
+ * @returns {Array}
+ */
+ public includeAttributes = (): string[] => {
+ return [
+ 'quantity',
+ 'quantityFormatted',
+ 'rate',
+ 'rateFormatted',
+ 'total',
+ 'totalFormatted',
+ 'itemName',
+ 'description',
+ ];
+ };
+
+ itemName(entry) {
+ return entry.item.name;
+ }
+
+ /**
+ * Exclude these attributes from payment link object.
+ * @returns {Array}
+ */
+ public excludeAttributes = (): string[] => {
+ return ['*'];
+ };
}
diff --git a/packages/webapp/src/containers/PaymentPortal/PaymentPortalPage.tsx b/packages/webapp/src/containers/PaymentPortal/PaymentPortalPage.tsx
index 9a9b817f5..a2cc12cdd 100644
--- a/packages/webapp/src/containers/PaymentPortal/PaymentPortalPage.tsx
+++ b/packages/webapp/src/containers/PaymentPortal/PaymentPortalPage.tsx
@@ -10,14 +10,11 @@ export default function PaymentPortalPage() {
const { linkId } = useParams<{ linkId: string }>();
return (
- <>
-
-
-
-
-
-
-
- >
+
+
+
+
+
+
);
}
diff --git a/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewContent.tsx b/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewContent.tsx
index dcb7a0216..9bda399f7 100644
--- a/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewContent.tsx
+++ b/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewContent.tsx
@@ -1,15 +1,36 @@
// @ts-nocheck
import { Box, DrawerBody, DrawerHeaderContent } from '@/components';
import { InvoicePaperTemplate } from '@/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate';
+import { usePaymentPortalBoot } from '../../PaymentPortalBoot';
export function PaymentInvoicePreviewContent() {
+ const { sharableLinkMeta } = usePaymentPortalBoot();
+
return (
<>
-
+ ({
+ item: entry.itemName,
+ description: entry.description,
+ quantity: entry.quantityFormatted,
+ rate: entry.rateFormatted,
+ total: entry.totalFormatted,
+ }))}
+ />
>
diff --git a/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer.tsx b/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer.tsx
index 5a41866d6..346dc5468 100644
--- a/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer.tsx
+++ b/packages/webapp/src/containers/PaymentPortal/drawers/PaymentInvoicePreviewDrawer/PaymentInvoicePreviewDrawer.tsx
@@ -1,10 +1,10 @@
// @ts-nocheck
import React from 'react';
import * as R from 'ramda';
+import { Position } from '@blueprintjs/core';
import { Drawer, DrawerSuspense } from '@/components';
import withDrawers from '@/containers/Drawer/withDrawers';
import { PaymentInvoicePreviewContent } from './PaymentInvoicePreviewContent';
-import { Position } from '@blueprintjs/core';
/**
*
diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx
index 7aeb70950..bc67bb7eb 100644
--- a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx
+++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx
@@ -99,16 +99,16 @@ export function InvoicePaperTemplate({
dueDate = 'September 3, 2024',
dueDateLabel = 'Date due',
- showDueDate,
+ showDueDate = true,
dateIssue = 'September 3, 2024',
dateIssueLabel = 'Date of issue',
- showDateIssue,
+ showDateIssue = true,
// dateIssue,
invoiceNumberLabel = 'Invoice number',
invoiceNumber = '346D3D40-0001',
- showInvoiceNumber,
+ showInvoiceNumber = true,
// Address
showBillingToAddress = true,
@@ -281,12 +281,12 @@ export function InvoicePaperTemplate({
- {showTermsConditions && (
+ {showTermsConditions && termsConditions && (
{termsConditions}
)}
- {showStatement && (
+ {showStatement && statement && (
{statement}
diff --git a/packages/webapp/src/hooks/query/payment-link.ts b/packages/webapp/src/hooks/query/payment-link.ts
index 1f12df834..08634ea5f 100644
--- a/packages/webapp/src/hooks/query/payment-link.ts
+++ b/packages/webapp/src/hooks/query/payment-link.ts
@@ -67,6 +67,18 @@ export interface GetSharableLinkMetaResponse {
totalLocalFormatted: string;
customerName: string;
companyName: string;
+ invoiceMessage: string;
+ termsConditions: string;
+ entries: Array<{
+ description: string;
+ itemName: string;
+ quantity: number;
+ quantityFormatted: string;
+ rate: number;
+ rateFormatted: string;
+ total: number;
+ totalFormatted: string;
+ }>;
}
/**