Good morning.
I have created a table with data whose last column is summed with the totalizeSell method and is shown at the bottom of the table. When applying a filter (using a computed Filtered Sales ) to this table, I would like this total at the bottom of the table to be updated (once it is filtered, the totalizarVenta method is automatically called and add only the rows that were left after applying the filter) and add only the content of the filtered table, the problem I have is that I always get the same total. I need your help please, thank you.
<tr>
....
<td><input type="text" v-model='filtroNombre' class="form-control"></td>
....
</tr>
<tr v-for="(item,index) in ventasFiltradas">
....
<td class="text-right">@{{ subtotal }}</td>
</tr>
<tr>
....
<td class="text-right">@{{ ventasTotales.toFixed(2) }}</td>
</tr>
var app = new Vue({
....,
computed: {
ventasFiltradas: function() {
return this.ventas.filter((venta) => venta.nombres.toLowerCase().includes(this.filtroNombre.toLowerCase()));
},
ventasTotales: function() {
return this.ventas.reduce((total, item) => {
return total + parseFloat(item.subtotal);
}, 0);
},
prendasTotales: function() {
return this.ventas.reduce((total, item) => {
return total + parseInt(item.prendas);
}, 0);
}
....,
Thank you.