2022-02-08 11:41:55 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('setSaleQuantity', {
|
|
|
|
description: 'Update sale quantity',
|
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: [{
|
|
|
|
arg: 'saleId',
|
|
|
|
type: 'number',
|
|
|
|
required: true,
|
|
|
|
description: 'The sale id'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
arg: 'quantity',
|
|
|
|
type: 'number',
|
|
|
|
required: true,
|
|
|
|
description: 'The quantity to picked'
|
|
|
|
}],
|
|
|
|
returns: {
|
|
|
|
type: 'object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/setSaleQuantity`,
|
|
|
|
verb: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.setSaleQuantity = async ctx => {
|
|
|
|
const args = ctx.args;
|
|
|
|
const models = Self.app.models;
|
|
|
|
|
2022-04-13 11:55:18 +00:00
|
|
|
const sale = await models.Sale.findById(args.saleId);
|
2022-02-08 11:41:55 +00:00
|
|
|
return await sale.updateAttribute('quantity', args.quantity);
|
|
|
|
};
|
|
|
|
};
|