Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: total lines style #761

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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,
});
};

/**
Expand All @@ -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 });
};

/**
Expand All @@ -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,
});
};

/**
Expand Down Expand Up @@ -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}%` : '';
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default function EstimateFromCurrencyTag() {
if (!isForeignCustomer) {
return null;
}

return (
<BaseCurrencyRoot>
<BaseCurrency currency={selectCustomer?.currency_code} />
Expand Down
24 changes: 18 additions & 6 deletions shared/pdf-templates/src/components/EstimatePaperTemplate.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -242,33 +247,40 @@ export function EstimatePaperTemplate({
<PaperTemplate.TotalLine
label={subtotalLabel}
amount={subtotal}
border={PaperTemplateTotalBorder.Gray}
style={{ fontWeight: 500 }}
/>
)}
{showDiscount && discount && (
{showDiscount && !isEmpty(discount) && (
<PaperTemplate.TotalLine
label={discountLabel}
amount={discount}
/>
)}
{showAdjustment && adjustment && (
{showAdjustment && !isEmpty(adjustment) && (
<PaperTemplate.TotalLine
label={adjustmentLabel}
amount={adjustment}
/>
)}
{showTotal && (
<PaperTemplate.TotalLine label={totalLabel} amount={total} />
<PaperTemplate.TotalLine
label={totalLabel}
amount={total}
border={PaperTemplateTotalBorder.Dark}
style={{ fontWeight: 500 }}
/>
)}
</PaperTemplate.Totals>
</Stack>

<Stack spacing={0}>
{showCustomerNote && (
{showCustomerNote && !isEmpty(customerNote) && (
<PaperTemplate.Statement label={customerNoteLabel}>
{customerNote}
</PaperTemplate.Statement>
)}
{showTermsConditions && (
{showTermsConditions && !isEmpty(termsConditions) && (
<PaperTemplate.Statement label={termsConditionsLabel}>
{termsConditions}
</PaperTemplate.Statement>
Expand Down
21 changes: 17 additions & 4 deletions shared/pdf-templates/src/components/ReceiptPaperTemplate.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -230,6 +235,8 @@ export function ReceiptPaperTemplate({
<PaperTemplate.TotalLine
label={subtotalLabel}
amount={subtotal}
border={PaperTemplateTotalBorder.Gray}
style={{ fontWeight: 500 }}
/>
)}
{showDiscount && discount && (
Expand All @@ -245,18 +252,24 @@ export function ReceiptPaperTemplate({
/>
)}
{showTotal && (
<PaperTemplate.TotalLine label={totalLabel} amount={total} />
<PaperTemplate.TotalLine
label={totalLabel}
amount={total}
border={PaperTemplateTotalBorder.Gray}
style={{ fontWeight: 500 }}
/>
)}
</PaperTemplate.Totals>
</Stack>

<Stack spacing={0}>
{showCustomerNote && (
{showCustomerNote && !isEmpty(customerNote) && (
<PaperTemplate.Statement label={customerNoteLabel}>
{customerNote}
</PaperTemplate.Statement>
)}
{showTermsConditions && (

{showTermsConditions && !isEmpty(termsConditions) && (
<PaperTemplate.Statement label={termsConditionsLabel}>
{termsConditions}
</PaperTemplate.Statement>
Expand Down
Loading