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,10 +20,9 @@
"type": "date"
}
},
"scope": {
"where" :{
"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 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');

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 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');

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
(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

View File

@ -98,9 +98,8 @@ module.exports = Self => {
summary.tags = res[1];
[summary.botanical] = res[2];
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
res = await models.Item.getVisibleAvailable(summary.item.id, userConfig.warehouseFk, null, 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);
summary.available = res.available;
summary.visible = res.visible;

View File

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

View File

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

View File

@ -19,7 +19,7 @@
<slot-before>
<div class="photo" text-center>
<img vn-id="photo"
ng-src="{{$root.imagePath('catalog', '200x200', $ctrl.item.id)}}"
ng-src="{{$root.imagePath('catalog', '200x200', $ctrl.item.id)}}"
zoom-image="{{$root.imagePath('catalog', '1600x900', $ctrl.item.id)}}"
on-error-src/>
<vn-float-button ng-click="uploadPhoto.show('catalog', $ctrl.item.id)"
@ -36,13 +36,23 @@
<p translate>Available</p>
<p>{{$ctrl.available | dashIfEmpty}}</p>
</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>
</slot-before>
<slot-body>
<div class="attributes">
<vn-label-value
label="Buyer">
<span
<span
ng-click="workerDescriptor.show($event, $ctrl.item.itemType.worker.userFk)"
class="link">
{{$ctrl.item.itemType.worker.user.name}}
@ -50,22 +60,22 @@
</vn-label-value>
<vn-label-value
label="{{$ctrl.item.tag5}}"
ng-if="$ctrl.item.value5"
ng-if="$ctrl.item.value5"
value="{{$ctrl.item.value5}}">
</vn-label-value>
<vn-label-value
label="{{$ctrl.item.tag6}}"
ng-if="$ctrl.item.value6"
label="{{$ctrl.item.tag6}}"
ng-if="$ctrl.item.value6"
value="{{$ctrl.item.value6}}">
</vn-label-value>
<vn-label-value
label="{{$ctrl.item.tag7}}"
ng-if="$ctrl.item.value7"
label="{{$ctrl.item.tag7}}"
ng-if="$ctrl.item.value7"
value="{{$ctrl.item.value7}}">
</vn-label-value>
<vn-label-value
label="{{$ctrl.item.tag8}}"
ng-if="$ctrl.item.value8"
label="{{$ctrl.item.tag8}}"
ng-if="$ctrl.item.value8"
value="{{$ctrl.item.value8}}">
</vn-label-value>
</div>
@ -112,7 +122,7 @@
question="Do you want to clone this item?"
message="All it's properties will be copied">
</vn-confirm>
<vn-worker-descriptor-popover
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
<vn-popup vn-id="summary">
@ -120,7 +130,7 @@
</vn-popup>
<!-- Upload photo dialog -->
<vn-upload-photo
vn-id="uploadPhoto"
<vn-upload-photo
vn-id="uploadPhoto"
on-response="$ctrl.onUploadResponse()">
</vn-upload-photo>
</vn-upload-photo>

View File

@ -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'];
@ -100,6 +119,6 @@ ngModule.vnComponent('vnItemDescriptor', {
item: '<',
dated: '<',
cardReload: '&',
warehouseFk: '<?'
warehouseFk: '<'
}
});

View File

@ -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'
}
});

View File

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

View File

@ -11,7 +11,7 @@
<vn-horizontal>
<vn-one>
<img style="width: 100%; display: block;"
ng-src="{{$root.imagePath('catalog', '200x200', $ctrl.item.id)}}"
ng-src="{{$root.imagePath('catalog', '200x200', $ctrl.item.id)}}"
zoom-image="{{$root.imagePath('catalog', '1600x900', $ctrl.item.id)}}" on-error-src/>
<vn-horizontal class="item-state">
<vn-one>
@ -22,44 +22,54 @@
<p translate>Available</p>
<p>{{$ctrl.summary.available}}</p>
</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-one>
<vn-one name="basicData">
<h4 ng-show="$ctrl.isBuyer">
<a
<a
ui-sref="item.card.basicData({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Basic data</span>
</a>
</h4>
<h4
translate
translate
ng-show="!$ctrl.isBuyer">
Basic data
</h4>
<vn-label-value label="Name"
value="{{$ctrl.summary.item.name}}">
</vn-label-value>
<vn-label-value label="Full name"
<vn-label-value label="Full name"
value="{{$ctrl.summary.item.longName}}">
</vn-label-value>
<vn-label-value label="Item family"
<vn-label-value label="Item family"
value="{{$ctrl.summary.item.itemType.name}}">
</vn-label-value>
<vn-label-value label="Size"
<vn-label-value label="Size"
value="{{$ctrl.summary.item.size}}">
</vn-label-value>
<vn-label-value label="Origin"
<vn-label-value label="Origin"
value="{{$ctrl.summary.item.origin.name}}">
</vn-label-value>
<vn-label-value label="stems"
<vn-label-value label="stems"
value="{{$ctrl.summary.item.stems}}">
</vn-label-value>
<vn-label-value label="Multiplier"
<vn-label-value label="Multiplier"
value="{{$ctrl.summary.item.stemMultiplier}}">
</vn-label-value>
<vn-label-value label="Buyer">
<span
<span
ng-click="workerDescriptor.show($event, $ctrl.summary.item.itemType.worker.userFk)"
class="link">
{{$ctrl.summary.item.itemType.worker.user.name}}
@ -68,45 +78,45 @@
</vn-one>
<vn-one name="otherData">
<h4 ng-show="$ctrl.isBuyer">
<a
<a
ui-sref="item.card.basicData({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Other data</span>
</a>
</h4>
<h4
translate
translate
ng-show="!$ctrl.isBuyer">
Other data
</h4>
<vn-label-value label="Intrastat code"
<vn-label-value label="Intrastat code"
value="{{$ctrl.summary.item.intrastat.id}}">
</vn-label-value>
<vn-label-value label="Intrastat"
<vn-label-value label="Intrastat"
value="{{$ctrl.summary.item.intrastat.description}}">
</vn-label-value>
<vn-label-value label="Reference"
<vn-label-value label="Reference"
value="{{$ctrl.summary.item.comment}}">
</vn-label-value>
<vn-label-value label="Relevancy"
<vn-label-value label="Relevancy"
value="{{$ctrl.summary.item.relevancy}}">
</vn-label-value>
<vn-label-value label="Weight/Piece"
<vn-label-value label="Weight/Piece"
value="{{$ctrl.summary.item.weightByPiece}}">
</vn-label-value>
<vn-label-value label="Expense"
<vn-label-value label="Expense"
value="{{$ctrl.summary.item.expense.name}}">
</vn-label-value>
</vn-one>
<vn-one name="tags">
<h4 ng-show="$ctrl.isBuyer || $ctrl.isReplenisher">
<a
<a
ui-sref="item.card.tags({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Tags</span>
</a>
</h4>
<h4
<h4
translate
ng-show="!$ctrl.isBuyer && !$ctrl.isReplenisher">
Tags
@ -119,14 +129,14 @@
</vn-one>
<vn-one name="description" ng-if="$ctrl.summary.item.description">
<h4 ng-show="$ctrl.isBuyer">
<a
<a
ui-sref="item.card.basicData({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Description</span>
</a>
</h4>
<h4
translate
translate
ng-show="!$ctrl.isBuyer">
Description
</h4>
@ -136,13 +146,13 @@
</vn-one>
<vn-one name="tax">
<h4 ng-show="$ctrl.isBuyer || $ctrl.isAdministrative">
<a
<a
ui-sref="item.card.tax({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Tax</span>
</a>
</h4>
<h4
<h4
translate
ng-show="!$ctrl.isBuyer && !$ctrl.isAdministrative">
Tax
@ -154,33 +164,33 @@
</vn-one>
<vn-one name="botanical">
<h4 ng-show="$ctrl.isBuyer">
<a
<a
ui-sref="item.card.botanical({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Botanical</span>
</a>
</h4>
<h4
<h4
translate
ng-show="!$ctrl.isBuyer">
Botanical
</h4>
<vn-label-value label="Genus"
<vn-label-value label="Genus"
value="{{$ctrl.summary.botanical.genus.name}}">
</vn-label-value>
<vn-label-value label="Specie"
<vn-label-value label="Specie"
value="{{$ctrl.summary.botanical.specie.name}}">
</vn-label-value>
</vn-one>
<vn-one name="barcode">
<h4 ng-show="$ctrl.isBuyer || $ctrl.isReplenisher">
<a
<a
ui-sref="item.card.itemBarcode({id:$ctrl.item.id})"
target="_self">
<span translate vn-tooltip="Go to">Barcode</span>
</a>
</h4>
<h4
<h4
translate
ng-show="!$ctrl.isBuyer && !$ctrl.isReplenisher">
Barcode
@ -191,6 +201,6 @@
</vn-one>
</vn-horizontal>
</vn-card>
<vn-worker-descriptor-popover
<vn-worker-descriptor-popover
vn-id="workerDescriptor">
</vn-worker-descriptor-popover>
</vn-worker-descriptor-popover>

View File

@ -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 => {
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() {
@ -37,4 +55,7 @@ ngModule.vnComponent('vnItemSummary', {
bindings: {
item: '<',
},
require: {
card: '?^vnItemCard'
}
});

View File

@ -14,12 +14,15 @@ describe('Item', () => {
const $element = angular.element('<vn-item-summary></vn-item-summary>');
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();

View File

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

View File

@ -1,3 +1,4 @@
Barcode: Códigos de barras
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

@ -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;
}
}
}
}

View File

@ -131,7 +131,7 @@
</vn-td>
<vn-td>
<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}}
</span>
<vn-autocomplete ng-if="!sale.id" class="dense"