feat: excluded bank transactions

This commit is contained in:
Ahmed Bouhuolia
2024-06-27 22:14:53 +02:00
parent fab22c9820
commit 978ce6c441
28 changed files with 1301 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
import { Inject, Service } from 'typedi';
import { param } from 'express-validator';
import { NextFunction, Request, Response, Router } from 'express';
import { NextFunction, Request, Response, Router, query } from 'express';
import BaseController from '../BaseController';
import { ExcludeBankTransactionsApplication } from '@/services/Banking/Exclude/ExcludeBankTransactionsApplication';
@@ -27,6 +27,12 @@ export class ExcludeBankTransactionsController extends BaseController {
this.validationResult,
this.unexcludeBankTransaction.bind(this)
);
router.get(
'/excluded',
[],
this.validationResult,
this.getExcludedBankTransactions.bind(this)
);
return router;
}
@@ -87,4 +93,32 @@ export class ExcludeBankTransactionsController extends BaseController {
next(error);
}
}
/**
* Retrieves the excluded uncategorized bank transactions.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @returns {Promise<Response|null>}
*/
private async getExcludedBankTransactions(
req: Request,
res: Response,
next: NextFunction
): Promise<Response | void> {
const { tenantId } = req;
const filter = this.matchedBodyData(req);
console.log('123');
try {
const data =
await this.excludeBankTransactionApp.getExcludedBankTransactions(
tenantId,
filter
);
return res.status(200).send(data);
} catch (error) {
next(error);
}
}
}

View File

@@ -14,14 +14,11 @@ export class RecognizedTransactionsController extends BaseController {
router() {
const router = Router();
router.get(
'/accounts/:accountId',
this.getRecognizedTransactions.bind(this)
);
router.get('/', this.getRecognizedTransactions.bind(this));
return router;
}
k;
/**
* Retrieves the recognized bank transactions.
* @param {Request} req
@@ -34,15 +31,15 @@ export class RecognizedTransactionsController extends BaseController {
res: Response,
next: NextFunction
) {
const { accountId } = req.params;
const filter = this.matchedQueryData(req);
const { tenantId } = req;
try {
const data = await this.cashflowApplication.getRecognizedTransactions(
tenantId,
accountId
filter
);
return res.status(200).send({ data });
return res.status(200).send(data);
} catch (error) {
next(error);
}