2018-04-13 14:03:43 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import './style.scss';
|
2018-05-10 11:36:26 +00:00
|
|
|
import FilterTicketList from '../filter-ticket-list';
|
|
|
|
|
|
|
|
class Controller extends FilterTicketList {
|
|
|
|
constructor($scope, $timeout, $stateParams) {
|
|
|
|
super($scope, $timeout, $stateParams);
|
|
|
|
this.$scope = $scope;
|
|
|
|
this.onOrder('itemFk', 'ASC');
|
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
|
|
|
|
total() {
|
|
|
|
let sum;
|
|
|
|
if (this.sales) {
|
|
|
|
sum = 0;
|
|
|
|
for (let sale of this.sales)
|
|
|
|
for (let component of sale.components)
|
|
|
|
sum += sale.quantity * component.value;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
base() {
|
|
|
|
let sum;
|
|
|
|
if (this.sales) {
|
|
|
|
sum = 0;
|
|
|
|
for (let sale of this.sales)
|
|
|
|
for (let component of sale.components)
|
|
|
|
if (component.componentRate.name == 'valor de compra')
|
|
|
|
sum += sale.quantity * component.value;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
profitMargin() {
|
|
|
|
let sum;
|
|
|
|
if (this.sales) {
|
|
|
|
sum = 0;
|
|
|
|
for (let sale of this.sales)
|
|
|
|
for (let component of sale.components)
|
|
|
|
if (component.componentRate.name != 'valor de compra')
|
|
|
|
sum += sale.quantity * component.value;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-10 11:36:26 +00:00
|
|
|
Controller.$inject = ['$scope', '$timeout', '$state'];
|
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
ngModule.component('vnTicketComponents', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-04-13 14:03:43 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
ticket: '<'
|
|
|
|
}
|
|
|
|
});
|