Bug #425 Split no funciona en produccion
This commit is contained in:
parent
ff6d86f6c2
commit
3dfa4bfc04
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('moveToNewTicket', {
|
||||
Self.remoteMethodCtx('moveToNewTicket', {
|
||||
description: 'Change the state of a ticket',
|
||||
accessType: '',
|
||||
accepts: [{
|
||||
|
@ -25,7 +25,8 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.moveToNewTicket = async params => {
|
||||
Self.moveToNewTicket = async(ctx, params) => {
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
let model = Self.app.models;
|
||||
let thisTicketIsEditable = await model.Ticket.isEditable(params.ticket.oldTicketFk);
|
||||
if (!thisTicketIsEditable)
|
||||
|
@ -44,14 +45,18 @@ module.exports = Self => {
|
|||
agencyModeFk: params.ticket.agencyModeFk,
|
||||
warehouseFk: params.ticket.warehouseFk,
|
||||
shipped: shipped,
|
||||
landed: landed
|
||||
landed: landed,
|
||||
userId: userId
|
||||
};
|
||||
|
||||
let newTicket = await model.Ticket.new(newTicketParams);
|
||||
|
||||
let promises = [];
|
||||
for (let i = 0; i < params.sales.length; i++) {
|
||||
await model.Sale.update({id: params.sales[i].id}, {ticketFk: newTicket});
|
||||
promises.push(model.Sale.update({id: params.sales[i].id}, {ticketFk: newTicket}));
|
||||
}
|
||||
await Promise.all(promises);
|
||||
|
||||
return newTicket;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = Self => {
|
|||
arg: 'params',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'ClientFk, Shipped, WharehouseFk, CompanyFk, AddressFk, AgencyModeFk, RouteFk, Landed',
|
||||
description: 'ClientFk, Shipped, WharehouseFk, CompanyFk, AddressFk, AgencyModeFk, RouteFk, Landed, userId',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
|
@ -24,7 +24,8 @@ module.exports = Self => {
|
|||
if (!existsAddress)
|
||||
throw new Error(`This address doesn't exist`);
|
||||
|
||||
let query = `CALL vn.ticketListCreate(?, ?, ?, ?, ?, ?, ?, ?);`;
|
||||
let query = `CALL vn.ticketCreateWithUser(?, ?, ?, ?, ?, ?, ?, ?, ?, @pe);
|
||||
SELECT @pe newTicketId;`;
|
||||
let result = await Self.rawSql(query, [
|
||||
params.clientFk,
|
||||
params.shipped,
|
||||
|
@ -33,8 +34,10 @@ module.exports = Self => {
|
|||
params.addressFk,
|
||||
params.agencyModeFk,
|
||||
params.routeFk | null,
|
||||
params.landed
|
||||
params.landed,
|
||||
params.userId
|
||||
]);
|
||||
return result[0][0].vNewTicket;
|
||||
|
||||
return result[1][0].newTicketId;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue