diff --git a/modules/item/back/methods/item/getVisibleAvailable.js b/modules/item/back/methods/item/getVisibleAvailable.js new file mode 100644 index 000000000..6e9f2b531 --- /dev/null +++ b/modules/item/back/methods/item/getVisibleAvailable.js @@ -0,0 +1,38 @@ +module.exports = Self => { + Self.remoteMethod('getVisibleAvailable', { + description: 'Returns visible and available for params', + accessType: '', + accepts: [ + { + arg: 'itemFk', + type: 'Number', + required: true, + }, + { + arg: 'warehouseFk', + type: 'Number', + required: true, + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/getVisibleAvailable`, + verb: 'GET' + } + }); + + Self.getVisibleAvailable = async(itemFk, warehouseFk) => { + let item = {}; + let query = ` + CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`; + + let options = [itemFk, warehouseFk, false]; + [res] = await Self.rawSql(query, options); + + item.available = res[0].available; + item.visible = res[0].visible; + return item; + }; +}; diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index e34b2eec5..628bd5a03 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -9,6 +9,7 @@ module.exports = Self => { require('../methods/item/getSummary')(Self); require('../methods/item/getCard')(Self); require('../methods/item/regularize')(Self); + require('../methods/item/getVisibleAvailable')(Self); require('../methods/item/new')(Self); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index 02e1267dc..22769d5a7 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -1,3 +1,10 @@ + +
diff --git a/modules/item/front/descriptor/index.js b/modules/item/front/descriptor/index.js index 4a3421f33..268fbfb8a 100644 --- a/modules/item/front/descriptor/index.js +++ b/modules/item/front/descriptor/index.js @@ -33,16 +33,21 @@ class Controller { } set item(value) { - this._item = value - this.avai = null - visible null - if (!this.item) - this._warehouseFk = parseInt(window.localStorage.defaultWarehouseFk); - llamar availabe - return this._warehouseFk; + this._item = value; + this.available = null; + this.visible = null; + if (!this.item) { + this.params = { + params: { + itemFk: this.item, + warehouseFk: this._warehouseFk + } + }; + } + return this._item; } - get item(){ + get item() { return this._item; } diff --git a/package-lock.json b/package-lock.json index d3dc2c650..3bc805f32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7575,7 +7575,7 @@ "jasmine-spec-reporter": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz", - "integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=", + "integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==", "dev": true, "requires": { "colors": "1.1.2" @@ -7863,7 +7863,7 @@ "karma-chrome-launcher": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", - "integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=", + "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", "dev": true, "requires": { "fs-access": "^1.0.0", @@ -9671,7 +9671,7 @@ "dependencies": { "commander": { "version": "1.0.4", - "resolved": "https://registry.npmjs.org/commander/-/commander-1.0.4.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-1.0.4.tgz", "integrity": "sha1-Xt6xruI8T7VBprcNaSq+8ZZpotM=", "dev": true, "requires": { @@ -11650,7 +11650,7 @@ }, "string_decoder": { "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, @@ -12119,7 +12119,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } @@ -12901,7 +12901,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { @@ -13367,7 +13367,7 @@ "split2": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", + "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=", "dev": true, "requires": { "through2": "^2.0.2" @@ -14855,7 +14855,7 @@ "useragent": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", - "integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=", + "integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==", "dev": true, "requires": { "lru-cache": "4.1.x", @@ -15571,7 +15571,7 @@ }, "globby": { "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "resolved": "http://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { @@ -15584,7 +15584,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }