feat: wip bank transaction matching

This commit is contained in:
Ahmed Bouhuolia
2024-07-03 18:49:21 +02:00
parent 67b519db61
commit a5eb42edaf
16 changed files with 39 additions and 118 deletions

View File

@@ -1,30 +0,0 @@
import { body } from 'express-validator';
import BaseController from '../BaseController';
import { Router } from 'express';
import { Service } from 'typedi';
@Service()
export class BankReconcileController extends BaseController {
/**
* Router constructor.
*/
public router() {
const router = Router();
router.post(
'/',
[
body('amount').exists(),
body('date').exists(),
body('fromAccountId').exists(),
body('toAccountId').exists(),
body('reference').optional({ nullable: true }),
],
this.validationResult,
this.createBankReconcileTransaction.bind(this)
);
return router;
}
createBankReconcileTransaction() {}
}

View File

@@ -24,12 +24,14 @@ export class GetBankAccountSummary {
.findById(bankAccountId)
.throwIfNotFound();
// Retrieves the uncategorized transactions count of the given bank account.
const uncategorizedTranasctionsCount =
await UncategorizedCashflowTransaction.query()
.where('accountId', bankAccountId)
.count('id as total')
.first();
// Retrieves the recognized transactions count of the given bank account.
const recognizedTransactionsCount = await RecognizedBankTransaction.query()
.whereExists(
UncategorizedCashflowTransaction.query().where(

View File

@@ -100,7 +100,6 @@ export class GetMatchedTransactions {
moment(match.date).isSame(uncategorizedTransaction.date, 'day'),
closestResullts
);
const possibleMatches = R.difference(closestResullts, perfectMatches);
return { perfectMatches, possibleMatches };

View File

@@ -8,7 +8,6 @@ import {
} from './types';
import { Inject, Service } from 'typedi';
// @Service()
export abstract class GetMatchedTransactionsByType {
@Inject()
protected tenancy: HasTenancyService;
@@ -17,6 +16,7 @@ export abstract class GetMatchedTransactionsByType {
* Retrieves the matched transactions.
* @param {number} tenantId -
* @param {GetMatchedTransactionsFilter} filter -
* @returns {Promise<MatchedTransactionsPOJO>}
*/
public async getMatchedTransactions(
tenantId: number,
@@ -31,6 +31,7 @@ export abstract class GetMatchedTransactionsByType {
* Retrieves the matched transaction details.
* @param {number} tenantId -
* @param {number} transactionId -
* @returns {Promise<MatchedTransactionPOJO>}
*/
public async getMatchedTransaction(
tenantId: number,