collection update sale

This commit is contained in:
Ainki 2020-03-23 10:36:10 +01:00 committed by Joan Sanchez
parent e893576591
commit 60d80502d1
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,42 @@
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 = `vn.collection_updateSale(?,?,?,?,?)`;
return await Self.rawSql(query, [sale, originalQuantity, userId, stateFk, ticketFk]);
};
};

View File

@ -2,4 +2,5 @@ module.exports = Self => {
require('../methods/collection/collectionGet')(Self);
require('../methods/collection/collectionNew')(Self);
require('../methods/collection/getSectors')(Self);
require('../methods/collection/collectionUpdateSale')(Self);
};