mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix(Currencies): Currencies preferences.
This commit is contained in:
@@ -23,12 +23,6 @@ export default class AccountsController extends BaseController {
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.post(
|
||||
'/bulk/:type(activate|inactivate)',
|
||||
[...this.bulkSelectIdsQuerySchema],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.bulkToggleActivateAccounts.bind(this))
|
||||
);
|
||||
router.post(
|
||||
'/:id/activate',
|
||||
[...this.accountParamSchema],
|
||||
@@ -77,13 +71,6 @@ export default class AccountsController extends BaseController {
|
||||
this.dynamicListService.handlerErrorsToResponse,
|
||||
this.catchServiceErrors
|
||||
);
|
||||
router.delete(
|
||||
'/',
|
||||
[...this.bulkSelectIdsQuerySchema],
|
||||
this.validationResult,
|
||||
asyncMiddleware(this.deleteBulkAccounts.bind(this)),
|
||||
this.catchServiceErrors
|
||||
);
|
||||
router.delete(
|
||||
'/:id',
|
||||
[...this.accountParamSchema],
|
||||
@@ -140,13 +127,6 @@ export default class AccountsController extends BaseController {
|
||||
];
|
||||
}
|
||||
|
||||
get bulkSelectIdsQuerySchema() {
|
||||
return [
|
||||
query('ids').isArray({ min: 1 }),
|
||||
query('ids.*').isNumeric().toInt(),
|
||||
];
|
||||
}
|
||||
|
||||
get closingAccountSchema() {
|
||||
return [
|
||||
check('to_account_id').exists().isNumeric().toInt(),
|
||||
@@ -293,62 +273,6 @@ export default class AccountsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk activate/inactivate accounts.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
async bulkToggleActivateAccounts(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: Function
|
||||
) {
|
||||
const { type } = req.params;
|
||||
const { tenantId } = req;
|
||||
const { ids: accountsIds } = req.query;
|
||||
|
||||
try {
|
||||
const isActive = type === 'activate' ? true : false;
|
||||
await this.accountsService.activateAccounts(
|
||||
tenantId,
|
||||
accountsIds,
|
||||
isActive
|
||||
);
|
||||
|
||||
const activatedText = isActive ? 'activated' : 'inactivated';
|
||||
|
||||
return res.status(200).send({
|
||||
ids: accountsIds,
|
||||
message: `The given accounts have been ${activatedText} successfully`,
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes accounts in bulk.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
async deleteBulkAccounts(req: Request, res: Response, next: NextFunction) {
|
||||
const { ids: accountsIds } = req.query;
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
await this.accountsService.deleteAccounts(tenantId, accountsIds);
|
||||
|
||||
return res.status(200).send({
|
||||
ids: accountsIds,
|
||||
message: 'The given accounts have been deleted successfully.',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve accounts datatable list.
|
||||
* @param {Request} req
|
||||
|
||||
Reference in New Issue
Block a user