diff --git a/back/methods/collection/collectionMissingTrash.js b/back/methods/collection/collectionMissingTrash.js new file mode 100644 index 000000000..06cbcaa36 --- /dev/null +++ b/back/methods/collection/collectionMissingTrash.js @@ -0,0 +1,51 @@ +module.exports = Self => { + Self.remoteMethodCtx('collectionMissingTrash', { + description: 'Modify the amount of a sale throwing it into faults or trash', + accessType: 'WRITE', + accepts: [{ + arg: 'saleId', + type: 'number', + required: true, + description: 'The sale id' + }, + { + arg: 'quantity', + type: 'number', + required: true, + description: 'The ammount to throw' + }, + { + arg: 'isTrash', + type: 'boolean', + required: true, + description: 'trash or fault?' + }, + { + arg: 'warehouseId', + type: 'number', + required: true, + description: 'The warehouse Id from wich the items will be removed' + }, + { + arg: 'newQuantity', + type: 'number', + required: true, + description: 'The amount that will be left on the original ticket' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/collectionMissingTrash`, + verb: 'POST' + } + }); + + Self.collectionMissingTrash = async(saleId, quantity, isTrash, warehouseId, newQuantity) => { + let params = [saleId.args.saleId, quantity, isTrash, warehouseId, newQuantity]; + const query = `CALL vn.collection_missingTrash(?)`; + const [result] = await Self.rawSql(query, [params]); + return result; + }; +}; diff --git a/back/models/collection.js b/back/models/collection.js index 436414f62..6792ef5cc 100644 --- a/back/models/collection.js +++ b/back/models/collection.js @@ -3,4 +3,5 @@ module.exports = Self => { require('../methods/collection/newCollection')(Self); require('../methods/collection/getSectors')(Self); require('../methods/collection/setSaleQuantity')(Self); + require('../methods/collection/collectionMissingTrash')(Self); }; diff --git a/db/changes/10490-august/00-ACL-collectionMissingTrash.sql b/db/changes/10490-august/00-ACL-collectionMissingTrash.sql new file mode 100644 index 000000000..75c6210b9 --- /dev/null +++ b/db/changes/10490-august/00-ACL-collectionMissingTrash.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,principalId) + VALUES ('Collection','collectionMissingTrash','*','employee');