import { Injectable } from '@nestjs/common'; import { GetMatchedTransactions } from './queries/GetMatchedTransactions.service'; import { MatchBankTransactions } from './commands/MatchTransactions'; import { UnmatchMatchedBankTransaction } from './commands/UnmatchMatchedTransaction.service'; import { GetMatchedTransactionsFilter } from './types'; import { MatchTransactionEntryDto } from './dtos/MatchBankTransaction.dto'; @Injectable() export class BankingMatchingApplication { constructor( private readonly getMatchedTransactionsService: GetMatchedTransactions, private readonly matchTransactionService: MatchBankTransactions, private readonly unmatchMatchedTransactionService: UnmatchMatchedBankTransaction, ) {} /** * Retrieves the matched transactions. * @param {Array} uncategorizedTransactionsIds - Uncategorized transactions ids. * @param {GetMatchedTransactionsFilter} filter - * @returns {Promise} */ public getMatchedTransactions( uncategorizedTransactionsIds: Array, filter: GetMatchedTransactionsFilter, ) { return this.getMatchedTransactionsService.getMatchedTransactions( uncategorizedTransactionsIds, filter, ); } /** * Matches the given uncategorized transaction with the given system transaction. * @param {IMatchBankTransactionDto} matchedTransactionsDTO * @returns {Promise} */ public matchTransaction( uncategorizedTransactionId: number | Array, matchedTransactionsDto: | MatchTransactionEntryDto | Array, ): Promise { return this.matchTransactionService.matchTransaction( uncategorizedTransactionId, matchedTransactionsDto, ); } /** * Unmatch the given matched transaction. * @param {number} uncategorizedTransactionId - Uncategorized transaction id. * @returns {Promise} */ public unmatchMatchedTransaction(uncategorizedTransactionId: number) { return this.unmatchMatchedTransactionService.unmatchMatchedTransaction( uncategorizedTransactionId, ); } }