diff --git a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransaction.tsx b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransaction.tsx
index 288ee0289..a2d0bd0d3 100644
--- a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransaction.tsx
+++ b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransaction.tsx
@@ -2,7 +2,7 @@
import { isEmpty } from 'lodash';
import * as R from 'ramda';
import { AnchorButton, Button, Intent, Tag, Text } from '@blueprintjs/core';
-import { AppToaster, Box, Group, Stack } from '@/components';
+import { AppToaster, Box, FormatNumber, Group, Stack } from '@/components';
import {
MatchingTransactionBoot,
useMatchingTransactionBoot,
@@ -12,7 +12,7 @@ import styles from './CategorizeTransactionAside.module.scss';
import { FastField, FastFieldProps, Form, Formik } from 'formik';
import { useMatchTransaction } from '@/hooks/query/bank-rules';
import { MatchingTransactionFormValues } from './types';
-import { transformToReq } from './utils';
+import { transformToReq, useGetPendingAmountMatched } from './utils';
import {
WithBankingActionsProps,
withBankingActions,
@@ -136,10 +136,12 @@ function GoodMatchingTransactions() {
{possibleMatches.map((match, index) => (
-
))}
@@ -189,6 +191,9 @@ const MatchTransactionFooter = R.compose(withBankingActions)(
const handleCancelBtnClick = () => {
closeMatchingTransactionAside();
};
+
+ const totalPending = useGetPendingAmountMatched();
+
return (
@@ -196,7 +201,10 @@ const MatchTransactionFooter = R.compose(withBankingActions)(
Add Reconcile Transaction +
- Pending $10,000
+
+
+ Pending
+
diff --git a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransactionBoot.tsx b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransactionBoot.tsx
index df94cab7f..355aa1166 100644
--- a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransactionBoot.tsx
+++ b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/MatchingTransactionBoot.tsx
@@ -1,5 +1,6 @@
-import { useMatchingTransactions } from '@/hooks/query/bank-rules';
+import { defaultTo } from 'lodash';
import React, { createContext } from 'react';
+import { useMatchingTransactions } from '@/hooks/query/bank-rules';
interface MatchingTransactionBootValues {
isMatchingTransactionsLoading: boolean;
@@ -29,9 +30,9 @@ function MatchingTransactionBoot({
const provider = {
isMatchingTransactionsLoading,
- possibleMatches: matchingTransactions?.possibleMatches,
- perfectMatchesCount: 2,
- perfectMatches: matchingTransactions?.perfectMatches,
+ possibleMatches: defaultTo(matchingTransactions?.possibleMatches, []),
+ perfectMatchesCount: matchingTransactions?.perfectMatches?.length || 0,
+ perfectMatches: defaultTo(matchingTransactions?.perfectMatches, []),
} as MatchingTransactionBootValues;
return ;
diff --git a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts
index e3d30bbe0..0f388da34 100644
--- a/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts
+++ b/packages/webapp/src/containers/CashFlow/CategorizeTransactionAside/utils.ts
@@ -1,4 +1,6 @@
+import { useFormikContext } from 'formik';
import { MatchingTransactionFormValues } from './types';
+import { useMatchingTransactionBoot } from './MatchingTransactionBoot';
export const transformToReq = (values: MatchingTransactionFormValues) => {
const matchedTransactions = Object.entries(values.matched)
@@ -11,3 +13,22 @@ export const transformToReq = (values: MatchingTransactionFormValues) => {
return { matchedTransactions };
};
+
+export const useGetPendingAmountMatched = () => {
+ const { values } = useFormikContext();
+ const { perfectMatches, possibleMatches } = useMatchingTransactionBoot();
+
+ const matchedItems = [...perfectMatches, ...possibleMatches].filter(
+ (match) => {
+ const key = `${match.transactionType}-${match.transactionId}`;
+ return values.matched[key];
+ },
+ );
+ const totalMatchedAmount = matchedItems.reduce(
+ (total, item) => total + parseFloat(item.amount),
+ 0,
+ );
+ const pendingAmount = 0 - totalMatchedAmount;
+
+ return pendingAmount;
+};