Migrate taxes
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -577,6 +577,20 @@ export default class AuthorizationService {
}
// End billing
+ // Taxes
+ public static async checkAndGetTaxesAuthorizations(tenant: Tenant, userToken: UserToken): Promise<AuthorizationFilter> {
+ const authorizationFilters: AuthorizationFilter = {
+ filters: {},
+ dataSources: new Map(),
+ projectFields: [],
+ authorized: false
+ };
+ // Check static & dynamic authorization
+ await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TAX, Action.LIST, authorizationFilters, {}, null, true);
+ return authorizationFilters;
+ }
+ // End taxes
+
public static async checkAndGetCarsAuthorizations(tenant: Tenant, userToken: UserToken, filteredRequest: Partial<HttpCarsRequest>): Promise<AuthorizationFilter> {
const authorizationFilters: AuthorizationFilter = {
filters: {},

MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -165,17 +165,14 @@ export default class BillingService {
}
public static async handleGetBillingTaxes(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
- if (!await Authorizations.canReadTaxesBilling(req.user)) {
- throw new AppAuthError({
- errorCode: HTTPAuthError.FORBIDDEN,
- user: req.user,
- entity: Entity.TAX, action: Action.LIST,
- module: MODULE_NAME, method: 'handleGetBillingTaxes',
- });
- }
// Check if component is active
- UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.BILLING,
- Action.LIST, Entity.TAX, MODULE_NAME, 'handleGetBillingTaxes');
+ UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.BILLING, Action.LIST, Entity.TAX, MODULE_NAME, 'handleGetBillingTaxes');
+ // Check dynamic authorization
+ const authorizationsTaxes = await AuthorizationService.checkAndGetTaxesAuthorizations(req.tenant, req.user);
+ if (!authorizationsTaxes.authorized) {
+ UtilsService.sendEmptyDataResult(res, next);
+ return;
+ }
// Get Billing implementation from factory
const billingImpl = await BillingFactory.getBillingImpl(req.tenant);
if (!billingImpl) {

Migrate taxes