fix: specific account transactions.

fix: specific expense associated expense account graph.
fix: specific manual journal associated account and contact graph.
This commit is contained in:
a.bouhuolia
2021-04-25 23:41:54 +02:00
parent fcc95d9e01
commit c75109a975
7 changed files with 102 additions and 4 deletions

View File

@@ -23,6 +23,14 @@ export default class AccountsController extends BaseController {
router() {
const router = Router();
router.get(
'/transactions',
[
query('account_id').optional().isInt().toInt(),
],
this.asyncMiddleware(this.accountTransactions.bind(this)),
this.catchServiceErrors,
);
router.post(
'/:id/activate',
[...this.accountParamSchema],
@@ -329,6 +337,28 @@ export default class AccountsController extends BaseController {
}
}
/**
* Retrieve accounts transactions list.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @returns {Response}
*/
async accountTransactions(req: Request, res: Response, next: NextFunction) {
const { tenantId } = req;
const transactionsFilter = this.matchedQueryData(req);
try {
const { transactions } = await this.accountsService.getAccountsTransactions(
tenantId,
transactionsFilter
);
return res.status(200).send({ transactions });
} catch (error) {
next(error);
}
}
/**
* Transforms service errors to response.
* @param {Error}