Merge pull request #358 from bigcapitalhq/big-127-amount-decimals-are-set-to-zero-when-creating-an-new-payment

fix: payment receive subtotal shouldn't be rounded
This commit is contained in:
Ahmed Bouhuolia
2024-02-06 20:39:27 +02:00
committed by GitHub
15 changed files with 83 additions and 31 deletions

View File

@@ -14,6 +14,7 @@ export class CreditNoteTransformer extends Transformer {
'formattedCreditNoteDate',
'formattedAmount',
'formattedCreditsUsed',
'formattedSubtotal',
'entries',
];
};
@@ -60,6 +61,15 @@ export class CreditNoteTransformer extends Transformer {
});
};
/**
* Retrieves the formatted subtotal.
* @param {ICreditNote} credit
* @returns {string}
*/
protected formattedSubtotal = (credit): string => {
return formatNumber(credit.amount, { money: false });
};
/**
* Retrieves the entries of the credit note.
* @param {ICreditNote} credit

View File

@@ -11,6 +11,7 @@ export class VendorCreditTransformer extends Transformer {
public includeAttributes = (): string[] => {
return [
'formattedAmount',
'formattedSubtotal',
'formattedVendorCreditDate',
'formattedCreditsRemaining',
'entries',
@@ -37,6 +38,15 @@ export class VendorCreditTransformer extends Transformer {
});
};
/**
* Retrieves the vendor credit formatted subtotal.
* @param {IVendorCredit} vendorCredit
* @returns {string}
*/
protected formattedSubtotal = (vendorCredit): string => {
return formatNumber(vendorCredit.amount, { money: false });
};
/**
* Retrieve formatted credits remaining.
* @param {IVendorCredit} credit

View File

@@ -10,6 +10,7 @@ export class SaleEstimateTransfromer extends Transformer {
*/
public includeAttributes = (): string[] => {
return [
'formattedSubtotal',
'formattedAmount',
'formattedEstimateDate',
'formattedExpirationDate',
@@ -76,6 +77,15 @@ export class SaleEstimateTransfromer extends Transformer {
});
};
/**
* Retrieves the formatted invoice subtotal.
* @param {ISaleEstimate} estimate
* @returns {string}
*/
protected formattedSubtotal = (estimate: ISaleEstimate): string => {
return formatNumber(estimate.amount, { money: false });
};
/**
* Retrieves the entries of the sale estimate.
* @param {ISaleEstimate} estimate

View File

@@ -8,7 +8,16 @@ export class ItemEntryTransformer extends Transformer {
* @returns {Array}
*/
public includeAttributes = (): string[] => {
return ['rateFormatted', 'totalFormatted'];
return ['quantityFormatted', 'rateFormatted', 'totalFormatted'];
};
/**
* Retrieves the formatted quantitty of item entry.
* @param {IItemEntry} entry
* @returns {string}
*/
protected quantityFormatted = (entry: IItemEntry): string => {
return formatNumber(entry.quantity, { money: false });
};
/**

View File

@@ -10,6 +10,7 @@ export class PaymentReceiveTransfromer extends Transformer {
*/
public includeAttributes = (): string[] => {
return [
'subtotalFormatted',
'formattedPaymentDate',
'formattedAmount',
'formattedExchangeRate',
@@ -26,6 +27,18 @@ export class PaymentReceiveTransfromer extends Transformer {
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.
* @param {ISaleInvoice} invoice

View File

@@ -12,6 +12,7 @@ export class SaleReceiptTransformer extends Transformer {
*/
public includeAttributes = (): string[] => {
return [
'formattedSubtotal',
'formattedAmount',
'formattedReceiptDate',
'formattedClosedAtDate',
@@ -37,6 +38,15 @@ export class SaleReceiptTransformer extends Transformer {
return this.formatDate(receipt.closedAt);
};
/**
* Retrieves the estimate formatted subtotal.
* @param {ISaleReceipt} receipt
* @returns {string}
*/
protected formattedSubtotal = (receipt: ISaleReceipt): string => {
return formatNumber(receipt.amount, { money: false });
};
/**
* Retrieve formatted invoice amount.
* @param {ISaleReceipt} estimate

View File

@@ -1,12 +1,9 @@
// @ts-nocheck
import React from 'react';
import styled from 'styled-components';
import {
T,
TotalLines,
TotalLine,
FormatNumber,
TotalLineBorderStyle,
TotalLineTextStyle,
} from '@/components';
@@ -23,7 +20,7 @@ export default function CreditNoteDetailTableFooter() {
<CreditNoteTotalLines labelColWidth={'180px'} amountColWidth={'180px'}>
<TotalLine
title={<T id={'credit_note.drawer.label_subtotal'} />}
value={<FormatNumber value={creditNote.formatted_amount} />}
value={creditNote.formatted_subtotal}
/>
<TotalLine
title={<T id={'credit_note.drawer.label_total'} />}

View File

@@ -8,7 +8,6 @@ import {
TotalLine,
TotalLineBorderStyle,
TotalLineTextStyle,
FormatNumber,
} from '@/components';
import { useEstimateDetailDrawerContext } from './EstimateDetailDrawerProvider';
@@ -23,7 +22,7 @@ export default function EstimateDetailTableFooter() {
<EstimateTotalLines labelColWidth={'180px'} amountColWidth={'180px'}>
<TotalLine
title={<T id={'estimate.details.subtotal'} />}
value={<FormatNumber value={estimate.amount} />}
value={estimate.formatted_subtotal}
borderStyle={TotalLineBorderStyle.SingleDark}
/>
<TotalLine

View File

@@ -2,7 +2,7 @@
import React from 'react';
import intl from 'react-intl-universal';
import { getColumnWidth } from '@/utils';
import { FormatNumberCell, TextOverviewTooltipCell } from '@/components';
import { TextOverviewTooltipCell } from '@/components';
import { useEstimateDetailDrawerContext } from './EstimateDetailDrawerProvider';
/**
@@ -35,9 +35,8 @@ export const useEstimateReadonlyEntriesColumns = () => {
},
{
Header: intl.get('quantity'),
accessor: 'quantity',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'quantity', {
accessor: 'quantity_formatted',
width: getColumnWidth(entries, 'quantity_formatted', {
minWidth: 60,
magicSpacing: 5,
}),
@@ -59,7 +58,6 @@ export const useEstimateReadonlyEntriesColumns = () => {
{
Header: intl.get('amount'),
accessor: 'total_formatted',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'total_formatted', {
minWidth: 60,
magicSpacing: 5,

View File

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

View File

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

View File

@@ -23,7 +23,7 @@ export default function ReceiptDetailTableFooter() {
<ReceiptTotalLines labelColWidth={'180px'} amountColWidth={'180px'}>
<TotalLine
title={<T id={'receipt.details.subtotal'} />}
value={receipt.formatted_amount}
value={receipt.formatted_subtotal}
/>
<TotalLine
title={<T id={'receipt.details.total'} />}

View File

@@ -13,7 +13,6 @@ export const useJournalEntriesTransactionsColumns = () => {
() => [
{
Header: intl.get('date'),
accessor: 'date',
accessor: 'formatted_date',
Cell: FormatDateCell,
width: 140,
@@ -34,15 +33,17 @@ export const useJournalEntriesTransactionsColumns = () => {
},
{
Header: intl.get('credit'),
accessor: ({ credit }) => credit.formatted_amount,
accessor: 'credit.formatted_amount',
width: 100,
className: 'credit',
align: 'right',
},
{
Header: intl.get('debit'),
accessor: ({ debit }) => debit.formatted_amount,
accessor: 'debit.formatted_amount',
width: 100,
className: 'debit',
align: 'right',
},
],
[],

View File

@@ -8,7 +8,6 @@ import {
TotalLine,
TotalLineBorderStyle,
TotalLineTextStyle,
FormatNumber,
} from '@/components';
import { useVendorCreditDetailDrawerContext } from './VendorCreditDetailDrawerProvider';
@@ -23,7 +22,7 @@ export default function VendorCreditDetailDrawerFooter() {
<VendorCreditTotalLines labelColWidth={'180px'} amountColWidth={'180px'}>
<TotalLine
title={<T id={'vendor_credit.drawer.label_subtotal'} />}
value={vendorCredit.formatted_amount}
value={vendorCredit.formatted_subtotal}
borderStyle={TotalLineBorderStyle.SingleDark}
/>
<TotalLine

View File

@@ -49,9 +49,8 @@ export const useVendorCreditReadonlyEntriesTableColumns = () => {
},
{
Header: intl.get('quantity'),
accessor: 'quantity',
Cell: FormatNumberCell,
width: getColumnWidth(entries, 'quantity', {
accessor: 'quantity_formatted',
width: getColumnWidth(entries, 'quantity_formatted', {
minWidth: 60,
magicSpacing: 5,
}),