From 300ba61fd3a9b44dafbf41bdbc97f056ef8c9b05 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 14 Oct 2019 14:43:10 +0200 Subject: [PATCH] =?UTF-8?q?#1759=20Forzar=20desenrutado=20al=20cambiar=20d?= =?UTF-8?q?atos=20b=C3=A1sicos=20de=20ticket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ticket/back/methods/ticket/componentUpdate.js | 13 +++---------- .../methods/ticket/specs/componentUpdate.spec.js | 6 ++---- .../ticket/front/basic-data/step-three/index.html | 7 ------- modules/ticket/front/basic-data/step-three/index.js | 11 +++++------ .../front/basic-data/step-three/index.spec.js | 4 +++- .../front/basic-data/step-three/locale/es.yml | 2 +- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index d9af2f6a1..2cba62540 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -55,11 +55,6 @@ module.exports = Self => { type: 'Boolean', description: 'Ticket is deleted', required: true - }, { - arg: 'hasToBeUnrouted', - type: 'Boolean', - description: 'Ticket should be removed from ticket', - required: true }, { arg: 'option', type: 'Number', @@ -77,7 +72,7 @@ module.exports = Self => { }); Self.componentUpdate = async(ctx, id, clientId, agencyModeId, addressId, zoneId, warehouseId, - companyId, shipped, landed, isDeleted, hasToBeUnrouted, option) => { + companyId, shipped, landed, isDeleted, option) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; const isEditable = await models.Ticket.isEditable(ctx, id); @@ -85,10 +80,6 @@ module.exports = Self => { if (!isEditable) throw new UserError(`The sales of this ticket can't be modified`); - const hasDeliveryRole = await models.Account.hasRole(userId, 'delivery'); - if (!hasDeliveryRole) - hasToBeUnrouted = true; - const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss'); if (!isProductionBoss) { const zoneShipped = await models.Agency.getShipped(landed, addressId, agencyModeId, warehouseId); @@ -97,6 +88,8 @@ module.exports = Self => { throw new UserError(`You don't have privileges to change the zone`); } + // Force unroute + const hasToBeUnrouted = true; let query = 'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; let res = await Self.rawSql(query, [ id, diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index f3864b6dc..25ce90946 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -37,13 +37,12 @@ describe('ticket componentUpdate()', () => { const companyId = 442; const isDeleted = false; const landed = tomorrow; - const hasToBeUnrouted = false; const option = 1; let ctx = {req: {accessToken: {userId: 101}}}; await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId, - zoneId, warehouseId, companyId, shipped, landed, isDeleted, hasToBeUnrouted, option); + zoneId, warehouseId, companyId, shipped, landed, isDeleted, option); [componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven); let firstvalueAfterChange = componentValue.value; @@ -65,12 +64,11 @@ describe('ticket componentUpdate()', () => { const companyId = 442; const isDeleted = false; const landed = tomorrow; - const hasToBeUnrouted = false; const option = 1; let ctx = {req: {accessToken: {userId: 101}}}; await app.models.Ticket.componentUpdate(ctx, ticketId, clientId, agencyModeId, addressId, - zoneId, warehouseId, companyId, shipped, landed, isDeleted, hasToBeUnrouted, option); + zoneId, warehouseId, companyId, shipped, landed, isDeleted, option); [componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven); let firstvalueAfterChange = componentValue.value; diff --git a/modules/ticket/front/basic-data/step-three/index.html b/modules/ticket/front/basic-data/step-three/index.html index 24d5c8ba5..81263769f 100644 --- a/modules/ticket/front/basic-data/step-three/index.html +++ b/modules/ticket/front/basic-data/step-three/index.html @@ -10,12 +10,5 @@ initial-data="$ctrl.ticket.option"> - - - - diff --git a/modules/ticket/front/basic-data/step-three/index.js b/modules/ticket/front/basic-data/step-three/index.js index 04fcbc36e..932aad4ca 100644 --- a/modules/ticket/front/basic-data/step-three/index.js +++ b/modules/ticket/front/basic-data/step-three/index.js @@ -15,7 +15,6 @@ class Controller { $onChanges() { this.ticket.option = 1; - this.ticket.hasToBeUnrouted = true; } onStepChange(state) { @@ -40,15 +39,15 @@ class Controller { shipped: this.ticket.shipped, landed: this.ticket.landed, isDeleted: this.ticket.isDeleted, - hasToBeUnrouted: this.ticket.hasToBeUnrouted, option: this.ticket.option }; this.$http.post(query, params).then(res => { - if (res.data) { - this.$state.go('ticket.card.summary', {id: this.$state.params.id}); - this.card.reload(); - } + this.vnApp.showMessage( + this.$translate.instant(`The ticket has been unrouted`) + ); + this.card.reload(); + this.$state.go('ticket.card.summary', {id: this.$state.params.id}); }); } } diff --git a/modules/ticket/front/basic-data/step-three/index.spec.js b/modules/ticket/front/basic-data/step-three/index.spec.js index 26edd1a82..1224f5f35 100644 --- a/modules/ticket/front/basic-data/step-three/index.spec.js +++ b/modules/ticket/front/basic-data/step-three/index.spec.js @@ -31,6 +31,7 @@ describe('ticket', () => { }); it('should perform a post query correctly then call two functions()', () => { + spyOn(controller.vnApp, 'showMessage'); controller.card = {reload: () => {}}; spyOn(controller.card, 'reload'); @@ -60,8 +61,9 @@ describe('ticket', () => { controller.onSubmit(); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', jasmine.any(Object)); + expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The ticket has been unrouted'); expect(controller.card.reload).toHaveBeenCalledWith(); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', jasmine.any(Object)); }); }); }); diff --git a/modules/ticket/front/basic-data/step-three/locale/es.yml b/modules/ticket/front/basic-data/step-three/locale/es.yml index f2b78c77f..185534c34 100644 --- a/modules/ticket/front/basic-data/step-three/locale/es.yml +++ b/modules/ticket/front/basic-data/step-three/locale/es.yml @@ -1,4 +1,4 @@ Charge: Cargo Choose an option: Selecciona una opciĆ³n Charge difference to: Diferencia a cargo de -Remove from route: Sacar de la ruta \ No newline at end of file +The ticket has been unrouted: El ticket ha sido desenrutado \ No newline at end of file