mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: Pending bank transactions
This commit is contained in:
@@ -7,4 +7,5 @@ export const BANK_QUERY_KEY = {
|
||||
'RECOGNIZED_BANK_TRANSACTIONS_INFINITY',
|
||||
BANK_ACCOUNT_SUMMARY_META: 'BANK_ACCOUNT_SUMMARY_META',
|
||||
AUTOFILL_CATEGORIZE_BANK_TRANSACTION: 'AUTOFILL_CATEGORIZE_BANK_TRANSACTION',
|
||||
PENDING_BANK_ACCOUNT_TRANSACTIONS: 'PENDING_BANK_ACCOUNT_TRANSACTIONS'
|
||||
};
|
||||
|
||||
@@ -20,7 +20,8 @@ export function AccountTransactionsFilterTabs() {
|
||||
const hasUncategorizedTransx = useMemo(
|
||||
() =>
|
||||
bankAccountMetaSummary?.totalUncategorizedTransactions > 0 ||
|
||||
bankAccountMetaSummary?.totalExcludedTransactions > 0,
|
||||
bankAccountMetaSummary?.totalExcludedTransactions > 0 ||
|
||||
bankAccountMetaSummary?.totalPendingTransactions > 0,
|
||||
[bankAccountMetaSummary],
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import * as R from 'ramda';
|
||||
import { useMemo } from 'react';
|
||||
import { useAppQueryString } from '@/hooks';
|
||||
import { Group } from '@/components';
|
||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||
@@ -12,31 +14,49 @@ export function AccountTransactionsUncategorizeFilter() {
|
||||
bankAccountMetaSummary?.totalUncategorizedTransactions;
|
||||
const totalRecognized = bankAccountMetaSummary?.totalRecognizedTransactions;
|
||||
|
||||
const totalPending = bankAccountMetaSummary?.totalPendingTransactions;
|
||||
|
||||
const handleTabsChange = (value) => {
|
||||
setLocationQuery({ uncategorizedFilter: value });
|
||||
};
|
||||
|
||||
const options = useMemo(
|
||||
() =>
|
||||
R.when(
|
||||
() => totalPending > 0,
|
||||
R.append({
|
||||
value: 'pending',
|
||||
label: (
|
||||
<>
|
||||
Pending <strong>({totalPending})</strong>
|
||||
</>
|
||||
),
|
||||
}),
|
||||
)([
|
||||
{
|
||||
value: 'all',
|
||||
label: (
|
||||
<>
|
||||
All <strong>({totalUncategorized})</strong>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
value: 'recognized',
|
||||
label: (
|
||||
<>
|
||||
Recognized <strong>({totalRecognized})</strong>
|
||||
</>
|
||||
),
|
||||
},
|
||||
]),
|
||||
[totalPending, totalRecognized, totalUncategorized],
|
||||
);
|
||||
|
||||
return (
|
||||
<Group position={'apart'}>
|
||||
<TagsControl
|
||||
options={[
|
||||
{
|
||||
value: 'all',
|
||||
label: (
|
||||
<>
|
||||
All <strong>({totalUncategorized})</strong>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
value: 'recognized',
|
||||
label: (
|
||||
<>
|
||||
Recognized <strong>({totalRecognized})</strong>
|
||||
</>
|
||||
),
|
||||
},
|
||||
]}
|
||||
options={options}
|
||||
value={locationQuery?.uncategorizedFilter || 'all'}
|
||||
onValueChange={handleTabsChange}
|
||||
/>
|
||||
|
||||
@@ -70,6 +70,8 @@ function AccountTransactionsSwitcher() {
|
||||
case 'all':
|
||||
default:
|
||||
return <AccountUncategorizedTransactions />;
|
||||
case 'pending':
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
28
packages/webapp/src/hooks/query/bank-transaction.ts
Normal file
28
packages/webapp/src/hooks/query/bank-transaction.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// @ts-nocheck
|
||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { BANK_QUERY_KEY } from '@/constants/query-keys/banking';
|
||||
|
||||
interface GetBankRuleRes {}
|
||||
|
||||
/**
|
||||
* Retrieve the given bank rule.
|
||||
* @param {number} bankRuleId -
|
||||
* @param {UseQueryOptions<GetBankRuleRes, Error>} options -
|
||||
* @returns {UseQueryResult<GetBankRuleRes, Error>}
|
||||
*/
|
||||
export function usePendingBankAccountTransactions(
|
||||
bankRuleId: number,
|
||||
options?: UseQueryOptions<GetBankRuleRes, Error>,
|
||||
): UseQueryResult<GetBankRuleRes, Error> {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery<GetBankRuleRes, Error>(
|
||||
[BANK_QUERY_KEY.PENDING_BANK_ACCOUNT_TRANSACTIONS],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/banking/bank_account/pending_transactions`)
|
||||
.then((res) => res.data),
|
||||
{ ...options },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user