5097-item.summary_available #1312

Merged
vicent merged 16 commits from 5097-item.summary_available into dev 2023-02-17 08:54:23 +00:00
19 changed files with 141 additions and 68 deletions

View File

@ -20,7 +20,6 @@
"type": "date" "type": "date"
} }
}, },
"scope": { "scope": {
"where" :{ "where" :{
"expired": null "expired": null

View File

@ -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 validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 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'; 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');

View File

@ -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 validPriorities varchar(50) DEFAULT '[1,2,3]' NOT NULL;
ALTER TABLE `vn`.`itemConfig` ADD defaultPriority INT DEFAULT 2 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'; 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');

View File

@ -0,0 +1,6 @@
ALTER TABLE `vn`.`itemConfig` ADD warehouseFk smallint(6) unsigned NULL;
UPDATE `vn`.`itemConfig`

quitar el update de itemConfig, debe hacerse directamente en produccion cuando se suba

quitar el update de itemConfig, debe hacerse directamente en produccion cuando se suba

Ara ho cambie, pero pq no es pot en un chages.sql?

Ara ho cambie, pero pq no es pot en un chages.sql?
SET warehouseFk=60
WHERE id=0;
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
VALUES('ItemConfig', '*', 'READ', 'ALLOW', 'ROLE', 'employee');

View File

@ -2744,9 +2744,9 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack
VALUES VALUES
(3, util.VN_NOW(), 1107, 5, NULL, 0, 0, 1, NULL, NULL); (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 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`) INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`)
VALUES VALUES

View File

@ -98,9 +98,8 @@ module.exports = Self => {
summary.tags = res[1]; summary.tags = res[1];
[summary.botanical] = res[2]; [summary.botanical] = res[2];
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); const itemConfig = await models.ItemConfig.findOne(null, myOptions);

que fa esta linea?

que fa esta linea?

Agarra el unic registre de itemConfig, pero he vist q el where sobra. Ho modifique també.

Agarra el unic registre de itemConfig, pero he vist q el where sobra. Ho modifique també.
res = await models.Item.getVisibleAvailable(summary.item.id, itemConfig.warehouseFk, undefined, myOptions);
res = await models.Item.getVisibleAvailable(summary.item.id, userConfig.warehouseFk, null, myOptions);
summary.available = res.available; summary.available = res.available;
summary.visible = res.visible; summary.visible = res.visible;

View File

@ -25,6 +25,9 @@
}, },
"defaultTag": { "defaultTag": {
"type": "int" "type": "int"
},
"warehouseFk": {
"type": "int"
} }
}, },
"relations": { "relations": {

View File

@ -1,6 +1,6 @@
<vn-portal slot="menu"> <vn-portal slot="menu">
<vn-item-descriptor <vn-item-descriptor
warehouse-fk="$ctrl.vnConfig.warehouseFk" warehouse-fk="$ctrl.warehouseFk"
item="$ctrl.item" item="$ctrl.item"
card-reload="$ctrl.reload()"></vn-item-descriptor> card-reload="$ctrl.reload()"></vn-item-descriptor>
<vn-left-menu source="card"></vn-left-menu> <vn-left-menu source="card"></vn-left-menu>

View File

@ -36,6 +36,16 @@
<p translate>Available</p> <p translate>Available</p>
<p>{{$ctrl.available | dashIfEmpty}}</p> <p>{{$ctrl.available | dashIfEmpty}}</p>
</vn-one> </vn-one>
<vn-one>
<p>
<vn-icon
ng-if="$ctrl.showIcon"
icon="info_outline"
vn-tooltip="{{$ctrl.warehouseText}}"
pointer>
</vn-icon>
</p>
</vn-one>
</vn-horizontal> </vn-horizontal>
</slot-before> </slot-before>
<slot-body> <slot-body>

View File

@ -30,7 +30,10 @@ class Controller extends Descriptor {
set warehouseFk(value) { set warehouseFk(value) {
this._warehouseFk = value; this._warehouseFk = value;
if (value) this.updateStock(); if (value) {
this.updateStock();
this.getWarehouseName(value);
}
} }
loadData() { loadData() {
@ -89,6 +92,22 @@ class Controller extends Descriptor {
this.$.photo.setAttribute('src', newSrc); this.$.photo.setAttribute('src', newSrc);
this.$.photo.setAttribute('zoom-image', newZoomSrc); 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']; Controller.$inject = ['$element', '$scope', '$rootScope'];
@ -100,6 +119,6 @@ ngModule.vnComponent('vnItemDescriptor', {
item: '<', item: '<',
dated: '<', dated: '<',
cardReload: '&', cardReload: '&',
warehouseFk: '<?' warehouseFk: '<'
} }
}); });

View File

@ -37,6 +37,7 @@ class Controller extends Section {
set warehouseFk(value) { set warehouseFk(value) {
if (value && value != this._warehouseFk) { if (value && value != this._warehouseFk) {
this._warehouseFk = value; this._warehouseFk = value;
this.card.warehouseFk = value;
this.$state.go(this.$state.current.name, { this.$state.go(this.$state.current.name, {
warehouseFk: value warehouseFk: value
@ -76,5 +77,8 @@ ngModule.vnComponent('vnItemDiary', {
controller: Controller, controller: Controller,
bindings: { bindings: {
item: '<' item: '<'
},
require: {
card: '?^vnItemCard'
} }
}); });

View File

@ -14,6 +14,7 @@ describe('Item', () => {
controller = $componentController('vnItemDiary', {$element, $scope}); controller = $componentController('vnItemDiary', {$element, $scope});
controller.$.model = crudModel; controller.$.model = crudModel;
controller.$params = {id: 1}; controller.$params = {id: 1};
controller.card = {};
})); }));
describe('set item()', () => { describe('set item()', () => {

View File

@ -22,6 +22,16 @@
<p translate>Available</p> <p translate>Available</p>
<p>{{$ctrl.summary.available}}</p> <p>{{$ctrl.summary.available}}</p>
</vn-one> </vn-one>
<vn-one>
<p>
<vn-icon
ng-if="$ctrl.warehouseText != null"
icon="info_outline"
vn-tooltip="{{$ctrl.warehouseText}}"
pointer>
</vn-icon>
</p>
</vn-one>
</vn-horizontal> </vn-horizontal>
</vn-one> </vn-one>
<vn-one name="basicData"> <vn-one name="basicData">

View File

@ -7,6 +7,24 @@ class Controller extends Summary {
this.$http.get(`Items/${this.item.id}/getSummary`).then(response => { this.$http.get(`Items/${this.item.id}/getSummary`).then(response => {
this.summary = response.data; this.summary = response.data;
}); });
this.$http.get('ItemConfigs/findOne')
.then(res => {
if (this.card) this.card.warehouseFk = res.data.warehouseFk;
this.getWarehouseName(res.data.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() { $onChanges() {
@ -37,4 +55,7 @@ ngModule.vnComponent('vnItemSummary', {
bindings: { bindings: {
item: '<', item: '<',
}, },
require: {
card: '?^vnItemCard'
}
}); });

View File

@ -14,12 +14,15 @@ describe('Item', () => {
const $element = angular.element('<vn-item-summary></vn-item-summary>'); const $element = angular.element('<vn-item-summary></vn-item-summary>');
controller = $componentController('vnItemSummary', {$element, $scope}); controller = $componentController('vnItemSummary', {$element, $scope});
controller.item = {id: 1}; controller.item = {id: 1};
controller.card = {};
})); }));
describe('getSummary()', () => { describe('getSummary()', () => {
it('should perform a query to set summary', () => { it('should perform a query to set summary', () => {
let data = {id: 1, name: 'Gem of mind'}; let data = {id: 1, name: 'Gem of mind'};
$httpBackend.expect('GET', `Items/1/getSummary`).respond(200, data); $httpBackend.expect('GET', `Items/1/getSummary`).respond(200, data);
$httpBackend.expect('GET', `ItemConfigs/findOne`).respond({});
$httpBackend.expect('GET', `Warehouses/findOne`).respond({});
controller.getSummary(); controller.getSummary();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -0,0 +1 @@
WarehouseFk: Calculated on the warehouse of {{ warehouseName }}

View File

@ -1,3 +1,4 @@
Barcode: Códigos de barras Barcode: Códigos de barras
Other data: Otros datos Other data: Otros datos
Go to the item: Ir al artículo Go to the item: Ir al artículo
WarehouseFk: Calculado sobre el almacén de {{ warehouseName }}

View File

@ -31,5 +31,9 @@ vn-item-summary {
&:nth-child(1) { &:nth-child(1) {
border-right: 1px solid white; border-right: 1px solid white;
} }
&:nth-child(2) {
border-right: 1px solid white;
}
} }
} }

View File

@ -131,7 +131,7 @@
</vn-td> </vn-td>
<vn-td> <vn-td>
<span class="link" ng-if="sale.id" <span class="link" ng-if="sale.id"
ng-click="itemDescriptor.show($event, sale.itemFk, sale.id)"> ng-click="itemDescriptor.show($event, sale.itemFk, sale.id, $ctrl.ticket.shipped)">
{{sale.itemFk}} {{sale.itemFk}}
</span> </span>
<vn-autocomplete ng-if="!sale.id" class="dense" <vn-autocomplete ng-if="!sale.id" class="dense"