From c928940d32000679a768823dfb2c06aa92d0966a Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Mon, 12 Aug 2024 13:01:00 +0200 Subject: [PATCH] fix: rounding the total amount the pending and matched transactions --- .../src/services/Banking/Matching/GetMatchedTransactions.ts | 2 +- .../containers/CashFlow/CategorizeTransactionAside/utils.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts b/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts index c7caf1325..cf46790a3 100644 --- a/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts +++ b/packages/server/src/services/Banking/Matching/GetMatchedTransactions.ts @@ -64,7 +64,7 @@ export class GetMatchedTransactions { .whereIn('id', uncategorizedTransactionIds) .throwIfNotFound(); - const totalPending = Math.abs(sumBy(uncategorizedTransactions, 'amount')); + const totalPending = sumBy(uncategorizedTransactions, 'amount'); const filtered = filter.transactionType ? this.registered.filter((item) => item.type === filter.transactionType) diff --git a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts index d4ec29a2f..974b5f772 100644 --- a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts +++ b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts @@ -1,8 +1,8 @@ +import { useMemo } from 'react'; import { useFormikContext } from 'formik'; +import { round } from 'lodash'; import { MatchingTransactionFormValues } from './types'; import { useMatchingTransactionBoot } from './MatchingTransactionBoot'; -import { useCategorizeTransactionTabsBoot } from './CategorizeTransactionTabsBoot'; -import { useMemo } from 'react'; export const transformToReq = ( values: MatchingTransactionFormValues, @@ -38,7 +38,7 @@ export const useGetPendingAmountMatched = () => { ); const pendingAmount = totalPending - totalMatchedAmount; - return pendingAmount; + return round(pendingAmount, 2); }, [totalPending, perfectMatches, possibleMatches, values]); };