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-11-14 13:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get ticket() {
|
|
|
|
return this._ticket;
|
|
|
|
}
|
|
|
|
|
|
|
|
set ticket(value) {
|
|
|
|
this._ticket = value;
|
|
|
|
|
|
|
|
if (!value) return;
|
|
|
|
|
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 => {
|
2019-09-02 12:36:54 +00:00
|
|
|
if (item.component)
|
|
|
|
totalNewPrice += item.quantity * item.component.newPrice;
|
2019-01-25 11:52:12 +00:00
|
|
|
});
|
|
|
|
this.totalNewPrice = totalNewPrice;
|
|
|
|
}
|
|
|
|
|
|
|
|
getTotalDifferenceOfPrice() {
|
|
|
|
let totalPriceDifference = 0;
|
|
|
|
this.ticket.sale.items.forEach(item => {
|
2019-09-02 12:36:54 +00:00
|
|
|
if (item.component)
|
|
|
|
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
|
|
|
}
|
|
|
|
});
|