2018-04-13 14:03:43 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import './style.scss';
|
2018-05-10 11:36:26 +00:00
|
|
|
|
2018-08-31 05:53:38 +00:00
|
|
|
class Controller {
|
|
|
|
constructor($scope, $stateParams) {
|
|
|
|
this.$stateParams = $stateParams;
|
2018-05-10 11:36:26 +00:00
|
|
|
this.$scope = $scope;
|
2018-08-31 05:53:38 +00:00
|
|
|
this.filter = {
|
|
|
|
order: 'concept ASC',
|
|
|
|
include: [{
|
|
|
|
relation: 'item',
|
|
|
|
scope: {
|
|
|
|
include: {
|
|
|
|
relation: 'tags',
|
|
|
|
scope: {
|
|
|
|
fields: ['tagFk', 'value'],
|
|
|
|
include: {
|
|
|
|
relation: 'tag',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
limit: 6
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fields: ['itemFk', 'name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'components',
|
|
|
|
scope: {
|
|
|
|
fields: ['componentFk', 'value'],
|
|
|
|
include: {
|
|
|
|
relation: 'componentRate',
|
|
|
|
scope: {
|
|
|
|
fields: ['componentTypeRate', 'name'],
|
|
|
|
include: {
|
|
|
|
relation: 'componentType',
|
|
|
|
scope: {
|
|
|
|
fields: ['type']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
};
|
2018-05-10 11:36:26 +00:00
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
|
|
|
|
total() {
|
2018-08-31 05:53:38 +00:00
|
|
|
let sales = this.$scope.model.data;
|
|
|
|
let sum = 0;
|
|
|
|
if (!sales) return;
|
|
|
|
|
|
|
|
for (let sale of sales)
|
|
|
|
for (let component of sale.components)
|
|
|
|
sum += sale.quantity * component.value;
|
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
return sum;
|
|
|
|
}
|
2018-08-01 07:47:34 +00:00
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
base() {
|
2018-08-31 05:53:38 +00:00
|
|
|
let sales = this.$scope.model.data;
|
|
|
|
let sum = 0;
|
|
|
|
|
|
|
|
if (!sales) return;
|
|
|
|
|
|
|
|
for (let sale of sales)
|
|
|
|
for (let component of sale.components)
|
|
|
|
if (component.componentRate.name == 'valor de compra')
|
|
|
|
sum += sale.quantity * component.value;
|
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
return sum;
|
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
profitMargin() {
|
2018-08-31 05:53:38 +00:00
|
|
|
let sales = this.$scope.model.data;
|
|
|
|
let sum = 0;
|
|
|
|
|
|
|
|
if (!sales) return;
|
|
|
|
|
|
|
|
for (let sale of sales)
|
|
|
|
for (let component of sale.components)
|
|
|
|
if (component.componentRate.name != 'valor de compra')
|
|
|
|
sum += sale.quantity * component.value;
|
|
|
|
|
2018-04-13 14:03:43 +00:00
|
|
|
return sum;
|
|
|
|
}
|
2018-05-29 12:33:29 +00:00
|
|
|
|
|
|
|
showDescriptor(event, itemFk) {
|
2018-09-04 09:49:00 +00:00
|
|
|
this.quicklinks = {
|
|
|
|
btnThree: {
|
|
|
|
icon: 'icon-transaction',
|
|
|
|
state: `item.card.diary({
|
|
|
|
id: ${itemFk},
|
|
|
|
q: '{"warehouseFk": ${this.ticket.warehouseFk}}'
|
|
|
|
})`,
|
|
|
|
tooltip: 'Item diary'
|
|
|
|
}
|
|
|
|
};
|
2018-05-29 12:33:29 +00:00
|
|
|
this.$scope.descriptor.itemFk = itemFk;
|
|
|
|
this.$scope.descriptor.parent = event.target;
|
|
|
|
this.$scope.descriptor.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
onDescriptorLoad() {
|
|
|
|
this.$scope.popover.relocate();
|
|
|
|
}
|
2018-04-13 14:03:43 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 05:53:38 +00:00
|
|
|
Controller.$inject = ['$scope', '$stateParams'];
|
2018-05-10 11:36:26 +00:00
|
|
|
|
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: '<'
|
|
|
|
}
|
|
|
|
});
|