From 52f97e1decd0e6408f9b14dcb28fb271a8c65fdf Mon Sep 17 00:00:00 2001 From: Ainki Date: Mon, 23 Mar 2020 15:22:48 +0100 Subject: [PATCH] sacadores --- back/methods/collection/collectionFaults.js | 6 +++--- back/methods/collection/collectionNew.js | 17 +++++++++++------ back/methods/collection/collectionUpdateSale.js | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/back/methods/collection/collectionFaults.js b/back/methods/collection/collectionFaults.js index b39e9f2d2..ac5186575 100644 --- a/back/methods/collection/collectionFaults.js +++ b/back/methods/collection/collectionFaults.js @@ -4,9 +4,9 @@ module.exports = Self => { accessType: 'WRITE', accepts: [{ arg: 'shelvingFk', - type: 'Number', + type: 'String', required: true, - description: 'The sale id' + description: 'The shalving id' }, { arg: 'quantity', type: 'Number', @@ -29,7 +29,7 @@ module.exports = Self => { }); Self.collectionFaults = async(ctx, shelvingFk, quantity, itemFk) => { - query = `vn.collection_faults(?,?,?)`; + query = `CALL vn.collection_faults(?,?,?)`; return await Self.rawSql(query, [shelvingFk, quantity, itemFk]); }; }; diff --git a/back/methods/collection/collectionNew.js b/back/methods/collection/collectionNew.js index 6e248f640..9a3020bf8 100644 --- a/back/methods/collection/collectionNew.js +++ b/back/methods/collection/collectionNew.js @@ -12,6 +12,11 @@ module.exports = Self => { type: 'Number', required: true, description: 'The sector of worker' + }, { + arg: 'vWagons', + type: 'Number', + required: true, + description: 'The number of wagons' }], returns: { type: 'Object', @@ -23,13 +28,13 @@ module.exports = Self => { } }); - Self.collectionNew = async(ctx, collectionFk, sectorFk) => { + Self.collectionNew = async(ctx, collectionFk, sectorFk, vWagons) => { let query = ''; if (!collectionFk) { const userId = ctx.req.accessToken.userId; - query = `CALL vn.collection_newBeta(?,?)`; - const [result] = await Self.rawSql(query, [sectorFk, userId]); + query = `CALL vn.collectionTrain_newBeta(?,?,?)`; + const [result] = await Self.rawSql(query, [sectorFk, vWagons, userId]); if (result.length == 0) throw new Error(`No collections for today`); @@ -48,7 +53,7 @@ module.exports = Self => { query = `CALL vn.collectionSticker_print(?,?)`; // await Self.rawSql(query, [collectionFk, sectorFk]); - return makeCollection(tickets, sales, placements); + return makeCollection(tickets, sales, placements, collectionFk); }; /** @@ -58,7 +63,7 @@ module.exports = Self => { * @param {*} placements - Request placements * @return {Object} Collection JSON */ - async function makeCollection(tickets, sales, placements) { + async function makeCollection(tickets, sales, placements, collectionFk) { let collection = []; for (let i = 0; i < tickets.length; i++) { @@ -74,7 +79,7 @@ module.exports = Self => { for (let x = 0; x < sales.length; x++) { if (sales[x]['ticketFk'] == ticket['ticketFk']) { let sale = {}; - + sale['collectionFk'] = collectionFk; sale['ticketFk'] = sales[x]['ticketFk']; sale['saleFk'] = sales[x]['saleFk']; sale['itemFk'] = sales[x]['itemFk']; diff --git a/back/methods/collection/collectionUpdateSale.js b/back/methods/collection/collectionUpdateSale.js index 4e8775755..7204dad22 100644 --- a/back/methods/collection/collectionUpdateSale.js +++ b/back/methods/collection/collectionUpdateSale.js @@ -36,7 +36,7 @@ module.exports = Self => { Self.collectionUpdateSale = async(ctx, sale, originalQuantity, ticketFk, stateFk) => { const userId = ctx.req.accessToken.userId; - query = `vn.collection_updateSale(?,?,?,?,?)`; + query = `CALL vn.collection_updateSale(?,?,?,?,?)`; return await Self.rawSql(query, [sale, originalQuantity, userId, stateFk, ticketFk]); }; };