diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html
index 88c8232c77..3b97f9db3f 100644
--- a/modules/claim/front/detail/index.html
+++ b/modules/claim/front/detail/index.html
@@ -55,8 +55,8 @@
{{::saleClaimed.sale.price | currency: 'EUR':2}}
-
{{saleClaimed.sale.discount}} %
diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js
index 9f6767318b..4e0017baa3 100644
--- a/modules/claim/front/detail/index.js
+++ b/modules/claim/front/detail/index.js
@@ -54,6 +54,10 @@ class Controller extends Section {
this.updateNewPrice();
}
+ get isClaimManager() {
+ return this.aclService.hasAny(['claimManager']);
+ }
+
openAddSalesDialog() {
this.getClaimableFromTicket();
this.$.addSales.show();
@@ -131,17 +135,6 @@ class Controller extends Section {
return total;
}
- showEditPopover(event, saleClaimed) {
- if (this.isEditable) {
- if (!this.aclService.hasAny(['claimManager']))
- return this.vnApp.showError(this.$t('Insuficient permisos'));
-
- this.saleClaimed = saleClaimed;
- this.$.editPopover.parent = event.target;
- this.$.editPopover.show();
- }
- }
-
getSalespersonMana() {
this.$http.get(`Tickets/${this.claim.ticketFk}/getSalesPersonMana`).then(res => {
this.mana = res.data;
@@ -164,6 +157,14 @@ class Controller extends Section {
});
}
+ showEditPopover(event, saleClaimed) {
+ if (this.aclService.hasAny(['claimManager'])) {
+ this.saleClaimed = saleClaimed;
+ this.$.editPopover.parent = event.target;
+ this.$.editPopover.show();
+ }
+ }
+
updateDiscount() {
const claimedSale = this.saleClaimed.sale;
if (this.newDiscount != claimedSale.discount) {
@@ -176,8 +177,6 @@ class Controller extends Section {
this.clearDiscount();
this.vnApp.showSuccess(this.$t('Data saved!'));
- }).catch(err => {
- this.vnApp.showError(err.message);
});
}
diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js
index 7c9f9ae482..1bebaae8dc 100644
--- a/modules/ticket/back/methods/ticket/updateDiscount.js
+++ b/modules/ticket/back/methods/ticket/updateDiscount.js
@@ -70,13 +70,17 @@ module.exports = Self => {
const userId = ctx.req.accessToken.userId;
const isLocked = await models.Ticket.isLocked(id);
- const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson');
+ const roles = await models.Account.getRoles(userId);
+ const hasAllowedRoles = roles.filter(role =>
+ role == 'salesPerson' || role == 'claimManager'
+ );
+
const state = await Self.app.models.TicketState.findOne({
where: {ticketFk: id}
});
const alertLevel = state ? state.alertLevel : null;
- if (isLocked || (!isSalesPerson && alertLevel > 0))
+ if (isLocked || (!hasAllowedRoles && alertLevel > 0))
throw new UserError(`The sales of this ticket can't be modified`);
const usesMana = await models.WorkerMana.findOne({