sacadores

This commit is contained in:
Ainki 2020-03-23 15:22:48 +01:00 committed by Joan Sanchez
parent 6829adc897
commit 4927ea4ca7
3 changed files with 15 additions and 10 deletions

View File

@ -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]);
};
};

View File

@ -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'];

View File

@ -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]);
};
};