fix: payment receive subtotal shouldn't be rounded

This commit is contained in:
Ahmed Bouhuolia
2024-02-06 10:54:41 +02:00
parent 528d447443
commit 374f1acf8a
3 changed files with 20 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ export class PaymentReceiveTransfromer extends Transformer {
*/ */
public includeAttributes = (): string[] => { public includeAttributes = (): string[] => {
return [ return [
'subtotalFormatted',
'formattedPaymentDate', 'formattedPaymentDate',
'formattedAmount', 'formattedAmount',
'formattedExchangeRate', 'formattedExchangeRate',
@@ -26,6 +27,18 @@ export class PaymentReceiveTransfromer extends Transformer {
return this.formatDate(payment.paymentDate); return this.formatDate(payment.paymentDate);
}; };
/**
* Retrieve the formatted payment subtotal.
* @param {IPaymentReceive} payment
* @returns {string}
*/
protected subtotalFormatted = (payment: IPaymentReceive): string => {
return formatNumber(payment.amount, {
currencyCode: payment.currencyCode,
money: false,
});
};
/** /**
* Retrieve formatted payment amount. * Retrieve formatted payment amount.
* @param {ISaleInvoice} invoice * @param {ISaleInvoice} invoice

View File

@@ -3,10 +3,9 @@ import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { import {
FormatNumber, T,
TotalLineTextStyle, TotalLineTextStyle,
TotalLineBorderStyle, TotalLineBorderStyle,
T,
TotalLine, TotalLine,
TotalLines, TotalLines,
} from '@/components'; } from '@/components';
@@ -27,7 +26,7 @@ export default function PaymentReceiveDetailTableFooter() {
> >
<TotalLine <TotalLine
title={<T id={'payment_receive.details.subtotal'} />} title={<T id={'payment_receive.details.subtotal'} />}
value={<FormatNumber value={paymentReceive.amount} />} value={paymentReceive.subtotal_formatted}
/> />
<TotalLine <TotalLine
title={<T id={'payment_receive.details.total'} />} title={<T id={'payment_receive.details.total'} />}

View File

@@ -10,7 +10,7 @@ import {
MenuItem, MenuItem,
Menu, Menu,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { Icon, FormatNumberCell } from '@/components'; import { Icon } from '@/components';
import { getColumnWidth } from '@/utils'; import { getColumnWidth } from '@/utils';
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider'; import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
@@ -40,9 +40,8 @@ export const usePaymentReceiveEntriesColumns = () => {
}, },
{ {
Header: intl.get('invoice_amount'), Header: intl.get('invoice_amount'),
accessor: 'invoice.balance', accessor: 'invoice.total_formatted',
Cell: FormatNumberCell, width: getColumnWidth(entries, 'invoice.total_formatted', {
width: getColumnWidth(entries, 'invoice.balance', {
minWidth: 60, minWidth: 60,
magicSpacing: 5, magicSpacing: 5,
}), }),
@@ -51,10 +50,9 @@ export const usePaymentReceiveEntriesColumns = () => {
}, },
{ {
Header: intl.get('amount_due'), Header: intl.get('amount_due'),
accessor: 'invoice.due_amount', accessor: 'invoice.due_amount_formatted',
Cell: FormatNumberCell,
align: 'right', align: 'right',
width: getColumnWidth(entries, 'invoice.due_amount', { width: getColumnWidth(entries, 'invoice.due_amount_formatted', {
minWidth: 60, minWidth: 60,
magicSpacing: 5, magicSpacing: 5,
}), }),