From 7caea444274d55e89d96d1f5abd99bfbdc1f870a Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 2 May 2024 13:53:28 +0200 Subject: [PATCH] feat(salix): refs #6321 #6321 getSimilar --- modules/item/back/methods/item/getSimilar.js | 59 ++++++++++++++++++++ modules/item/back/models/item.js | 1 + 2 files changed, 60 insertions(+) create mode 100644 modules/item/back/methods/item/getSimilar.js diff --git a/modules/item/back/methods/item/getSimilar.js b/modules/item/back/methods/item/getSimilar.js new file mode 100644 index 000000000..3ec72e1b1 --- /dev/null +++ b/modules/item/back/methods/item/getSimilar.js @@ -0,0 +1,59 @@ +module.exports = Self => { + Self.remoteMethodCtx('getSimilar', { + description: 'Returns the ', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'Object', + required: true, + description: 'Filter defining where and paginated data', + http: {source: 'query'} + }], + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/getSimilar`, + verb: 'GET' + } + }); + + Self.getSimilar = async(ctx, filter, options) => { + const myOptions = {userId: ctx.req.accessToken.userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + // const where = filter.where; + // const query = 'CALL vn.item_getSimilar(?, ?, ?)'; + // const [results] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); + + return [ + { + 'id': 1, + 'longName': 'Ranged weapon longbow 200cm', + 'subName': 'Stark Industries', + 'tag5': 'Color', + 'value5': 'Brown', + 'match5': 0, + 'match6': 0, + 'match7': 0, + 'match8': 1, + 'tag6': 'Categoria', + 'value6': '+1 precission', + 'tag7': 'Tallos', + 'value7': '1', + 'tag8': null, + 'value8': null, + 'available': 185, + 'calc_id': 6, + 'counter': 0, + 'minQuantity': 1, + 'visible': null, + 'price2': null + } + + ]; + }; +}; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index e715ab431..ec0d40840 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -5,6 +5,7 @@ module.exports = Self => { require('../methods/item/clone')(Self); require('../methods/item/updateTaxes')(Self); require('../methods/item/getBalance')(Self); + require('../methods/item/getSimilar')(Self); require('../methods/item/lastEntriesFilter')(Self); require('../methods/item/getSummary')(Self); require('../methods/item/getCard')(Self);