From 8923970e75d94634b7fc8e33af40f4f10a307d7e Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 6 Mar 2019 08:54:04 +0100 Subject: [PATCH 1/3] e2e fixed --- e2e/helpers/selectors.js | 2 +- modules/ticket/front/services/index.html | 7 ++++--- modules/ticket/front/services/index.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a37d63854f..818232ef5a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -425,7 +425,7 @@ export default { addServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(3) > vn-icon-button > button > vn-icon', firstDescriptionInput: 'vn-ticket-service vn-textfield[label="Description"] input', firstQuantityInput: 'vn-ticket-service vn-textfield[label="Quantity"] input', - firstPriceInput: 'vn-ticket-service vn-textfield[label="Price"] input', + firstPriceInput: 'vn-ticket-service vn-input-number[label="Price"] input', firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]', fistDeleteServiceButton: 'vn-ticket-card > vn-main-block > div.content-block.ng-scope > vn-ticket-service > form > vn-card > div > vn-one:nth-child(1) > vn-horizontal:nth-child(1) > vn-auto > vn-icon-button[icon="delete"]', serviceLine: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal', diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html index ba50c46516..83b504021f 100644 --- a/modules/ticket/front/services/index.html +++ b/modules/ticket/front/services/index.html @@ -27,12 +27,13 @@ model="service.quantity" rule="TicketService.quantity"> - - + display-controls="false"> + { this.$scope.watcher.notifySaved(); + this.$scope.model.refresh(); }); } } From 80168900fee2cab8de6ab8b7cfa9c732737165d2 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 6 Mar 2019 08:54:32 +0100 Subject: [PATCH 2/3] e2e fixed --- e2e/paths/ticket-module/13_create_ticket_services.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/paths/ticket-module/13_create_ticket_services.spec.js b/e2e/paths/ticket-module/13_create_ticket_services.spec.js index 394b7cd9f2..0d9ae610ca 100644 --- a/e2e/paths/ticket-module/13_create_ticket_services.spec.js +++ b/e2e/paths/ticket-module/13_create_ticket_services.spec.js @@ -17,7 +17,6 @@ describe('Ticket services path', () => { .write(selectors.ticketService.firstDescriptionInput, 'my service') .clearInput(selectors.ticketService.firstQuantityInput) .write(selectors.ticketService.firstQuantityInput, 99) - .clearInput(selectors.ticketService.firstPriceInput) .write(selectors.ticketService.firstPriceInput, 999) .autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'General VAT') .waitToClick(selectors.ticketService.saveServiceButton) From b2adde4ba341ff5a7046c2d1a48b1344c256dbd4 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 6 Mar 2019 08:54:56 +0100 Subject: [PATCH 3/3] #1176 ticket.sale actualizar descuento --- .../ticket/back/methods/sale/updateDiscount.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/sale/updateDiscount.js b/modules/ticket/back/methods/sale/updateDiscount.js index 1c1db19271..e1793241be 100644 --- a/modules/ticket/back/methods/sale/updateDiscount.js +++ b/modules/ticket/back/methods/sale/updateDiscount.js @@ -1,7 +1,7 @@ let UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('updateDiscount', { + Self.remoteMethodCtx('updateDiscount', { description: 'Changes the discount of a sale', accessType: '', accepts: [{ @@ -21,16 +21,12 @@ module.exports = Self => { } }); - Self.updateDiscount = async params => { + Self.updateDiscount = async(ctx, params) => { if (isNaN(params.editLines[0].discount)) throw new UserError(`The value should be a number`); let model = Self.app.models; let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk); - - if (!thisTicketIsEditable) - throw new UserError(`The sales of this ticket can't be modified`); - let ticket = await model.Ticket.find({ where: { id: params.editLines[0].ticketFk @@ -41,9 +37,16 @@ module.exports = Self => { fields: ['salesPersonFk'] } }], - fields: ['id', 'clientFk'] + fields: ['id', 'clientFk', 'refFk'] }); + let userId = ctx.req.accessToken.userId; + let isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); + + if ((!thisTicketIsEditable && !isSalesAssistant) || (ticket.refFk && isSalesAssistant)) + throw new UserError(`The sales of this ticket can't be modified`); + + let componentToUse; let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});