mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
fix: retrieve the excluded transactions count
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import { initialize } from 'objection';
|
import { initialize } from 'objection';
|
||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||||
|
import { UncategorizedTransactionTransformer } from '@/services/Cashflow/UncategorizedTransactionTransformer';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class GetBankAccountSummary {
|
export class GetBankAccountSummary {
|
||||||
@@ -69,14 +70,27 @@ export class GetBankAccountSummary {
|
|||||||
q.first();
|
q.first();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const excludedTransactionsCount =
|
||||||
|
await UncategorizedCashflowTransaction.query().onBuild((q) => {
|
||||||
|
q.where('accountId', bankAccountId);
|
||||||
|
q.modify('excluded');
|
||||||
|
|
||||||
|
// Count the results.
|
||||||
|
q.count('uncategorized_cashflow_transactions.id as total');
|
||||||
|
q.first();
|
||||||
|
});
|
||||||
|
|
||||||
const totalUncategorizedTransactions =
|
const totalUncategorizedTransactions =
|
||||||
uncategorizedTranasctionsCount?.total || 0;
|
uncategorizedTranasctionsCount?.total || 0;
|
||||||
const totalRecognizedTransactions = recognizedTransactionsCount?.total || 0;
|
const totalRecognizedTransactions = recognizedTransactionsCount?.total || 0;
|
||||||
|
|
||||||
|
const totalExcludedTransactions = excludedTransactionsCount?.total || 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: bankAccount.name,
|
name: bankAccount.name,
|
||||||
totalUncategorizedTransactions,
|
totalUncategorizedTransactions,
|
||||||
totalRecognizedTransactions,
|
totalRecognizedTransactions,
|
||||||
|
totalExcludedTransactions,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
|
import { useMemo } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { ContentTabs } from '@/components/ContentTabs/ContentTabs';
|
import { ContentTabs } from '@/components/ContentTabs/ContentTabs';
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
@@ -8,15 +9,19 @@ const AccountContentTabs = styled(ContentTabs)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export function AccountTransactionsFilterTabs() {
|
export function AccountTransactionsFilterTabs() {
|
||||||
const { filterTab, setFilterTab, currentAccount } =
|
const { filterTab, setFilterTab, bankAccountMetaSummary, currentAccount } =
|
||||||
useAccountTransactionsContext();
|
useAccountTransactionsContext();
|
||||||
|
|
||||||
const handleChange = (value) => {
|
const handleChange = (value) => {
|
||||||
setFilterTab(value);
|
setFilterTab(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasUncategorizedTransx = Boolean(
|
// Detarmines whether show the uncategorized transactions tab.
|
||||||
currentAccount.uncategorized_transactions,
|
const hasUncategorizedTransx = useMemo(
|
||||||
|
() =>
|
||||||
|
bankAccountMetaSummary?.totalUncategorizedTransactions > 0 ||
|
||||||
|
bankAccountMetaSummary?.totalExcludedTransactions > 0,
|
||||||
|
[bankAccountMetaSummary],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user