From eefafb3ac2ba7aa163beffb932d917d951b5a8ab Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 19 Jan 2023 15:14:31 +0100 Subject: [PATCH 01/12] fix: available is cero --- modules/item/back/methods/item/getSummary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 738976e60..0cee86955 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -100,7 +100,7 @@ module.exports = Self => { const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); - res = await models.Item.getVisibleAvailable(summary.item.id, userConfig.warehouseFk, null, myOptions); + res = await models.Item.getVisibleAvailable(summary.item.id, userConfig.warehouseFk, undefined, myOptions); summary.available = res.available; summary.visible = res.visible; From caf1dcd690a6d09d29817f95b4da5ce15dc774f8 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 25 Jan 2023 15:19:33 +0100 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20a=C3=B1adido=20almac=C3=A9n=20por?= =?UTF-8?q?=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/models/company.json | 6 +- modules/item/back/methods/item/getSummary.js | 4 +- modules/item/front/summary/index.html | 77 +++++++++++--------- modules/item/front/summary/locale/en.yml | 2 + modules/item/front/summary/locale/es.yml | 4 +- modules/ticket/front/summary/index.html | 60 +++++++-------- 6 files changed, 85 insertions(+), 68 deletions(-) create mode 100644 modules/item/front/summary/locale/en.yml diff --git a/back/models/company.json b/back/models/company.json index a36b43b69..6b50a1697 100644 --- a/back/models/company.json +++ b/back/models/company.json @@ -18,12 +18,14 @@ }, "expired": { "type": "date" + }, + "warehouseFk": { + "type": "number" } }, - "scope": { "where" :{ "expired": null } } -} \ No newline at end of file +} diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 0cee86955..5f88ca939 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -99,8 +99,10 @@ module.exports = Self => { [summary.botanical] = res[2]; const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); + console.log(userConfig.warehouseFk); + const company = await models.Company.findOne({where: {code: 'VNL'}}, myOptions); - res = await models.Item.getVisibleAvailable(summary.item.id, userConfig.warehouseFk, undefined, myOptions); + res = await models.Item.getVisibleAvailable(summary.item.id, company.warehouseFk, undefined, myOptions); summary.available = res.available; summary.visible = res.visible; diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index a4d40c829..cd4d69ca3 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -11,7 +11,7 @@ @@ -20,46 +20,55 @@

Available

-

{{$ctrl.summary.available}}

-
+

{{$ctrl.summary.available}} + + +

+

- Basic data

Basic data

- - - - - - - {{$ctrl.summary.item.itemType.worker.user.name}} @@ -68,45 +77,45 @@

- Other data

Other data

- - - - - -

- Tags

-

Tags @@ -119,14 +128,14 @@

- Description

Description

@@ -136,13 +145,13 @@

- Tax

-

Tax @@ -154,33 +163,33 @@

- Botanical

-

Botanical

- -

- Barcode

-

Barcode @@ -191,6 +200,6 @@ - - \ No newline at end of file + diff --git a/modules/item/front/summary/locale/en.yml b/modules/item/front/summary/locale/en.yml new file mode 100644 index 000000000..79c19a94d --- /dev/null +++ b/modules/item/front/summary/locale/en.yml @@ -0,0 +1,2 @@ +WarehouseFk: > + Calculated on the warehouse of {{ name }} diff --git a/modules/item/front/summary/locale/es.yml b/modules/item/front/summary/locale/es.yml index a87a04857..709d22efd 100644 --- a/modules/item/front/summary/locale/es.yml +++ b/modules/item/front/summary/locale/es.yml @@ -1,3 +1,5 @@ Barcode: Códigos de barras Other data: Otros datos -Go to the item: Ir al artículo \ No newline at end of file +Go to the item: Ir al artículo +WarehouseFk: > + Calculado sobre el almacén de {{ name }} diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index fe49a301f..6565b7195 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -1,6 +1,6 @@
- - Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} + Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} ({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}} - -
- - {{$ctrl.summary.client.salesPersonUser.name}} - @@ -47,11 +47,11 @@ {{$ctrl.summary.zone.name}} - - {{$ctrl.summary.routeFk}} @@ -66,17 +66,17 @@ - - -

- Sale @@ -146,13 +146,13 @@ vn-tooltip="{{::$ctrl.$t('Claim')}}: {{::sale.claimBeginning.claimFk}}"> - - @@ -170,22 +170,22 @@ - {{sale.itemFk | zeroFill:6}} - {{::sale.visible}} - {{::sale.available}} @@ -216,7 +216,7 @@

- Packages @@ -241,7 +241,7 @@

- Service @@ -276,7 +276,7 @@

- Purchase request @@ -304,7 +304,7 @@ {{::request.quantity}} {{::request.price}} - @@ -336,9 +336,9 @@ - - - \ No newline at end of file + From 366748a13686b421f6699bd3f943e70255aad83c Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 26 Jan 2023 14:00:29 +0100 Subject: [PATCH 03/12] fix: se la pasa la fecha shipped para calcular el visible y disponible --- modules/ticket/front/sale/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 97f6a2a81..527f55b23 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -130,7 +130,7 @@ + ng-click="itemDescriptor.show($event, sale.itemFk, sale.id, $ctrl.ticket.shipped)"> {{sale.itemFk}} Date: Tue, 31 Jan 2023 09:28:28 +0100 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20el=20descriptor=20coge=20el=20war?= =?UTF-8?q?ehouseFk=20dependiendo=20de=20la=20secci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/item/back/methods/item/getSummary.js | 4 ++-- modules/item/front/card/index.html | 4 ++-- modules/item/front/card/index.js | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 5f88ca939..216093bf1 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -101,8 +101,8 @@ module.exports = Self => { const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); console.log(userConfig.warehouseFk); const company = await models.Company.findOne({where: {code: 'VNL'}}, myOptions); - - res = await models.Item.getVisibleAvailable(summary.item.id, company.warehouseFk, undefined, myOptions); + console.log(company.warehouseFk); + res = await models.Item.getVisibleAvailable(summary.item.id, 1, undefined, myOptions); summary.available = res.available; summary.visible = res.visible; diff --git a/modules/item/front/card/index.html b/modules/item/front/card/index.html index e92e1696d..f141649eb 100644 --- a/modules/item/front/card/index.html +++ b/modules/item/front/card/index.html @@ -1,6 +1,6 @@ - diff --git a/modules/item/front/card/index.js b/modules/item/front/card/index.js index 8b32e030b..ca150e880 100644 --- a/modules/item/front/card/index.js +++ b/modules/item/front/card/index.js @@ -2,6 +2,12 @@ import ngModule from '../module'; import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { + getWarehouseFk() { + if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') + return this.$params.warehouseFk; + return this.vnConfig.warehouseFk; + } + reload() { this.$http.get(`Items/${this.$params.id}/getCard`) .then(res => this.item = res.data); From ba5616055b38b905c9f2bc249a7608d3665fa505 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 3 Feb 2023 14:31:50 +0100 Subject: [PATCH 05/12] feat: item.descriptor en summary coge el warehouse por defecto --- back/models/company.json | 3 --- db/changes/230601/00-itemConfig_warehouseFk.sql | 4 ++++ modules/item/back/methods/item/getSummary.js | 8 +++----- modules/item/back/models/item-config.json | 3 +++ modules/item/front/card/index.html | 2 +- modules/item/front/card/index.js | 13 ++++++++++--- 6 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 db/changes/230601/00-itemConfig_warehouseFk.sql diff --git a/back/models/company.json b/back/models/company.json index 6b50a1697..f16c5762f 100644 --- a/back/models/company.json +++ b/back/models/company.json @@ -18,9 +18,6 @@ }, "expired": { "type": "date" - }, - "warehouseFk": { - "type": "number" } }, "scope": { diff --git a/db/changes/230601/00-itemConfig_warehouseFk.sql b/db/changes/230601/00-itemConfig_warehouseFk.sql new file mode 100644 index 000000000..c860986d6 --- /dev/null +++ b/db/changes/230601/00-itemConfig_warehouseFk.sql @@ -0,0 +1,4 @@ +ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL; +UPDATE `vn`.`itemConfig` + SET warehouseFk=60 +WHERE id=0; diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 216093bf1..a74fab359 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -98,11 +98,9 @@ module.exports = Self => { summary.tags = res[1]; [summary.botanical] = res[2]; - const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); - console.log(userConfig.warehouseFk); - const company = await models.Company.findOne({where: {code: 'VNL'}}, myOptions); - console.log(company.warehouseFk); - res = await models.Item.getVisibleAvailable(summary.item.id, 1, undefined, myOptions); + const itemConfig = await models.ItemConfig.findOne({where: {code: 'VNL'}}, myOptions); + + res = await models.Item.getVisibleAvailable(summary.item.id, itemConfig.warehouseFk, undefined, myOptions); summary.available = res.available; summary.visible = res.visible; diff --git a/modules/item/back/models/item-config.json b/modules/item/back/models/item-config.json index 36d25e0bb..c7a0b2644 100644 --- a/modules/item/back/models/item-config.json +++ b/modules/item/back/models/item-config.json @@ -25,6 +25,9 @@ }, "defaultTag": { "type": "int" + }, + "warehouseFk": { + "type": "int" } }, "relations": { diff --git a/modules/item/front/card/index.html b/modules/item/front/card/index.html index f141649eb..330d274c0 100644 --- a/modules/item/front/card/index.html +++ b/modules/item/front/card/index.html @@ -1,6 +1,6 @@ diff --git a/modules/item/front/card/index.js b/modules/item/front/card/index.js index ca150e880..ba9e18c0b 100644 --- a/modules/item/front/card/index.js +++ b/modules/item/front/card/index.js @@ -3,14 +3,21 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { getWarehouseFk() { - if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') - return this.$params.warehouseFk; - return this.vnConfig.warehouseFk; + if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') { + this.warehouseFk = this.$params.warehouseFk; + return; + } + this.$http.get('ItemConfigs/findOne') + .then(res => { + this.warehouseFk = res.data.warehouseFk; + }); } reload() { this.$http.get(`Items/${this.$params.id}/getCard`) .then(res => this.item = res.data); + + this.getWarehouseFk(); } } From 4f76465246576260c8ebe0a0a2bc7fed57252402 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 6 Feb 2023 12:24:26 +0100 Subject: [PATCH 06/12] fix: no recarga cada vez --- db/dump/fixtures.sql | 4 ++-- modules/item/front/card/index.html | 2 +- modules/item/front/card/index.js | 11 ++++------- modules/item/front/descriptor/index.js | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index bb4f00ff5..e03619aae 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2718,9 +2718,9 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack VALUES (3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL); -INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`) +INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk`) VALUES - (0, 0, 24, '', '[1,2,3]', 2, 56); + (0, 0, 24, '', '[1,2,3]', 2, 56, 60); INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) VALUES diff --git a/modules/item/front/card/index.html b/modules/item/front/card/index.html index 330d274c0..f141649eb 100644 --- a/modules/item/front/card/index.html +++ b/modules/item/front/card/index.html @@ -1,6 +1,6 @@ diff --git a/modules/item/front/card/index.js b/modules/item/front/card/index.js index ba9e18c0b..8ff9e2da6 100644 --- a/modules/item/front/card/index.js +++ b/modules/item/front/card/index.js @@ -3,21 +3,18 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { getWarehouseFk() { - if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') { - this.warehouseFk = this.$params.warehouseFk; - return; - } + if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') + return this.$params.warehouseFk; + this.$http.get('ItemConfigs/findOne') .then(res => { - this.warehouseFk = res.data.warehouseFk; + return res.data.warehouseFk; }); } reload() { this.$http.get(`Items/${this.$params.id}/getCard`) .then(res => this.item = res.data); - - this.getWarehouseFk(); } } diff --git a/modules/item/front/descriptor/index.js b/modules/item/front/descriptor/index.js index 133b11b48..61c8e7464 100644 --- a/modules/item/front/descriptor/index.js +++ b/modules/item/front/descriptor/index.js @@ -100,6 +100,6 @@ ngModule.vnComponent('vnItemDescriptor', { item: '<', dated: '<', cardReload: '&', - warehouseFk: ' Date: Tue, 7 Feb 2023 13:40:39 +0100 Subject: [PATCH 07/12] =?UTF-8?q?feat:=20a=C3=B1adido=20icono=20info,=20qu?= =?UTF-8?q?e=20indica=20de=20que=20almac=C3=A9n=20se=20saca=20la=20informa?= =?UTF-8?q?ci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/item/front/card/index.html | 2 +- modules/item/front/card/index.js | 10 ------- modules/item/front/descriptor/index.html | 36 +++++++++++++++--------- modules/item/front/descriptor/index.js | 21 +++++++++++++- modules/item/front/diary/index.js | 4 +++ modules/item/front/summary/index.html | 13 +++++---- modules/item/front/summary/index.js | 21 ++++++++++++++ modules/item/front/summary/locale/en.yml | 3 +- modules/item/front/summary/locale/es.yml | 3 +- modules/item/front/summary/style.scss | 8 ++++-- 10 files changed, 84 insertions(+), 37 deletions(-) diff --git a/modules/item/front/card/index.html b/modules/item/front/card/index.html index f141649eb..330d274c0 100644 --- a/modules/item/front/card/index.html +++ b/modules/item/front/card/index.html @@ -1,6 +1,6 @@ diff --git a/modules/item/front/card/index.js b/modules/item/front/card/index.js index 8ff9e2da6..8b32e030b 100644 --- a/modules/item/front/card/index.js +++ b/modules/item/front/card/index.js @@ -2,16 +2,6 @@ import ngModule from '../module'; import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { - getWarehouseFk() { - if (this.$state.getCurrentPath()[4].state.name === 'item.card.diary') - return this.$params.warehouseFk; - - this.$http.get('ItemConfigs/findOne') - .then(res => { - return res.data.warehouseFk; - }); - } - reload() { this.$http.get(`Items/${this.$params.id}/getCard`) .then(res => this.item = res.data); diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index 321545b38..8e85e043f 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -19,7 +19,7 @@
Available

{{$ctrl.available | dashIfEmpty}}

+ +

+ + +

+
- {{$ctrl.item.itemType.worker.user.name}} @@ -50,22 +60,22 @@
@@ -112,7 +122,7 @@ question="Do you want to clone this item?" message="All it's properties will be copied"> - @@ -120,7 +130,7 @@ - - \ No newline at end of file + diff --git a/modules/item/front/descriptor/index.js b/modules/item/front/descriptor/index.js index 61c8e7464..0acc7c8f6 100644 --- a/modules/item/front/descriptor/index.js +++ b/modules/item/front/descriptor/index.js @@ -30,7 +30,10 @@ class Controller extends Descriptor { set warehouseFk(value) { this._warehouseFk = value; - if (value) this.updateStock(); + if (value) { + this.updateStock(); + this.getWarehouseName(value); + } } loadData() { @@ -89,6 +92,22 @@ class Controller extends Descriptor { this.$.photo.setAttribute('src', newSrc); this.$.photo.setAttribute('zoom-image', newZoomSrc); } + + getWarehouseName(warehouseFk) { + this.showIcon = false; + + const filter = { + where: {id: warehouseFk} + }; + this.$http.get('Warehouses/findOne', {filter}) + .then(res => { + this.warehouseText = this.$t('WarehouseFk', { + warehouseName: res.data.name + }); + + this.showIcon = true; + }); + } } Controller.$inject = ['$element', '$scope', '$rootScope']; diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index c997ea491..cc965a76e 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -37,6 +37,7 @@ class Controller extends Section { set warehouseFk(value) { if (value && value != this._warehouseFk) { this._warehouseFk = value; + this.card.warehouseFk = value; this.$state.go(this.$state.current.name, { warehouseFk: value @@ -76,5 +77,8 @@ ngModule.vnComponent('vnItemDiary', { controller: Controller, bindings: { item: '<' + }, + require: { + card: '?^vnItemCard' } }); diff --git a/modules/item/front/summary/index.html b/modules/item/front/summary/index.html index cd4d69ca3..40e9c5aa7 100644 --- a/modules/item/front/summary/index.html +++ b/modules/item/front/summary/index.html @@ -20,17 +20,18 @@

Available

-

{{$ctrl.summary.available}} +

{{$ctrl.summary.available}}

+
+ +

- +
diff --git a/modules/item/front/summary/index.js b/modules/item/front/summary/index.js index 52753ff65..3d2517110 100644 --- a/modules/item/front/summary/index.js +++ b/modules/item/front/summary/index.js @@ -7,6 +7,24 @@ class Controller extends Summary { this.$http.get(`Items/${this.item.id}/getSummary`).then(response => { this.summary = response.data; }); + + this.$http.get('ItemConfigs/findOne') + .then(res => { + this.card.warehouseFk = res.data.warehouseFk; + this.getWarehouseName(this.card.warehouseFk); + }); + } + + getWarehouseName(warehouseFk) { + const filter = { + where: {id: warehouseFk} + }; + this.$http.get('Warehouses/findOne', {filter}) + .then(res => { + this.warehouseText = this.$t('WarehouseFk', { + warehouseName: res.data.name + }); + }); } $onChanges() { @@ -37,4 +55,7 @@ ngModule.vnComponent('vnItemSummary', { bindings: { item: '<', }, + require: { + card: '?^vnItemCard' + } }); diff --git a/modules/item/front/summary/locale/en.yml b/modules/item/front/summary/locale/en.yml index 79c19a94d..0ec208720 100644 --- a/modules/item/front/summary/locale/en.yml +++ b/modules/item/front/summary/locale/en.yml @@ -1,2 +1 @@ -WarehouseFk: > - Calculated on the warehouse of {{ name }} +WarehouseFk: Calculated on the warehouse of {{ warehouseName }} diff --git a/modules/item/front/summary/locale/es.yml b/modules/item/front/summary/locale/es.yml index 709d22efd..2e78841ae 100644 --- a/modules/item/front/summary/locale/es.yml +++ b/modules/item/front/summary/locale/es.yml @@ -1,5 +1,4 @@ Barcode: Códigos de barras Other data: Otros datos Go to the item: Ir al artículo -WarehouseFk: > - Calculado sobre el almacén de {{ name }} +WarehouseFk: Calculado sobre el almacén de {{ warehouseName }} diff --git a/modules/item/front/summary/style.scss b/modules/item/front/summary/style.scss index 7d5e3b609..d047f3e36 100644 --- a/modules/item/front/summary/style.scss +++ b/modules/item/front/summary/style.scss @@ -29,7 +29,11 @@ vn-item-summary { padding: 0; &:nth-child(1) { - border-right: 1px solid white; + border-right: 1px solid white; + } + + &:nth-child(2) { + border-right: 1px solid white; } } -} \ No newline at end of file +} From b70311999d72236cb1da6c45ad84c47e3cfa650d Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 8 Feb 2023 09:41:09 +0100 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20eliminado=20codigo=20innecesa?= =?UTF-8?q?rio=20y=20quitado=20update=20que=20se=20har=C3=A1=20directament?= =?UTF-8?q?e=20en=20producci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/230601/00-itemConfig_warehouseFk.sql | 3 --- modules/item/back/methods/item/getSummary.js | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/db/changes/230601/00-itemConfig_warehouseFk.sql b/db/changes/230601/00-itemConfig_warehouseFk.sql index c860986d6..b2e11146d 100644 --- a/db/changes/230601/00-itemConfig_warehouseFk.sql +++ b/db/changes/230601/00-itemConfig_warehouseFk.sql @@ -1,4 +1 @@ ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL; -UPDATE `vn`.`itemConfig` - SET warehouseFk=60 -WHERE id=0; diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index a74fab359..6cd9d9511 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -98,8 +98,7 @@ module.exports = Self => { summary.tags = res[1]; [summary.botanical] = res[2]; - const itemConfig = await models.ItemConfig.findOne({where: {code: 'VNL'}}, myOptions); - + const itemConfig = await models.ItemConfig.findOne(null, myOptions); res = await models.Item.getVisibleAvailable(summary.item.id, itemConfig.warehouseFk, undefined, myOptions); summary.available = res.available; From bb2eddc462f7cebfe2d3667c39c334708819fde5 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Feb 2023 07:32:44 +0100 Subject: [PATCH 09/12] fix: test front --- modules/item/front/diary/index.spec.js | 1 + modules/item/front/summary/index.spec.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js index a80fbfc69..a6302346d 100644 --- a/modules/item/front/diary/index.spec.js +++ b/modules/item/front/diary/index.spec.js @@ -14,6 +14,7 @@ describe('Item', () => { controller = $componentController('vnItemDiary', {$element, $scope}); controller.$.model = crudModel; controller.$params = {id: 1}; + controller.card = {}; })); describe('set item()', () => { diff --git a/modules/item/front/summary/index.spec.js b/modules/item/front/summary/index.spec.js index 0b349194c..d7821bea0 100644 --- a/modules/item/front/summary/index.spec.js +++ b/modules/item/front/summary/index.spec.js @@ -14,12 +14,15 @@ describe('Item', () => { const $element = angular.element(''); controller = $componentController('vnItemSummary', {$element, $scope}); controller.item = {id: 1}; + controller.card = {}; })); describe('getSummary()', () => { it('should perform a query to set summary', () => { let data = {id: 1, name: 'Gem of mind'}; $httpBackend.expect('GET', `Items/1/getSummary`).respond(200, data); + $httpBackend.expect('GET', `ItemConfigs/findOne`).respond({}); + $httpBackend.expect('GET', `Warehouses/findOne`).respond({}); controller.getSummary(); $httpBackend.flush(); From dc2ab50f659fcd8cc29397db2ee2e6c6234d5e33 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Feb 2023 09:44:06 +0100 Subject: [PATCH 10/12] fix: test e2e --- db/changes/230201/00-validPriorities_ItemConfig.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/changes/230201/00-validPriorities_ItemConfig.sql b/db/changes/230201/00-validPriorities_ItemConfig.sql index a793997d0..0b32d5de8 100644 --- a/db/changes/230201/00-validPriorities_ItemConfig.sql +++ b/db/changes/230201/00-validPriorities_ItemConfig.sql @@ -3,7 +3,3 @@ ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultT ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL; ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL; ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos'; - -INSERT INTO `salix`.`ACL` -(model, property, accessType, permission, principalType, principalId) -VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer'); From 3dd870f7df7fe2903ebec4bb12c4958a36b2b689 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Feb 2023 09:44:20 +0100 Subject: [PATCH 11/12] fix: test e2e --- db/changes/230202/00-itemConfig.sql | 4 ---- db/changes/230601/00-itemConfig_warehouseFk.sql | 2 ++ modules/item/front/summary/index.js | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/db/changes/230202/00-itemConfig.sql b/db/changes/230202/00-itemConfig.sql index a793997d0..0b32d5de8 100644 --- a/db/changes/230202/00-itemConfig.sql +++ b/db/changes/230202/00-itemConfig.sql @@ -3,7 +3,3 @@ ALTER TABLE `vn`.`itemConfig` ADD CONSTRAINT itemConfig_FK FOREIGN KEY (defaultT ALTER TABLE `vn`.`itemConfig` ADD validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL; ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 NOT NULL; ALTER TABLE `vn`.`item` MODIFY COLUMN relevancy tinyint(1) DEFAULT 0 NOT NULL COMMENT 'La web ordena de forma descendiente por este campo para mostrar los artículos'; - -INSERT INTO `salix`.`ACL` -(model, property, accessType, permission, principalType, principalId) -VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer'); diff --git a/db/changes/230601/00-itemConfig_warehouseFk.sql b/db/changes/230601/00-itemConfig_warehouseFk.sql index b2e11146d..37631964a 100644 --- a/db/changes/230601/00-itemConfig_warehouseFk.sql +++ b/db/changes/230601/00-itemConfig_warehouseFk.sql @@ -1 +1,3 @@ ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL; +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/item/front/summary/index.js b/modules/item/front/summary/index.js index 3d2517110..e17a6a8c4 100644 --- a/modules/item/front/summary/index.js +++ b/modules/item/front/summary/index.js @@ -10,8 +10,8 @@ class Controller extends Summary { this.$http.get('ItemConfigs/findOne') .then(res => { - this.card.warehouseFk = res.data.warehouseFk; - this.getWarehouseName(this.card.warehouseFk); + if (this.card) this.card.warehouseFk = res.data.warehouseFk; + this.getWarehouseName(res.data.warehouseFk); }); } From 76f203012574c025b346cfdf8d3e5d224c64d83a Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 16 Feb 2023 09:50:25 +0100 Subject: [PATCH 12/12] feat: add update sql --- db/changes/230601/00-itemConfig_warehouseFk.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/changes/230601/00-itemConfig_warehouseFk.sql b/db/changes/230601/00-itemConfig_warehouseFk.sql index 37631964a..84987d512 100644 --- a/db/changes/230601/00-itemConfig_warehouseFk.sql +++ b/db/changes/230601/00-itemConfig_warehouseFk.sql @@ -1,3 +1,6 @@ ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL; +UPDATE `vn`.`itemConfig` + SET warehouseFk=60 +WHERE id=0; INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'employee');