2018-02-23 12:04:44 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
export default class Controller {
|
|
|
|
constructor($stateParams, $http) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.$stateParams = $stateParams;
|
|
|
|
|
|
|
|
let filter = {
|
|
|
|
fields: ['id', 'countryFk', 'taxClassFk'],
|
|
|
|
include: [{
|
|
|
|
relation: 'country',
|
|
|
|
scope: {fields: ['country']}
|
2018-02-26 11:56:42 +00:00
|
|
|
}, {
|
|
|
|
relation: 'taxClass',
|
|
|
|
scope: {fields: ['id', 'description']}
|
2018-02-23 12:04:44 +00:00
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
let urlFilter = encodeURIComponent(JSON.stringify(filter));
|
|
|
|
let url = `/item/api/Items/${$stateParams.id}/taxes?filter=${urlFilter}`;
|
|
|
|
$http.get(url).then(json => {
|
|
|
|
this.taxes = json.data;
|
|
|
|
});
|
|
|
|
|
|
|
|
$http.get(`/item/api/TaxClasses`).then(json => {
|
|
|
|
this.classes = json.data;
|
|
|
|
});
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-02-23 12:04:44 +00:00
|
|
|
submit() {
|
|
|
|
let data = [];
|
|
|
|
for (let tax of this.taxes)
|
|
|
|
data.push({id: tax.id, taxClassFk: tax.taxClassFk});
|
|
|
|
|
|
|
|
let url = `/item/api/Items/${this.$stateParams.id}/updateTaxes`;
|
|
|
|
this.$http.post(url, data);
|
|
|
|
}
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-02-23 12:04:44 +00:00
|
|
|
Controller.$inject = ['$stateParams', '$http'];
|
|
|
|
|
|
|
|
ngModule.component('vnItemTax', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-02-23 12:04:44 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
item: '<'
|
|
|
|
}
|
|
|
|
});
|