update getComponentSum

This commit is contained in:
Bernat Exposito Domenech 2020-09-08 07:17:16 +02:00
parent 0d689a8c01
commit 92e14d5292
5 changed files with 43 additions and 15 deletions

View File

@ -1,6 +1,7 @@
@import "variables";
.vn-radio {
& > .btn {
border-radius: 50%;
@ -25,4 +26,8 @@
&.disabled.checked > .btn > .mark {
background-color: $color-font-secondary;
}
> div {
text-overflow: ellipsis;
overflow: hidden;
}
}

View File

@ -2,6 +2,6 @@
<div class="focus-mark"></div>
<div class="mark"></div>
</div>
<span translate>
<div translate>
{{::$ctrl.label}}
</span>
</div>

View File

@ -18,15 +18,35 @@ module.exports = Self => {
verb: 'GET'
}
});
Self.getComponentsSum = async id => {
const models = Self.app.models;
let sales = await models.Sale.find({where: {ticketFk: id}});
let salesComponents;
let components = await models.Component.find();
let salesComponents = [];
let componentsSum = [];
for (let sale of sales) {
salesComponents = await models.SaleComponent.find({saleFk: sale.id});
console.log('salesComponents', salesComponents);
let myComponents = await models.SaleComponent.find({where: {saleFk: sale.id}});
salesComponents = salesComponents.concat(myComponents);
}
return true;
salesComponents.reduce((acumulator, currentValue) => {
if (!acumulator[currentValue.componentFk]) {
let defaultValue = 0;
let tarjetComponent = components.find(component => component.id === currentValue.componentFk);
acumulator[currentValue.componentFk] = {
componentFk: currentValue.componentFk,
value: defaultValue,
name: tarjetComponent.name
};
componentsSum.push(acumulator[currentValue.componentFk]);
}
acumulator[currentValue.componentFk].value += currentValue.value;
return acumulator;
});
return componentsSum;
};
};

View File

@ -65,17 +65,19 @@
<div class="totalBox" style="text-align: left;">
<h6 style="text-align: center;" translate>Total</h6>
<div> <vn-label translate>Base to commission</vn-label> {{$ctrl.base() | currency: 'EUR':3}} </div>
<div> <vn-label translate>Total</vn-label> {{$ctrl.getTotal() | currency: 'EUR': 2}} </div>
<div> <vn-label translate>Base to commission</vn-label> {{$ctrl.base() | currency: 'EUR':2}} </div>
<div> <vn-label translate>Total without VAT</vn-label> {{$ctrl.getTotal() | currency: 'EUR': 3}} </div>
</div>
<div class="totalBox" style="text-align: left;">
<h6 style="text-align: center;" translate>Total</h6>
<div> <vn-label translate>Price</vn-label> {{$ctrl.totalPrice | currency: 'EUR': 2}} </div>
<div> <vn-label translate>New price</vn-label> {{$ctrl.totalNewPrice | currency: 'EUR': 2}} </div>
<div> <vn-label translate>Difference</vn-label> {{$ctrl.totalPriceDifference | currency: 'EUR': 2}} </div>
<h6 style="text-align: center;" translate>Components</h6>
<section ng-repeat="component in $ctrl.componentsList">
<div>
<vn-label>{{component.name}}</vn-label> {{component.value | currency: 'EUR': 3}}
</div>
</section>
</div>
<div class="totalBox" style="text-align: left;">
<h6 style="text-align: center;" translate>Theorical ports</h6>
<h6 style="text-align: center;" translate>Theorical port</h6>
<div> <vn-label translate>Price</vn-label> {{$ctrl.theoricalPorts | currency: 'EUR': 2}} </div>
</div>

View File

@ -1 +1,2 @@
Theorical ports: Portes teóricos
Theorical port: Porte teorico
Total without VAT: Total sin IVA