From 67030370a199327a070d5ad25df9ac1ce51d5879 Mon Sep 17 00:00:00 2001 From: gerard Date: Wed, 11 Jul 2018 13:52:04 +0200 Subject: [PATCH] Bug #398 El SPLUR crea los nuevos tickets sin Alias(nickname) --- client/ticket/src/sale/index.js | 2 +- .../common/methods/sale/moveToNewTicket.js | 4 ++-- .../common/methods/ticket/{create.js => new.js} | 14 +++++++------- services/loopback/common/models/ticket.js | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) rename services/loopback/common/methods/ticket/{create.js => new.js} (81%) diff --git a/client/ticket/src/sale/index.js b/client/ticket/src/sale/index.js index e468820aa..9f36086b3 100644 --- a/client/ticket/src/sale/index.js +++ b/client/ticket/src/sale/index.js @@ -172,7 +172,7 @@ class Controller { let sales = this.getCheckedLines(); this.$http.post(`/api/Sales/MoveToNewTicket`, {ticket: ticket, sales: sales}).then(res => { - let url = this.$state.href("ticket.card.sale", {id: res.data.id}, {absolute: true}); + let url = this.$state.href("ticket.card.sale", {id: res.data}, {absolute: true}); window.open(url, '_blank'); this.$.transfer.hide(); this.getSales(); diff --git a/services/loopback/common/methods/sale/moveToNewTicket.js b/services/loopback/common/methods/sale/moveToNewTicket.js index 9ad79eda2..469b729fe 100644 --- a/services/loopback/common/methods/sale/moveToNewTicket.js +++ b/services/loopback/common/methods/sale/moveToNewTicket.js @@ -47,10 +47,10 @@ module.exports = Self => { landed: landed }; - let newTicket = await model.Ticket.create(newTicketParams); + let newTicket = await model.Ticket.new(newTicketParams); for (let i = 0; i < params.sales.length; i++) { - await model.Sale.update({id: params.sales[i].id}, {ticketFk: newTicket.id}); + await model.Sale.update({id: params.sales[i].id}, {ticketFk: newTicket}); } return newTicket; }; diff --git a/services/loopback/common/methods/ticket/create.js b/services/loopback/common/methods/ticket/new.js similarity index 81% rename from services/loopback/common/methods/ticket/create.js rename to services/loopback/common/methods/ticket/new.js index db7c100cb..b6d9e87bb 100644 --- a/services/loopback/common/methods/ticket/create.js +++ b/services/loopback/common/methods/ticket/new.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethod('create', { + Self.remoteMethod('new', { description: 'Create a newticket and returns the new ID', accessType: 'WRITE', accepts: [{ @@ -14,12 +14,12 @@ module.exports = Self => { root: true }, http: { - path: `/create`, + path: `/new`, verb: 'post' } }); - Self.create = async params => { + Self.new = async params => { let existsAddress = await Self.app.models.Address.findOne({where: {id: params.addressFk, clientFk: params.clientFk}}); if (!existsAddress) throw new Error(`This address doesn't exist`); @@ -28,13 +28,13 @@ module.exports = Self => { let result = await Self.rawSql(query, [ params.clientFk, params.shipped, - params.wharehouseFk, - params.companyFk, + params.warehouseFk, + params.companyFk | 442, params.addressFk, params.agencyModeFk, - params.routeFk, + params.routeFk | null, params.landed ]); - return result; + return result[0][0].vNewTicket; }; }; diff --git a/services/loopback/common/models/ticket.js b/services/loopback/common/models/ticket.js index 62c3fb24f..1eaadb5ce 100644 --- a/services/loopback/common/models/ticket.js +++ b/services/loopback/common/models/ticket.js @@ -7,7 +7,7 @@ module.exports = Self => { require('../methods/ticket/getTotal')(Self); require('../methods/ticket/getTaxes')(Self); require('../methods/ticket/componentUpdate')(Self); - require('../methods/ticket/create')(Self); + require('../methods/ticket/new')(Self); require('../methods/ticket/isEditable')(Self); require('../methods/ticket/threeLastActive')(Self); require('../methods/ticket/deleted')(Self);