feat: wip matching bank transactions

This commit is contained in:
Ahmed Bouhuolia
2024-07-01 12:02:59 +02:00
parent da0fab9a58
commit c27458ebcc
12 changed files with 107 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
import { Inject, Service } from 'typedi';
import { GetMatchedTransactionsFilter } from './types';
import { GetMatchedTransactionsFilter, MatchedTransactionPOJO } from './types';
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import { GetMatchedTransactionsByType } from './GetMatchedTransactionsByType';
@@ -46,4 +46,27 @@ export class GetMatchedTransactionsByExpenses extends GetMatchedTransactionsByTy
new GetMatchedTransactionExpensesTransformer()
);
}
/**
* Retrieves the given matched expense transaction.
* @param {number} tenantId
* @param {number} transactionId
* @returns {GetMatchedTransactionExpensesTransformer-}
*/
public async getMatchedTransaction(
tenantId: number,
transactionId: number
): Promise<MatchedTransactionPOJO> {
const { Expense } = this.tenancy.models(tenantId);
const expense = await Expense.query()
.findById(transactionId)
.throwIfNotFound();
return this.transformer.transform(
tenantId,
expense,
new GetMatchedTransactionExpensesTransformer()
);
}
}