getAvailable aislado
This commit is contained in:
parent
58706b8694
commit
a3e69d604a
|
@ -60,16 +60,6 @@ module.exports = Self => {
|
|||
};
|
||||
[item] = await Self.app.models.Item.find(filter);
|
||||
|
||||
// Visible Available
|
||||
let query = `
|
||||
CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`;
|
||||
|
||||
let options = [item.id, item.itemType().warehouseFk, false];
|
||||
let [res] = await Self.rawSql(query, options);
|
||||
|
||||
item.available = res[0].available;
|
||||
item.visible = res[0].visible;
|
||||
|
||||
return item;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ module.exports = Self => {
|
|||
accessType: '',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'itemFk',
|
||||
arg: 'id',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
},
|
||||
|
@ -18,21 +18,20 @@ module.exports = Self => {
|
|||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getVisibleAvailable`,
|
||||
path: `/:id/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;
|
||||
return {
|
||||
available: res[0].available,
|
||||
visible: res[0].visible};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="item/api/Items/getVisibleAvailable"
|
||||
filter="$ctrl.params"
|
||||
data="$ctrl.item.available"
|
||||
on-data-change="$ctrl.calculateTotals()">
|
||||
</vn-crud-model>
|
||||
<div class="vn-descriptor">
|
||||
<div class="header">
|
||||
<a translate-attr="{title: 'Return to module index'}" ui-sref="item.index">
|
||||
|
@ -41,11 +34,11 @@
|
|||
<vn-horizontal class="item-state">
|
||||
<vn-one>
|
||||
<p translate>Visible</p>
|
||||
<p>{{$ctrl.item.visible}}</p>
|
||||
<p>{{$ctrl.visible | dashIfEmpty}}</p>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<p translate>Available</p>
|
||||
<p>{{$ctrl.item.available}}</p>
|
||||
<p>{{$ctrl.available | dashIfEmpty}}</p>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import ngModule from '../module';
|
||||
import './style.scss';
|
||||
import {runInThisContext} from 'vm';
|
||||
|
||||
class Controller {
|
||||
constructor($state, $scope, $http, vnApp, $translate) {
|
||||
|
@ -34,23 +35,29 @@ class Controller {
|
|||
|
||||
set item(value) {
|
||||
this._item = value;
|
||||
this.available = null;
|
||||
this.visible = null;
|
||||
if (!this.item) {
|
||||
this.params = {
|
||||
params: {
|
||||
itemFk: this.item,
|
||||
warehouseFk: this._warehouseFk
|
||||
}
|
||||
};
|
||||
}
|
||||
return this._item;
|
||||
this.updateStock();
|
||||
}
|
||||
|
||||
get item() {
|
||||
return this._item;
|
||||
}
|
||||
|
||||
updateStock() {
|
||||
this.available = null;
|
||||
this.visible = null;
|
||||
if (this._item && this._item.id) {
|
||||
let options = {
|
||||
params: {
|
||||
warehouseFk: this._warehouseFk
|
||||
}
|
||||
};
|
||||
this.$http.get(`/item/api/Items/${this._item.id}/getVisibleAvailable`, options).then(response => {
|
||||
this.available = response.data.available;
|
||||
this.visible = response.data.visible;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onMoreChange(callback) {
|
||||
callback.call(this);
|
||||
}
|
||||
|
@ -75,7 +82,7 @@ class Controller {
|
|||
warehouseFk: this.warehouseFk
|
||||
}).then(res => {
|
||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||
this.card.reload();
|
||||
this.updateStock();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue