From 2f9adfd908f64c0b59695084981147e4992fcd77 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 25 Sep 2024 11:04:17 +0200 Subject: [PATCH 1/2] fix: Invoice pdf customize --- .../services/Attachments/S3UploadPipeline.ts | 8 ++++++-- .../BrandingTemplateForm.tsx | 5 ----- .../src/containers/BrandingTemplates/types.ts | 1 + .../CreditNotePaperTemplate.tsx | 8 ++++++-- .../CreditNoteCustomize/constants.ts | 4 ++-- .../CreditNotes/CreditNoteCustomize/types.ts | 1 - .../EstimateCustomizeFieldsGeneral.tsx | 1 - .../EstimatePaperTemplate.tsx | 8 +++++--- .../Estimates/EstimateCustomize/constants.ts | 6 +++--- .../Estimates/EstimateCustomize/types.ts | 5 +++-- .../InvoiceCustomizeGeneralFields.tsx | 19 +++++++++++++++++-- .../InvoiceCustomize/InvoicePaperTemplate.tsx | 6 +++--- .../InvoiceCustomize/PaperTemplate.tsx | 12 ++++++------ .../Invoices/InvoiceCustomize/constants.ts | 2 ++ .../PaymentReceivedCustomizeFieldsGeneral.tsx | 1 - .../PaymentReceivedPaperTemplate.tsx | 9 +++++++-- .../PaymentReceivedCustomize/constants.ts | 6 +++--- .../PaymentReceivedCustomize/types.ts | 1 - .../ReceiptCustomize/ReceiptPaperTemplate.tsx | 11 ++++++++--- .../Receipts/ReceiptCustomize/constants.ts | 4 ++-- .../Sales/Receipts/ReceiptCustomize/types.ts | 1 - 21 files changed, 74 insertions(+), 45 deletions(-) diff --git a/packages/server/src/services/Attachments/S3UploadPipeline.ts b/packages/server/src/services/Attachments/S3UploadPipeline.ts index b2443e318..26d00f124 100644 --- a/packages/server/src/services/Attachments/S3UploadPipeline.ts +++ b/packages/server/src/services/Attachments/S3UploadPipeline.ts @@ -1,17 +1,16 @@ +import { NextFunction, Request, Response } from 'express'; import multer from 'multer'; import type { Multer } from 'multer'; import multerS3 from 'multer-s3'; import { s3 } from '@/lib/S3/S3'; import { Service } from 'typedi'; import config from '@/config'; -import { NextFunction, Request, Response } from 'express'; @Service() export class AttachmentUploadPipeline { /** * Middleware to ensure that S3 configuration is properly set before proceeding. * This function checks if the necessary S3 configuration keys are present and throws an error if any are missing. - * * @param req The HTTP request object. * @param res The HTTP response object. * @param next The callback to pass control to the next middleware function. @@ -49,6 +48,11 @@ export class AttachmentUploadPipeline { key: function (req, file, cb) { cb(null, Date.now().toString()); }, + acl: function(req, file, cb) { + // Conditionally set file to public or private based on isPublic flag + const aclValue = true ? 'public-read' : 'private'; + cb(null, aclValue); // Set ACL based on the isPublic flag + } }), }); } diff --git a/packages/webapp/src/containers/BrandingTemplates/BrandingTemplateForm.tsx b/packages/webapp/src/containers/BrandingTemplates/BrandingTemplateForm.tsx index 97eaa2da9..1f3c77d7f 100644 --- a/packages/webapp/src/containers/BrandingTemplates/BrandingTemplateForm.tsx +++ b/packages/webapp/src/containers/BrandingTemplates/BrandingTemplateForm.tsx @@ -134,8 +134,3 @@ export function BrandingTemplateForm({ export const validationSchema = Yup.object().shape({ templateName: Yup.string().required('Template Name is required'), }); - - -// Initial values - companyLogoKey, companyLogoUri -// Form - _companyLogoFile, companyLogoKey, companyLogoUri -// Request - companyLogoKey diff --git a/packages/webapp/src/containers/BrandingTemplates/types.ts b/packages/webapp/src/containers/BrandingTemplates/types.ts index e60c142f5..b4c01223a 100644 --- a/packages/webapp/src/containers/BrandingTemplates/types.ts +++ b/packages/webapp/src/containers/BrandingTemplates/types.ts @@ -3,6 +3,7 @@ export interface BrandingTemplateValues { templateName: string; + // Company logo companyLogoKey?: string; companyLogoUri?: string; } \ No newline at end of file diff --git a/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/CreditNotePaperTemplate.tsx b/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/CreditNotePaperTemplate.tsx index 90644193b..93cef8956 100644 --- a/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/CreditNotePaperTemplate.tsx +++ b/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/CreditNotePaperTemplate.tsx @@ -53,10 +53,14 @@ export interface CreditNotePaperTemplateProps extends PaperTemplateProps { } export function CreditNotePaperTemplate({ + // # Colors primaryColor, secondaryColor, + + // # Company Logo showCompanyLogo = true, - companyLogo, + companyLogoUri = '', + companyName = 'Bigcapital Technology, Inc.', // Address @@ -123,7 +127,7 @@ export function CreditNotePaperTemplate({ primaryColor={primaryColor} secondaryColor={secondaryColor} showCompanyLogo={showCompanyLogo} - companyLogo={companyLogo} + companyLogoUri={companyLogoUri} bigtitle={'Credit Note'} > diff --git a/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/constants.ts b/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/constants.ts index e1beac48f..67d421193 100644 --- a/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/constants.ts +++ b/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/constants.ts @@ -7,8 +7,8 @@ export const initialValues = { // Company logo. showCompanyLogo: true, - companyLogo: - 'https://cdn-development.mercury.com/demo-assets/avatars/mercury-demo-dark.png', + companyLogoKey: '', + companyLogoUri: '', // Address showBilledToAddress: true, diff --git a/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/types.ts b/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/types.ts index 5527a0e3c..b627dd2f9 100644 --- a/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/types.ts +++ b/packages/webapp/src/containers/Sales/CreditNotes/CreditNoteCustomize/types.ts @@ -7,7 +7,6 @@ export interface CreditNoteCustomizeValues extends BrandingTemplateValues { // Company Logo showCompanyLogo?: boolean; - companyLogo?: string; // Entries itemNameLabel?: string; diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeFieldsGeneral.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeFieldsGeneral.tsx index a017599d5..8b859392d 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeFieldsGeneral.tsx +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimateCustomizeFieldsGeneral.tsx @@ -76,7 +76,6 @@ export function EstimateCustomizeGeneralField() { name={'showCompanyLogo'} label={'Display company logo in the paper'} style={{ fontSize: 14 }} - large fastField /> diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimatePaperTemplate.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimatePaperTemplate.tsx index 6a93a2a72..7b1e6335f 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimatePaperTemplate.tsx +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/EstimatePaperTemplate.tsx @@ -1,4 +1,4 @@ -import { Group, Stack } from '@/components'; +import { Stack } from '@/components'; import { PaperTemplate, PaperTemplateProps, @@ -57,8 +57,10 @@ export interface EstimatePaperTemplateProps extends PaperTemplateProps { export function EstimatePaperTemplate({ primaryColor, secondaryColor, + showCompanyLogo = true, - companyLogo, + companyLogoUri = '', + companyName, billedToAddress = [ @@ -122,7 +124,7 @@ export function EstimatePaperTemplate({ primaryColor={primaryColor} secondaryColor={secondaryColor} showCompanyLogo={showCompanyLogo} - companyLogo={companyLogo} + companyLogoUri={companyLogoUri} bigtitle={'Estimate'} > diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/constants.ts b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/constants.ts index 14c0c2196..8f5046849 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/constants.ts +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/constants.ts @@ -1,14 +1,14 @@ export const initialValues = { templateName: '', - + // Colors primaryColor: '#2c3dd8', secondaryColor: '#2c3dd8', // Company logo. showCompanyLogo: true, - companyLogo: - 'https://cdn-development.mercury.com/demo-assets/avatars/mercury-demo-dark.png', + companyLogoKey: '', + companyLogoUri: '', // Top details. showEstimateNumber: true, diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/types.ts b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/types.ts index 5bfa3f794..8646f9ee6 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/types.ts +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateCustomize/types.ts @@ -1,4 +1,4 @@ -import { BrandingTemplateValues } from "@/containers/BrandingTemplates/types"; +import { BrandingTemplateValues } from '@/containers/BrandingTemplates/types'; export interface EstimateCustomizeValues extends BrandingTemplateValues { // Colors @@ -7,7 +7,8 @@ export interface EstimateCustomizeValues extends BrandingTemplateValues { // Company Logo showCompanyLogo?: boolean; - companyLogo?: string; + companyLogoKey?: string; + companyLogoUri?: string; // Top details. estimateNumberLabel?: string; diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeGeneralFields.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeGeneralFields.tsx index 11d789f05..e31c41e09 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeGeneralFields.tsx +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoiceCustomizeGeneralFields.tsx @@ -13,6 +13,10 @@ import { CreditCardIcon } from '@/icons/CreditCardIcon'; import { Overlay } from './Overlay'; import { useIsTemplateNamedFilled } from '@/containers/BrandingTemplates/utils'; import { BrandingCompanyLogoUploadField } from '@/containers/ElementCustomize/components/BrandingCompanyLogoUploadField'; +import { Link } from 'react-router-dom'; +import { MANAGE_LINK_URL } from './constants'; +import { useDrawerContext } from '@/components/Drawer/DrawerProvider'; +import { useDrawerActions } from '@/hooks/state'; export function InvoiceCustomizeGeneralField() { const isTemplateNameFilled = useIsTemplateNamedFilled(); @@ -93,6 +97,13 @@ export function InvoiceCustomizeGeneralField() { } function InvoiceCustomizePaymentManage() { + const { name } = useDrawerContext(); + const { closeDrawer } = useDrawerActions(); + + const handleLinkClick = () => { + closeDrawer(name); + }; + return ( Accept payment methods - + Manage - + ); } diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx index e00b81fa2..3e56cafd8 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/InvoicePaperTemplate.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { PaperTemplate, PaperTemplateTotalBorder } from './PaperTemplate'; -import { Group, Stack } from '@/components'; +import { Stack } from '@/components'; interface PapaerLine { item?: string; @@ -95,7 +95,7 @@ export function InvoicePaperTemplate({ companyName = 'Bigcapital Technology, Inc.', showCompanyLogo = true, - companyLogoUri, + companyLogoUri = '', dueDate = 'September 3, 2024', dueDateLabel = 'Date due', @@ -185,7 +185,7 @@ export function InvoicePaperTemplate({ primaryColor={primaryColor} secondaryColor={secondaryColor} showCompanyLogo={showCompanyLogo} - companyLogo={companyLogoUri} + companyLogoUri={companyLogoUri} bigtitle={'Invoice'} > diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/PaperTemplate.tsx b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/PaperTemplate.tsx index c8daf0715..3b6e20d97 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/PaperTemplate.tsx +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/PaperTemplate.tsx @@ -9,7 +9,7 @@ export interface PaperTemplateProps { secondaryColor?: string; showCompanyLogo?: boolean; - companyLogo?: string; + companyLogoUri?: string; companyName?: string; bigtitle?: string; @@ -21,7 +21,7 @@ export function PaperTemplate({ primaryColor, secondaryColor, showCompanyLogo, - companyLogo, + companyLogoUri, bigtitle = 'Invoice', children, }: PaperTemplateProps) { @@ -32,9 +32,9 @@ export function PaperTemplate({

{bigtitle}

- {showCompanyLogo && ( + {showCompanyLogo && companyLogoUri && (
- +
)}
@@ -120,8 +120,8 @@ PaperTemplate.MutedText = () => {}; PaperTemplate.Text = () => {}; PaperTemplate.AddressesGroup = (props: GroupProps) => { - return -} + return ; +}; PaperTemplate.Address = ({ items, }: { diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/constants.ts b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/constants.ts index e020c0d3e..964406c43 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/constants.ts +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceCustomize/constants.ts @@ -1,3 +1,5 @@ +export const MANAGE_LINK_URL = '/preferences/payment-methods'; + export const initialValues = { templateName: '', diff --git a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedCustomizeFieldsGeneral.tsx b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedCustomizeFieldsGeneral.tsx index 94b1f29aa..09217cb05 100644 --- a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedCustomizeFieldsGeneral.tsx +++ b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedCustomizeFieldsGeneral.tsx @@ -76,7 +76,6 @@ export function PaymentReceivedCustomizeGeneralField() { name={'showCompanyLogo'} label={'Display company logo in the paper'} style={{ fontSize: 14 }} - large fastField /> diff --git a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedPaperTemplate.tsx b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedPaperTemplate.tsx index 51a9bbb3f..d8068c797 100644 --- a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedPaperTemplate.tsx +++ b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/PaymentReceivedPaperTemplate.tsx @@ -41,10 +41,15 @@ export interface PaymentReceivedPaperTemplateProps extends PaperTemplateProps { } export function PaymentReceivedPaperTemplate({ + // # Colors primaryColor, secondaryColor, + + // # Company logo showCompanyLogo = true, - companyLogo, + companyLogoUri, + + // # Company name companyName = 'Bigcapital Technology, Inc.', billedToAddress = [ @@ -94,7 +99,7 @@ export function PaymentReceivedPaperTemplate({ primaryColor={primaryColor} secondaryColor={secondaryColor} showCompanyLogo={showCompanyLogo} - companyLogo={companyLogo} + companyLogoUri={companyLogoUri} bigtitle={'Payment'} > diff --git a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/constants.ts b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/constants.ts index 4b735653a..1cdcc1b76 100644 --- a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/constants.ts +++ b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/constants.ts @@ -1,14 +1,14 @@ export const initialValues = { templateName: '', - + // Colors primaryColor: '#2c3dd8', secondaryColor: '#2c3dd8', // Company logo. showCompanyLogo: true, - companyLogo: - 'https://cdn-development.mercury.com/demo-assets/avatars/mercury-demo-dark.png', + companyLogoUri: '', + companyLogokey: '', // Top details. showPaymentReceivedNumber: true, diff --git a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/types.ts b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/types.ts index 1da7073b8..da5468a55 100644 --- a/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/types.ts +++ b/packages/webapp/src/containers/Sales/PaymentsReceived/PaymentReceivedCustomize/types.ts @@ -7,7 +7,6 @@ export interface PaymentReceivedCustomizeValues extends BrandingTemplateValues { // Company Logo showCompanyLogo?: boolean; - companyLogo?: string; // Top details. showInvoiceNumber?: boolean; diff --git a/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/ReceiptPaperTemplate.tsx b/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/ReceiptPaperTemplate.tsx index 3e0c5f3e4..13b409558 100644 --- a/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/ReceiptPaperTemplate.tsx +++ b/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/ReceiptPaperTemplate.tsx @@ -1,4 +1,4 @@ -import { Group, Stack } from '@/components'; +import { Stack } from '@/components'; import { PaperTemplate, PaperTemplateProps, @@ -53,10 +53,15 @@ export interface ReceiptPaperTemplateProps extends PaperTemplateProps { } export function ReceiptPaperTemplate({ + // # Colors primaryColor, secondaryColor, + + // # Company logo showCompanyLogo = true, - companyLogo, + companyLogoUri, + + // # Company name companyName = 'Bigcapital Technology, Inc.', // # Address @@ -117,7 +122,7 @@ export function ReceiptPaperTemplate({ primaryColor={primaryColor} secondaryColor={secondaryColor} showCompanyLogo={showCompanyLogo} - companyLogo={companyLogo} + companyLogoUri={companyLogoUri} bigtitle={'Receipt'} > diff --git a/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/constants.ts b/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/constants.ts index cffb4cd49..6f67d5a48 100644 --- a/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/constants.ts +++ b/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/constants.ts @@ -7,8 +7,8 @@ export const initialValues = { // Company logo. showCompanyLogo: true, - companyLogo: - 'https://cdn-development.mercury.com/demo-assets/avatars/mercury-demo-dark.png', + companyLogoKey: '', + companyLogoUri: '', // Receipt Number showReceiptNumber: true, diff --git a/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/types.ts b/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/types.ts index d9257b0a8..1fe5f2bf0 100644 --- a/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/types.ts +++ b/packages/webapp/src/containers/Sales/Receipts/ReceiptCustomize/types.ts @@ -7,7 +7,6 @@ export interface ReceiptCustomizeValues extends BrandingTemplateValues { // Company Logo showCompanyLogo?: boolean; - companyLogo?: string; // Receipt Number showReceiptNumber?: boolean; From 946872204b4581f4db697fbce1ce0a0a9300666e Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 25 Sep 2024 12:21:26 +0200 Subject: [PATCH 2/2] fix: payment page --- .../server/src/models/PaymentIntegration.ts | 11 ++++++++ .../GetPaymentServicesSpecificInvoice.ts | 2 +- .../Invoices/GetInvoicePaymentLinkMetadata.ts | 1 + .../GetInvoicePaymentLinkTransformer.ts | 28 +++++++++++++++++++ .../PaymentPortal/PaymentPortal.module.scss | 2 +- .../PaymentPortal/PaymentPortal.tsx | 7 +++++ .../PaymentInvoicePreviewContent.tsx | 4 +++ .../webapp/src/hooks/query/payment-link.ts | 7 ++++- 8 files changed, 59 insertions(+), 3 deletions(-) diff --git a/packages/server/src/models/PaymentIntegration.ts b/packages/server/src/models/PaymentIntegration.ts index 04ed8fb31..cb4c8c825 100644 --- a/packages/server/src/models/PaymentIntegration.ts +++ b/packages/server/src/models/PaymentIntegration.ts @@ -25,6 +25,17 @@ export class PaymentIntegration extends Model { return this.paymentEnabled && this.payoutEnabled; } + static get modifiers() { + return { + /** + * Query to filter enabled payment and payout. + */ + fullEnabled(query) { + query.where('paymentEnabled', true).andWhere('payoutEnabled', true); + }, + }; + } + static get jsonSchema() { return { type: 'object', diff --git a/packages/server/src/services/PaymentServices/GetPaymentServicesSpecificInvoice.ts b/packages/server/src/services/PaymentServices/GetPaymentServicesSpecificInvoice.ts index 447f95943..eaab16921 100644 --- a/packages/server/src/services/PaymentServices/GetPaymentServicesSpecificInvoice.ts +++ b/packages/server/src/services/PaymentServices/GetPaymentServicesSpecificInvoice.ts @@ -21,7 +21,7 @@ export class GetPaymentServicesSpecificInvoice { const { PaymentIntegration } = this.tenancy.models(tenantId); const paymentGateways = await PaymentIntegration.query() - .where('active', true) + .modify('fullEnabled') .orderBy('name', 'ASC'); return this.transform.transform( diff --git a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts index 362cafa7c..532082d08 100644 --- a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts +++ b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkMetadata.ts @@ -44,6 +44,7 @@ export class GetInvoicePaymentLinkMetadata { .findById(paymentLink.resourceId) .withGraphFetched('entries.item') .withGraphFetched('customer') + .withGraphFetched('taxes.taxRate') .throwIfNotFound(); return this.transformer.transform( diff --git a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts index 268ba0586..15119e436 100644 --- a/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts +++ b/packages/server/src/services/Sales/Invoices/GetInvoicePaymentLinkTransformer.ts @@ -1,4 +1,5 @@ import { ItemEntryTransformer } from './ItemEntryTransformer'; +import { SaleInvoiceTaxEntryTransformer } from './SaleInvoiceTaxEntryTransformer'; import { SaleInvoiceTransformer } from './SaleInvoiceTransformer'; export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer { @@ -37,6 +38,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer 'invoiceMessage', 'termsConditions', 'entries', + 'taxes', ]; }; @@ -62,6 +64,22 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer } ); }; + + /** + * Retrieves the sale invoice entries. + * @returns {} + */ + protected taxes = (invoice) => { + return this.item( + invoice.taxes, + new GetInvoicePaymentLinkTaxEntryTransformer(), + { + subtotal: invoice.subtotal, + isInclusiveTax: invoice.isInclusiveTax, + currencyCode: invoice.currencyCode, + } + ); + }; } class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer { @@ -94,3 +112,13 @@ class GetInvoicePaymentLinkEntryMetaTransformer extends ItemEntryTransformer { return ['*']; }; } + +class GetInvoicePaymentLinkTaxEntryTransformer extends SaleInvoiceTaxEntryTransformer { + /** + * Included attributes. + * @returns {Array} + */ + public includeAttributes = (): string[] => { + return ['name', 'taxRateCode', 'taxRateAmount', 'taxRateAmountFormatted']; + }; +} diff --git a/packages/webapp/src/containers/PaymentPortal/PaymentPortal.module.scss b/packages/webapp/src/containers/PaymentPortal/PaymentPortal.module.scss index 6870ee413..8401ca7c3 100644 --- a/packages/webapp/src/containers/PaymentPortal/PaymentPortal.module.scss +++ b/packages/webapp/src/containers/PaymentPortal/PaymentPortal.module.scss @@ -1,6 +1,6 @@ .rootBodyPage { - background: #0c103f; + background: #1c1d29; } .root { diff --git a/packages/webapp/src/containers/PaymentPortal/PaymentPortal.tsx b/packages/webapp/src/containers/PaymentPortal/PaymentPortal.tsx index cd8a7bfb9..3f3e2c98d 100644 --- a/packages/webapp/src/containers/PaymentPortal/PaymentPortal.tsx +++ b/packages/webapp/src/containers/PaymentPortal/PaymentPortal.tsx @@ -83,6 +83,13 @@ export function PaymentPortal() { + {sharableLinkMeta?.taxes?.map((tax, key) => ( + + {tax?.name} + {tax?.taxRateAmountFormatted} + + ))} + ({ + label: tax.name, + amount: tax.taxRateAmountFormatted, + }))} /> diff --git a/packages/webapp/src/hooks/query/payment-link.ts b/packages/webapp/src/hooks/query/payment-link.ts index 4750267b5..8857cad81 100644 --- a/packages/webapp/src/hooks/query/payment-link.ts +++ b/packages/webapp/src/hooks/query/payment-link.ts @@ -50,7 +50,6 @@ export function useCreatePaymentLink( ); } - // Get Invoice Payment Link // ----------------------------------------- export interface GetInvoicePaymentLinkResponse { @@ -82,6 +81,12 @@ export interface GetInvoicePaymentLinkResponse { total: number; totalFormatted: string; }>; + taxes: Array<{ + name: string; + taxRateAmount: number; + taxRateAmountFormatted: string; + taxRateCode: string; + }>; } /** * Fetches the sharable invoice link metadata for a given link ID.