Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
ac5f30924a
|
@ -55,8 +55,8 @@
|
|||
</vn-td>
|
||||
<vn-td number>{{::saleClaimed.sale.price | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td number>
|
||||
<span ng-class="{'link': $ctrl.isEditable}"
|
||||
title="{{$ctrl.isEditable ? 'Edit discount' : ''}}"
|
||||
<span ng-class="{'link': $ctrl.isRewritable && $ctrl.isClaimManager}"
|
||||
translate-attr="{title: $ctrl.isRewritable && $ctrl.isClaimManager ? 'Edit discount' : ''}"
|
||||
ng-click="$ctrl.showEditPopover($event, saleClaimed)">
|
||||
{{saleClaimed.sale.discount}} %
|
||||
</span>
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue