mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix: Should not show the excluded transactions in recognized transactions
This commit is contained in:
@@ -31,17 +31,21 @@ export class GetBankAccountSummary {
|
|||||||
.findById(bankAccountId)
|
.findById(bankAccountId)
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
|
const commonQuery = (q) => {
|
||||||
|
// Include just the given account.
|
||||||
|
q.where('accountId', bankAccountId);
|
||||||
|
|
||||||
|
// Only the not excluded.
|
||||||
|
q.modify('notExcluded');
|
||||||
|
|
||||||
|
// Only the not categorized.
|
||||||
|
q.modify('notCategorized');
|
||||||
|
};
|
||||||
|
|
||||||
// Retrieves the uncategorized transactions count of the given bank account.
|
// Retrieves the uncategorized transactions count of the given bank account.
|
||||||
const uncategorizedTranasctionsCount =
|
const uncategorizedTranasctionsCount =
|
||||||
await UncategorizedCashflowTransaction.query().onBuild((q) => {
|
await UncategorizedCashflowTransaction.query().onBuild((q) => {
|
||||||
// Include just the given account.
|
commonQuery(q);
|
||||||
q.where('accountId', bankAccountId);
|
|
||||||
|
|
||||||
// Only the not excluded.
|
|
||||||
q.modify('notExcluded');
|
|
||||||
|
|
||||||
// Only the not categorized.
|
|
||||||
q.modify('notCategorized');
|
|
||||||
|
|
||||||
// Only the not matched bank transactions.
|
// Only the not matched bank transactions.
|
||||||
q.withGraphJoined('matchedBankTransactions');
|
q.withGraphJoined('matchedBankTransactions');
|
||||||
@@ -52,16 +56,18 @@ export class GetBankAccountSummary {
|
|||||||
q.first();
|
q.first();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieves the recognized transactions count of the given bank account.
|
// Retrives the recognized transactions count.
|
||||||
const recognizedTransactionsCount = await RecognizedBankTransaction.query()
|
const recognizedTransactionsCount =
|
||||||
.whereExists(
|
await UncategorizedCashflowTransaction.query().onBuild((q) => {
|
||||||
UncategorizedCashflowTransaction.query().where(
|
commonQuery(q);
|
||||||
'accountId',
|
|
||||||
bankAccountId
|
q.withGraphJoined('recognizedTransaction');
|
||||||
)
|
q.whereNotNull('recognizedTransaction.id');
|
||||||
)
|
|
||||||
.count('id as total')
|
// Count the results.
|
||||||
.first();
|
q.count('uncategorized_cashflow_transactions.id as total');
|
||||||
|
q.first();
|
||||||
|
});
|
||||||
|
|
||||||
const totalUncategorizedTransactions =
|
const totalUncategorizedTransactions =
|
||||||
uncategorizedTranasctionsCount?.total || 0;
|
uncategorizedTranasctionsCount?.total || 0;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export class GetRecognizedTransactionsService {
|
|||||||
q.withGraphFetched('recognizedTransaction.assignAccount');
|
q.withGraphFetched('recognizedTransaction.assignAccount');
|
||||||
q.withGraphFetched('recognizedTransaction.bankRule');
|
q.withGraphFetched('recognizedTransaction.bankRule');
|
||||||
q.whereNotNull('recognizedTransactionId');
|
q.whereNotNull('recognizedTransactionId');
|
||||||
|
q.modify('notExcluded');
|
||||||
|
|
||||||
if (_filter.accountId) {
|
if (_filter.accountId) {
|
||||||
q.where('accountId', _filter.accountId);
|
q.where('accountId', _filter.accountId);
|
||||||
|
|||||||
Reference in New Issue
Block a user