feat: getting matched transactiosn from multi uncategorized transactions

This commit is contained in:
Ahmed Bouhuolia
2024-08-01 12:11:40 +02:00
parent f5e18fc1fe
commit 47dd767b3a
5 changed files with 51 additions and 31 deletions

View File

@@ -16,6 +16,7 @@ import { MatchTransactionsTypes } from './MatchTransactionsTypes';
import { ServiceError } from '@/exceptions';
import {
sumMatchTranasctions,
sumUncategorizedTransactions,
validateUncategorizedTransactionsExcluded,
validateUncategorizedTransactionsNotMatched,
} from './_utils';
@@ -95,11 +96,14 @@ export class MatchBankTransactions {
const totalMatchedTranasctions = sumMatchTranasctions(
validatationResult.results
);
const totalUncategorizedTransactions = sumUncategorizedTransactions(
uncategorizedTransactions
);
// Validates the total given matching transcations whether is not equal
// uncategorized transaction amount.
// if (totalMatchedTranasctions !== uncategorizedTransaction.amount) {
// throw new ServiceError(ERRORS.TOTAL_MATCHING_TRANSACTIONS_INVALID);
// }
if (totalUncategorizedTransactions === totalMatchedTranasctions) {
throw new ServiceError(ERRORS.TOTAL_MATCHING_TRANSACTIONS_INVALID);
}
}
/**