feat: auto fill categorize form from recognized transaction

This commit is contained in:
Ahmed Bouhuolia
2024-07-01 15:48:40 +02:00
parent 79616cf1eb
commit c95eec565d
9 changed files with 212 additions and 26 deletions

View File

@@ -15,6 +15,10 @@ export class RecognizedTransactionsController extends BaseController {
const router = Router();
router.get('/', this.getRecognizedTransactions.bind(this));
router.get(
'/transactions/:uncategorizedTransactionId',
this.getRecognizedTransaction.bind(this)
);
return router;
}
@@ -44,4 +48,30 @@ export class RecognizedTransactionsController extends BaseController {
next(error);
}
}
/**
* Retrieves the recognized transaction of the ginen uncategorized transaction.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @returns {Promise<Response|null>}
*/
async getRecognizedTransaction(
req: Request<{ uncategorizedTransactionId: number }>,
res: Response,
next: NextFunction
) {
const { tenantId } = req;
const { uncategorizedTransactionId } = req.params;
try {
const data = await this.cashflowApplication.getRecognizedTransaction(
tenantId,
uncategorizedTransactionId
);
return res.status(200).send({ data });
} catch (error) {
next(error);
}
}
}