import ngModule from '../module'; import './style.scss'; 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'); } 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; } 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; } 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; } showDescriptor(event, itemFk) { this.$scope.descriptor.itemFk = itemFk; this.$scope.descriptor.parent = event.target; this.$scope.descriptor.show(); } onDescriptorLoad() { this.$scope.popover.relocate(); } } Controller.$inject = ['$scope', '$timeout', '$state']; ngModule.component('vnTicketComponents', { template: require('./index.html'), controller: Controller, bindings: { ticket: '<' } });