2018-04-18 07:47:05 +00:00
|
|
|
import ngModule from '../../module';
|
|
|
|
|
|
|
|
class Controller {
|
2018-05-16 06:13:39 +00:00
|
|
|
constructor($http) {
|
2018-04-18 07:47:05 +00:00
|
|
|
this.$http = $http;
|
|
|
|
}
|
|
|
|
|
2018-05-16 06:13:39 +00:00
|
|
|
$onInit() {
|
|
|
|
this.data.registerChild(this);
|
2019-01-25 11:52:12 +00:00
|
|
|
this.getTotalPrice();
|
|
|
|
this.getTotalNewPrice();
|
|
|
|
this.getTotalDifferenceOfPrice();
|
2018-05-16 06:13:39 +00:00
|
|
|
}
|
2018-04-18 07:47:05 +00:00
|
|
|
|
2018-05-16 06:13:39 +00:00
|
|
|
onStepChange(state) {
|
|
|
|
return true;
|
2018-04-18 07:47:05 +00:00
|
|
|
}
|
2019-01-25 11:52:12 +00:00
|
|
|
|
|
|
|
getTotalPrice() {
|
|
|
|
let totalPrice = 0;
|
|
|
|
this.ticket.sale.items.forEach(item => {
|
|
|
|
let itemTotalPrice = item.quantity * item.price;
|
|
|
|
totalPrice += itemTotalPrice;
|
|
|
|
});
|
|
|
|
this.totalPrice = totalPrice;
|
|
|
|
}
|
|
|
|
|
|
|
|
getTotalNewPrice() {
|
|
|
|
let totalNewPrice = 0;
|
|
|
|
this.ticket.sale.items.forEach(item => {
|
|
|
|
let itemTotalNewPrice = item.quantity * item.component.newPrice;
|
|
|
|
totalNewPrice += itemTotalNewPrice;
|
|
|
|
});
|
|
|
|
this.totalNewPrice = totalNewPrice;
|
|
|
|
}
|
|
|
|
|
|
|
|
getTotalDifferenceOfPrice() {
|
|
|
|
let totalPriceDifference = 0;
|
|
|
|
this.ticket.sale.items.forEach(item => {
|
2019-05-09 07:32:04 +00:00
|
|
|
totalPriceDifference += item.component.difference;
|
2019-01-25 11:52:12 +00:00
|
|
|
});
|
|
|
|
this.totalPriceDifference = totalPriceDifference;
|
|
|
|
}
|
2018-04-18 07:47:05 +00:00
|
|
|
}
|
|
|
|
|
2018-05-16 06:13:39 +00:00
|
|
|
Controller.$inject = ['$http'];
|
2018-04-18 07:47:05 +00:00
|
|
|
|
2019-04-16 13:00:21 +00:00
|
|
|
ngModule.component('vnTicketBasicDataStepTwo', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-04-18 07:47:05 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
ticket: '<'
|
2018-05-16 06:13:39 +00:00
|
|
|
},
|
|
|
|
require: {
|
2019-04-16 13:00:21 +00:00
|
|
|
data: '^vnTicketBasicData'
|
2018-04-18 07:47:05 +00:00
|
|
|
}
|
|
|
|
});
|