diff --git a/server/src/api/controllers/Accounts.ts b/server/src/api/controllers/Accounts.ts index 259137bbc..fb3670580 100644 --- a/server/src/api/controllers/Accounts.ts +++ b/server/src/api/controllers/Accounts.ts @@ -23,7 +23,10 @@ export default class AccountsController extends BaseController{ const router = Router(); router.post( - '/bulk/:type(activate|inactivate)', + '/bulk/:type(activate|inactivate)', [ + ...this.bulkSelectIdsQuerySchema + ], + this.validationResult, asyncMiddleware(this.bulkToggleActivateAccounts.bind(this)) ); router.post( @@ -74,6 +77,14 @@ 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 @@ -82,14 +93,6 @@ export default class AccountsController extends BaseController{ asyncMiddleware(this.deleteAccount.bind(this)), this.catchServiceErrors, ); - router.delete( - '/', [ - ...this.bulkDeleteSchema, - ], - this.validationResult, - asyncMiddleware(this.deleteBulkAccounts.bind(this)), - this.catchServiceErrors, - ); return router; } @@ -149,7 +152,7 @@ export default class AccountsController extends BaseController{ /** * */ - get bulkDeleteSchema() { + get bulkSelectIdsQuerySchema() { return [ query('ids').isArray({ min: 2 }), query('ids.*').isNumeric().toInt(), diff --git a/server/src/models/Expense.js b/server/src/models/Expense.js index 8c3cdac3b..c422a6065 100644 --- a/server/src/models/Expense.js +++ b/server/src/models/Expense.js @@ -20,7 +20,7 @@ export default class Expense extends TenantModel { /** * Model timestamps. */ - static get timestamps() { + get timestamps() { return ['createdAt', 'updatedAt']; } diff --git a/server/src/models/Item.js b/server/src/models/Item.js index 4abfa3408..ea500c8cc 100644 --- a/server/src/models/Item.js +++ b/server/src/models/Item.js @@ -15,7 +15,7 @@ export default class Item extends TenantModel { /** * Model timestamps. */ - static get timestamps() { + get timestamps() { return ['createdAt', 'updatedAt']; } @@ -23,8 +23,6 @@ export default class Item extends TenantModel { * Model modifiers. */ static get modifiers() { - const TABLE_NAME = Item.tableName; - return { sortBy(query, columnSort, sortDirection) { query.orderBy(columnSort, sortDirection); diff --git a/server/src/models/ItemCategory.js b/server/src/models/ItemCategory.js index ad79dd4d7..26e7f2684 100644 --- a/server/src/models/ItemCategory.js +++ b/server/src/models/ItemCategory.js @@ -10,6 +10,13 @@ export default class ItemCategory extends TenantModel { return 'items_categories'; } + /** + * Timestamps columns. + */ + get timestamps() { + return ['createdAt', 'updatedAt']; + } + /** * Relationship mapping. */ diff --git a/server/src/system/models/Subscriptions/Plan.js b/server/src/system/models/Subscriptions/Plan.js index 20cfd046c..cb724ff46 100644 --- a/server/src/system/models/Subscriptions/Plan.js +++ b/server/src/system/models/Subscriptions/Plan.js @@ -39,21 +39,9 @@ export default class Plan extends mixin(SystemModel) { * Relationship mapping. */ static get relationMappings() { - const PlanFeature = require('system/models/Subscriptions/PlanFeature'); + const PlanSubscription = require('system/models/Subscriptions/PlanSubscription'); return { - /** - * The plan may have many features. - */ - features: { - relation: Model.BelongsToOneRelation, - modelClass: PlanFeature.default, - join: { - from: 'subscriptions_plans.id', - to: 'subscriptions_plan_features.planId', - }, - }, - /** * The plan may have many subscriptions. */ @@ -62,7 +50,7 @@ export default class Plan extends mixin(SystemModel) { modelClass: PlanSubscription.default, join: { from: 'subscription_plans.id', - to: 'subscription_plans.planId', + to: 'subscription_plan_subscriptions.planId', }, } };