change some names an methods
This commit is contained in:
parent
1063db3a2f
commit
07d952646a
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('collectionFaults', {
|
||||
Self.remoteMethod('collectionFaults', {
|
||||
description: 'Update sale of a collection',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -28,7 +28,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.collectionFaults = async(ctx, shelvingFk, quantity, itemFk) => {
|
||||
Self.collectionFaults = async(shelvingFk, quantity, itemFk) => {
|
||||
query = `CALL vn.collection_faults(?,?,?)`;
|
||||
return await Self.rawSql(query, [shelvingFk, quantity, itemFk]);
|
||||
};
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('collectionUpdateSale', {
|
||||
description: 'Update sale of a collection',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'sale',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The sale id'
|
||||
}, {
|
||||
arg: 'originalQuantity',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The quantity to sale'
|
||||
}, {
|
||||
arg: 'ticketFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The ticket id'
|
||||
}, {
|
||||
arg: 'stateFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The state id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/collectionUpdateSale`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.collectionUpdateSale = async(ctx, sale, originalQuantity, ticketFk, stateFk) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
query = `CALL vn.collection_updateSale(?,?,?,?,?)`;
|
||||
return await Self.rawSql(query, [sale, originalQuantity, userId, stateFk, ticketFk]);
|
||||
};
|
||||
};
|
|
@ -1,18 +1,18 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('collectionGet', {
|
||||
Self.remoteMethodCtx('getCollection', {
|
||||
description: 'Get pending collections from a worker',
|
||||
accessType: 'WRITE',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/collectionGet`,
|
||||
verb: 'POST'
|
||||
path: `/getCollection`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.collectionGet = async ctx => {
|
||||
Self.getCollection = async ctx => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const query = `CALL vn.collection_get(?)`;
|
||||
const [result] = await Self.rawSql(query, [userId]);
|
|
@ -1,14 +1,14 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getSectors', {
|
||||
description: 'Get all sectors',
|
||||
accessType: 'WRITE',
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getSectors`,
|
||||
verb: 'POST'
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('collectionNew', {
|
||||
Self.remoteMethodCtx('newCollection', {
|
||||
description: 'Make a new collection of tickets',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -23,12 +23,12 @@ module.exports = Self => {
|
|||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/collectionNew`,
|
||||
path: `/newCollection`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.collectionNew = async(ctx, collectionFk, sectorFk, vWagons) => {
|
||||
Self.newCollection = async(ctx, collectionFk, sectorFk, vWagons) => {
|
||||
let query = '';
|
||||
|
||||
if (!collectionFk) {
|
||||
|
@ -85,6 +85,10 @@ module.exports = Self => {
|
|||
sale['saleFk'] = sales[x]['saleFk'];
|
||||
sale['itemFk'] = sales[x]['itemFk'];
|
||||
sale['quantity'] = sales[x]['quantity'];
|
||||
if (sales[x]['quantityPicked'] != null)
|
||||
sale['quantityPicked'] = sales[x]['quantityPicked'];
|
||||
else
|
||||
sale['quantityPicked'] = 0;
|
||||
sale['longName'] = sales[x]['longName'];
|
||||
sale['size'] = sales[x]['size'];
|
||||
sale['color'] = sales[x]['color'];
|
|
@ -0,0 +1,89 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('updateCollectionSale', {
|
||||
description: 'Update sale of a collection',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'sale',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The sale id'
|
||||
}, {
|
||||
arg: 'originalQuantity',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The quantity to sale'
|
||||
},
|
||||
{
|
||||
arg: 'quantity',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The quantity to picked'
|
||||
},
|
||||
{
|
||||
arg: 'quantityPicked',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The quantity to picked'
|
||||
}, {
|
||||
arg: 'ticketFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The ticket id'
|
||||
}, {
|
||||
arg: 'stateFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The state id'
|
||||
}, {
|
||||
arg: 'isNicho',
|
||||
type: 'Boolean',
|
||||
required: true,
|
||||
description: 'Determine if sale is picked from nicho or not'
|
||||
}, {
|
||||
arg: 'shelvingFk',
|
||||
type: 'String',
|
||||
required: false,
|
||||
description: 'The shelving id'
|
||||
}, {
|
||||
arg: 'itemFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The item id'
|
||||
}, {
|
||||
arg: 'sectorFk',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: 'The sector id'
|
||||
}],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/updateCollectionSale`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.updateCollectionSale = async(ctx, sale, originalQuantity, quantity, quantityPicked, ticketFk, stateFk, isNicho, shelvingFk, itemFk, sectorFk) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
if (originalQuantity == quantity) {
|
||||
query = `CALL vn.collection_updateSale(?,?,?,?,?)`;
|
||||
await Self.rawSql(query, [sale, originalQuantity, userId, stateFk, ticketFk]);
|
||||
}
|
||||
|
||||
if (!isNicho) {
|
||||
query = `CALL vn.collection_faults(?,?,?)`;
|
||||
await Self.rawSql(query, [shelvingFk, quantityPicked, itemFk]);
|
||||
} else {
|
||||
query = `CALL vn.sector_getWarehouse(?)`;
|
||||
const [result] = await Self.rawSql(query, [sectorFk]);
|
||||
|
||||
query = `CALL vn.itemPlacementSave(?,?,?)`;
|
||||
await Self.rawSql(query, [shelvingFk, quantityPicked, result[0]['warehouseFk']]);
|
||||
}
|
||||
query = `CALL vn.sale_updateOriginalQuantity(?,?)`;
|
||||
return await Self.rawSql(query, [sale, quantity]);
|
||||
};
|
||||
};
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/collection/collectionGet')(Self);
|
||||
require('../methods/collection/collectionNew')(Self);
|
||||
require('../methods/collection/getCollection')(Self);
|
||||
require('../methods/collection/newCollection')(Self);
|
||||
require('../methods/collection/getSectors')(Self);
|
||||
require('../methods/collection/collectionUpdateSale')(Self);
|
||||
require('../methods/collection/updateCollectionSale')(Self);
|
||||
require('../methods/collection/collectionFaults')(Self);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue