From 38f2004e56e4b9edd63b7035817ca8b85ed12e9d Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 4 Dec 2024 15:24:58 +0200 Subject: [PATCH] fix: total lines style --- .../Sales/Receipts/SaleReceiptTransformer.ts | 16 +++++++------ .../EstimateForm/EstimateFormCurrencyTag.tsx | 1 - .../src/components/EstimatePaperTemplate.tsx | 24 ++++++++++++++----- .../src/components/ReceiptPaperTemplate.tsx | 21 ++++++++++++---- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/packages/server/src/services/Sales/Receipts/SaleReceiptTransformer.ts b/packages/server/src/services/Sales/Receipts/SaleReceiptTransformer.ts index 422e88e83c..adafab5d82 100644 --- a/packages/server/src/services/Sales/Receipts/SaleReceiptTransformer.ts +++ b/packages/server/src/services/Sales/Receipts/SaleReceiptTransformer.ts @@ -49,7 +49,7 @@ export class SaleReceiptTransformer extends Transformer { /** * Retrieve formatted receipt created at date. - * @param receipt + * @param receipt * @returns {string} */ protected formattedCreatedAt = (receipt: ISaleReceipt): string => { @@ -62,7 +62,9 @@ export class SaleReceiptTransformer extends Transformer { * @returns {string} */ protected subtotalFormatted = (receipt: ISaleReceipt): string => { - return formatNumber(receipt.subtotal, { money: false }); + return formatNumber(receipt.subtotal, { + currencyCode: receipt.currencyCode, + }); }; /** @@ -82,7 +84,7 @@ export class SaleReceiptTransformer extends Transformer { * @returns {string} */ protected totalFormatted = (receipt: ISaleReceipt): string => { - return formatNumber(receipt.total, { money: false }); + return formatNumber(receipt.total, { currencyCode: receipt.currencyCode }); }; /** @@ -91,7 +93,9 @@ export class SaleReceiptTransformer extends Transformer { * @returns {string} */ protected totalLocalFormatted = (receipt: ISaleReceipt): string => { - return formatNumber(receipt.totalLocal, { money: false }); + return formatNumber(receipt.totalLocal, { + currencyCode: receipt.currencyCode, + }); }; /** @@ -123,9 +127,7 @@ export class SaleReceiptTransformer extends Transformer { * @returns {string} */ protected discountPercentageFormatted = (receipt: ISaleReceipt): string => { - return receipt.discountPercentage - ? `${receipt.discountPercentage}%` - : ''; + return receipt.discountPercentage ? `${receipt.discountPercentage}%` : ''; }; /** diff --git a/packages/webapp/src/containers/Sales/Estimates/EstimateForm/EstimateFormCurrencyTag.tsx b/packages/webapp/src/containers/Sales/Estimates/EstimateForm/EstimateFormCurrencyTag.tsx index c272fbebea..68036c5fd9 100644 --- a/packages/webapp/src/containers/Sales/Estimates/EstimateForm/EstimateFormCurrencyTag.tsx +++ b/packages/webapp/src/containers/Sales/Estimates/EstimateForm/EstimateFormCurrencyTag.tsx @@ -13,7 +13,6 @@ export default function EstimateFromCurrencyTag() { if (!isForeignCustomer) { return null; } - return ( diff --git a/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx b/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx index e28a292a24..3a7419ed84 100644 --- a/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx +++ b/shared/pdf-templates/src/components/EstimatePaperTemplate.tsx @@ -1,3 +1,4 @@ +import isEmpty from 'lodash/isEmpty'; import { Box } from '../lib/layout/Box'; import { Text } from '../lib/text/Text'; import { Stack } from '../lib/layout/Stack'; @@ -10,7 +11,11 @@ import { DefaultPdfTemplateAddressBilledTo, DefaultPdfTemplateAddressBilledFrom, } from './_constants'; -import { PaperTemplate, PaperTemplateProps } from './PaperTemplate'; +import { + PaperTemplate, + PaperTemplateProps, + PaperTemplateTotalBorder, +} from './PaperTemplate'; export interface EstimatePaperTemplateProps extends PaperTemplateProps { // # Company @@ -242,33 +247,40 @@ export function EstimatePaperTemplate({ )} - {showDiscount && discount && ( + {showDiscount && !isEmpty(discount) && ( )} - {showAdjustment && adjustment && ( + {showAdjustment && !isEmpty(adjustment) && ( )} {showTotal && ( - + )} - {showCustomerNote && ( + {showCustomerNote && !isEmpty(customerNote) && ( {customerNote} )} - {showTermsConditions && ( + {showTermsConditions && !isEmpty(termsConditions) && ( {termsConditions} diff --git a/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx b/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx index 68a19c9e9f..3cf8471469 100644 --- a/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx +++ b/shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx @@ -1,8 +1,13 @@ +import isEmpty from 'lodash/isEmpty'; import { Box } from '../lib/layout/Box'; import { Text } from '../lib/text/Text'; import { Stack } from '../lib/layout/Stack'; import { Group } from '../lib/layout/Group'; -import { PaperTemplate, PaperTemplateProps } from './PaperTemplate'; +import { + PaperTemplate, + PaperTemplateProps, + PaperTemplateTotalBorder, +} from './PaperTemplate'; import { DefaultPdfTemplateTerms, DefaultPdfTemplateItemDescription, @@ -230,6 +235,8 @@ export function ReceiptPaperTemplate({ )} {showDiscount && discount && ( @@ -245,18 +252,24 @@ export function ReceiptPaperTemplate({ /> )} {showTotal && ( - + )} - {showCustomerNote && ( + {showCustomerNote && !isEmpty(customerNote) && ( {customerNote} )} - {showTermsConditions && ( + + {showTermsConditions && !isEmpty(termsConditions) && ( {termsConditions}