feat: match bank transaction

This commit is contained in:
Ahmed Bouhuolia
2024-06-20 23:31:46 +02:00
parent b37002bea6
commit 738a84bb4b
20 changed files with 492 additions and 55 deletions

View File

@@ -2,7 +2,7 @@ import { Inject, Service } from 'typedi';
import { NextFunction, Request, Response, Router } from 'express';
import BaseController from '@/api/controllers/BaseController';
import { MatchBankTransactionsApplication } from '@/services/Banking/Matching/MatchBankTransactionsApplication';
import { param } from 'express-validator';
import { body, param } from 'express-validator';
import {
GetMatchedTransactionsFilter,
IMatchTransactionDTO,
@@ -21,7 +21,14 @@ export class BankTransactionsMatchingController extends BaseController {
router.post(
'/:transactionId',
[param('transactionId').exists()],
[
param('transactionId').exists(),
body('matchedTransactions').isArray({ min: 1 }),
body('matchedTransactions.*.reference_type').exists(),
body('matchedTransactions.*.reference_id').isNumeric().toInt(),
body('matchedTransactions.*.amount').exists().isNumeric().toFloat(),
],
this.validationResult,
this.matchBankTransaction.bind(this)
);
@@ -60,7 +67,6 @@ export class BankTransactionsMatchingController extends BaseController {
transactionId,
matchTransactionDTO
);
return res.status(200).send({
message: 'The bank transaction has been matched.',
});

View File

@@ -7,7 +7,7 @@ import { ExcludeBankTransactionsApplication } from '@/services/Banking/Exclude/E
@Service()
export class ExcludeBankTransactionsController extends BaseController {
@Inject()
prviate excludeBankTransactionApp: ExcludeBankTransactionsApplication;
private excludeBankTransactionApp: ExcludeBankTransactionsApplication;
/**
* Router constructor.

View File

@@ -0,0 +1,30 @@
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() {}
}