From a4f14e5fdad7db702f337535edf2dc63525ae9b9 Mon Sep 17 00:00:00 2001 From: Ainki Date: Mon, 23 Mar 2020 10:36:10 +0100 Subject: [PATCH] collection update sale --- .../collection/collectionUpdateSale.js | 42 +++++++++++++++++++ back/models/collection.js | 1 + 2 files changed, 43 insertions(+) create mode 100644 back/methods/collection/collectionUpdateSale.js diff --git a/back/methods/collection/collectionUpdateSale.js b/back/methods/collection/collectionUpdateSale.js new file mode 100644 index 000000000..4e8775755 --- /dev/null +++ b/back/methods/collection/collectionUpdateSale.js @@ -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]); + }; +}; diff --git a/back/models/collection.js b/back/models/collection.js index 2802425a5..9f944d72f 100644 --- a/back/models/collection.js +++ b/back/models/collection.js @@ -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); };