salix/modules/ticket/front/component/index.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
2020-03-18 07:35:59 +00:00
import Section from 'salix/components/section';
import './style.scss';
2020-03-18 07:35:59 +00:00
class Controller extends Section {
constructor($element, $) {
super($element, $);
this.filter = {
order: 'concept ASC',
include: [{
relation: 'item',
}, {
relation: 'components',
scope: {
fields: ['componentFk', 'value'],
include: {
relation: 'component',
scope: {
fields: ['typeFk', 'name'],
include: {
relation: 'componentType',
scope: {
fields: ['type', 'isBase']
}
}
}
}
}
}]
};
}
base() {
2020-03-18 07:35:59 +00:00
let sales = this.$.model.data;
let sum = 0;
if (!sales) return;
2018-11-06 09:49:38 +00:00
for (let sale of sales) {
for (let saleComponent of sale.components) {
if (saleComponent.component.componentType.isBase)
sum += sale.quantity * saleComponent.value;
2018-11-06 09:49:38 +00:00
}
}
return sum;
}
}
ngModule.component('vnTicketComponents', {
template: require('./index.html'),
controller: Controller,
bindings: {
ticket: '<'
}
});