feat: cashflow transaction matching

This commit is contained in:
Ahmed Bouhuolia
2024-07-04 22:44:20 +02:00
parent 202179ec0b
commit 87f60f7461
10 changed files with 333 additions and 45 deletions

View File

@@ -1,9 +1,12 @@
import { defaultTo } from 'lodash';
import React, { createContext } from 'react';
import { defaultTo } from 'lodash';
import * as R from 'ramda';
import { useGetBankTransactionsMatches } from '@/hooks/query/bank-rules';
interface MatchingTransactionBootValues {
isMatchingTransactionsLoading: boolean;
isMatchingTransactionsFetching: boolean;
isMatchingTransactionsSuccess: boolean;
possibleMatches: Array<any>;
perfectMatchesCount: number;
perfectMatches: Array<any>;
@@ -26,13 +29,24 @@ function MatchingTransactionBoot({
const {
data: matchingTransactions,
isLoading: isMatchingTransactionsLoading,
isFetching: isMatchingTransactionsFetching,
isSuccess: isMatchingTransactionsSuccess,
} = useGetBankTransactionsMatches(uncategorizedTransactionId);
const possibleMatches = defaultTo(matchingTransactions?.possibleMatches, []);
const perfectMatchesCount = matchingTransactions?.perfectMatches?.length || 0;
const perfectMatches = defaultTo(matchingTransactions?.perfectMatches, []);
const matches = R.concat(perfectMatches, possibleMatches);
const provider = {
isMatchingTransactionsLoading,
possibleMatches: defaultTo(matchingTransactions?.possibleMatches, []),
perfectMatchesCount: matchingTransactions?.perfectMatches?.length || 0,
perfectMatches: defaultTo(matchingTransactions?.perfectMatches, []),
isMatchingTransactionsFetching,
isMatchingTransactionsSuccess,
possibleMatches,
perfectMatchesCount,
perfectMatches,
matches,
} as MatchingTransactionBootValues;
return <RuleFormBootContext.Provider value={provider} {...props} />;