diff --git a/packages/server/src/services/Sales/Estimates/utils.ts b/packages/server/src/services/Sales/Estimates/utils.ts index c5d100cd9..d39fd7f0b 100644 --- a/packages/server/src/services/Sales/Estimates/utils.ts +++ b/packages/server/src/services/Sales/Estimates/utils.ts @@ -15,7 +15,7 @@ export const transformEstimateToPdfTemplate = ( quantity: entry.quantityFormatted, total: entry.totalFormatted, })), - total: estimate.formattedSubtotal, + total: estimate.totalFormatted, subtotal: estimate.formattedSubtotal, adjustment: estimate.adjustmentFormatted, customerNote: estimate.note, diff --git a/packages/server/src/services/Sales/Receipts/GetSaleReceiptMailStateTransformer.ts b/packages/server/src/services/Sales/Receipts/GetSaleReceiptMailStateTransformer.ts index 7a7c41b2c..1f6126f52 100644 --- a/packages/server/src/services/Sales/Receipts/GetSaleReceiptMailStateTransformer.ts +++ b/packages/server/src/services/Sales/Receipts/GetSaleReceiptMailStateTransformer.ts @@ -82,21 +82,21 @@ export class GetSaleReceiptMailStateTransformer extends SaleReceiptTransformer { }; /** - * + * Retrieves the total amount. * @param receipt * @returns */ protected total = (receipt) => { - return receipt.amount; + return receipt.total; }; /** - * + * Retrieves the formatted total amount. * @param receipt - * @returns + * @returns {string} */ protected totalFormatted = (receipt) => { - return this.formatMoney(receipt.amount, { + return this.formatMoney(receipt.total, { currencyCode: receipt.currencyCode, }); }; @@ -118,7 +118,7 @@ export class GetSaleReceiptMailStateTransformer extends SaleReceiptTransformer { * @returns */ protected subtotal = (receipt) => { - return receipt.amount; + return receipt.subtotal; }; /** @@ -127,7 +127,7 @@ export class GetSaleReceiptMailStateTransformer extends SaleReceiptTransformer { * @returns */ protected subtotalFormatted = (receipt) => { - return this.formatMoney(receipt.amount, { + return this.formatMoney(receipt.subtotal, { currencyCode: receipt.currencyCode, }); }; diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index aaf236eb5..1e9d48eac 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -413,7 +413,10 @@ export const formatSmsMessage = (message: string, args) => { const variable = `{${key}}`; const value = _.defaultTo(args[key], ''); - formattedMessage = formattedMessage.replace(variable, value); + formattedMessage = formattedMessage.replace( + new RegExp(variable, 'g'), + value + ); }); return formattedMessage; }; diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateSendMailDrawer/withEstimateMailReceiptPreviewProps.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimateSendMailDrawer/withEstimateMailReceiptPreviewProps.tsx index 7b935396b..e4a850c66 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimateSendMailDrawer/withEstimateMailReceiptPreviewProps.tsx +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateSendMailDrawer/withEstimateMailReceiptPreviewProps.tsx @@ -36,7 +36,7 @@ export const withEstimateMailReceiptPreviewProps = < estimateNumber: estimateMailState?.estimateNumber, estimateDate: estimateMailState?.estimateDateFormatted, subtotal: estimateMailState?.subtotalFormatted, - discount: estimateMailState?.discountFormatted, + discount: estimateMailState?.discountAmountFormatted, adjustment: estimateMailState?.adjustmentFormatted, items, message, diff --git a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/_hooks.ts b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/_hooks.ts index 878c5f55c..9f2f2d0fa 100644 --- a/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/_hooks.ts +++ b/packages/webapp/src/containers/Sales/Invoices/InvoiceSendMailDrawer/_hooks.ts @@ -67,7 +67,7 @@ export const formatSmsMessage = ( const variable = `{${key}}`; const value = defaultTo(args[key], ''); - formattedMessage = formattedMessage.replace(variable, value); + formattedMessage = formattedMessage.replaceAll(variable, value); }); return formattedMessage; }; diff --git a/packages/webapp/src/hooks/query/estimates.tsx b/packages/webapp/src/hooks/query/estimates.tsx index e54950f23..741ab72de 100644 --- a/packages/webapp/src/hooks/query/estimates.tsx +++ b/packages/webapp/src/hooks/query/estimates.tsx @@ -284,8 +284,8 @@ export interface SaleEstimateMailStateResponse { subtotal: number; subtotalFormatted: string; - discount: number; - discountFormatted: string; + discountAmount: number; + discountAmountFormatted: string; discountLabel: string; discountPercentage: number | null; discountPercentageFormatted: string; diff --git a/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx b/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx index 3a7419ed8..ac48e7c19 100644 --- a/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx +++ b/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx @@ -16,6 +16,7 @@ import { PaperTemplateProps, PaperTemplateTotalBorder, } from './PaperTemplate'; +import { theme } from '../constants'; export interface EstimatePaperTemplateProps extends PaperTemplateProps { // # Company @@ -173,6 +174,7 @@ export function EstimatePaperTemplate({ lineRateLabel = 'Rate', lineTotalLabel = 'Total', }: EstimatePaperTemplateProps) { + return ( @@ -228,13 +230,13 @@ export function EstimatePaperTemplate({ {data.item} {data.description} ), + thStyle: { width: '60%' }, }, { label: lineQuantityLabel, accessor: 'quantity' }, { label: lineRateLabel, accessor: 'rate', align: 'right' }, diff --git a/shared/pdf-templates/src/components/InvoicePaperTemplate.tsx b/shared/pdf-templates/src/components/InvoicePaperTemplate.tsx index f2ff68e3a..487ae16ef 100644 --- a/shared/pdf-templates/src/components/InvoicePaperTemplate.tsx +++ b/shared/pdf-templates/src/components/InvoicePaperTemplate.tsx @@ -118,23 +118,27 @@ export interface InvoicePaperTemplateProps extends PaperTemplateProps { } export function InvoicePaperTemplate({ + // # Colors primaryColor, secondaryColor, + // # Company. companyName = 'Bigcapital Technology, Inc.', showCompanyLogo = true, companyLogoUri = '', + // # Due date dueDate = 'September 3, 2024', dueDateLabel = 'Date due', showDueDate = true, + // # Issue date. dateIssue = 'September 3, 2024', dateIssueLabel = 'Date of issue', showDateIssue = true, - // dateIssue, + // Invoice #, invoiceNumberLabel = 'Invoice number', invoiceNumber = '346D3D40-0001', showInvoiceNumber = true, @@ -197,6 +201,7 @@ export function InvoicePaperTemplate({ { label: 'Sample Tax2 (7.00%)', amount: '21.74' }, ], + // # Statement statementLabel = 'Statement', showStatement = true, statement = DefaultPdfTemplateStatement, diff --git a/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx b/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx index 3cf847146..04ddb24e3 100644 --- a/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx +++ b/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx @@ -16,6 +16,7 @@ import { DefaultPdfTemplateAddressBilledTo, DefaultPdfTemplateAddressBilledFrom, } from './_constants'; +import { theme } from '../constants'; export interface ReceiptPaperTemplateProps extends PaperTemplateProps { // # Company logo @@ -216,8 +217,7 @@ export function ReceiptPaperTemplate({ {data.item} {data.description} @@ -255,7 +255,7 @@ export function ReceiptPaperTemplate({ )} diff --git a/shared/pdf-templates/src/constants.ts b/shared/pdf-templates/src/constants.ts index 839b3949f..e9d8e32d0 100644 --- a/shared/pdf-templates/src/constants.ts +++ b/shared/pdf-templates/src/constants.ts @@ -1,5 +1,11 @@ +import { defaultTheme } from "@xstyled/system"; + export const OpenSansFontLink = ` `; + +export const theme = { + ...defaultTheme, +} \ No newline at end of file