<template> <div> <table class="table is-fullwidth is-striped is-bordered"> <thead> <tr> <th>Núcleo</th> <th v-if="$root.devoluciones"><abbr title="Total sin tomar en cuenta las devoluciones">Total parcial $</abbr></th> <th v-if="$root.devoluciones"><abbr title="Devoluciones correspondientes al núcleo">Devoluciones $</abbr></th> <th><abbr title="Total a Pagar por el núleo">{{ $root.devoluciones ? 'Total real' : 'Total' }} $</abbr></th> <th class="is-1"><abbr title="Pagado">Pagado</abbr></th> </tr> </thead> <tbody> <pedidos-admin-fila-pedido v-for="pedido in this.pedidos" :pedido="pedido" :key="pedido.id"> </pedidos-admin-fila-pedido> </tbody> </table> <table class="table is-striped is-bordered"> <tr> <th colspan="2" class="has-background-black has-text-white has-text-centered">TOTALES</th> </tr> <tr> <th>Total a recaudar:</th> <td class="has-text-right">$ {{ totalARecaudar }}</td> </tr> <tr> <th>Total bonos barriales:</th> <td class="has-text-right">$ {{ $parent.totalBonosBarriales }}</td> </tr> <tr v-if="$root.devoluciones"> <th>Total devoluciones:</th> <td class="has-text-right">- $ {{ totalDevoluciones() }}</td> </tr> <tr> <th>Total bonos de transporte:</th> <td class="has-text-right">$ {{ bonosDeTransporte * 15 }}</td> </tr> <tr> <th>Total a depositar:</th> <td class="has-text-right">$ {{ totalAprobadosConTransporteRecalculado() - totalBonosBarriales }}</td> </tr> </table> </div> </template> <script> import PedidosAdminFilaPedidoVue from './PedidosAdminFilaPedido.vue'; export default { name: "PedidosAdminTablaPedidos", components: { PedidosAdminFilaPedidoVue }, props: { pedidos: { type: Array, required: true }, bonosDeTransporte: { type: Number, required: true }, totalBonosBarriales: { type: Number, required: true }, }, computed: { totalARecaudar: function() { return this.$root.devoluciones ? this.totalAprobadosMenosDevoluciones() : this.totalAprobados(); }, }, methods: { totalDevoluciones() { let suma = 0 let aprobados = this.pedidos.filter(p => p.aprobado); for (let i = 0; i < aprobados.length; i++) { suma += aprobados[i].devoluciones_total } return suma; }, totalAprobados() { let suma = 0 let aprobados = this.pedidos.filter(p => p.aprobado); for (let i = 0; i < aprobados.length; i++) { suma += this.$limpiarFloat(aprobados[i].total) } return suma; }, totalAprobadosMenosDevoluciones() { let suma = 0 let aprobados = this.pedidos.filter(p => p.aprobado); for (let i = 0; i < aprobados.length; i++) { suma += this.$limpiarFloat(aprobados[i].total_menos_devoluciones) } return suma; }, totalAprobadosConTransporteRecalculado() { let suma = 0 let aprobados = this.pedidos.filter(p => p.aprobado); for (let i = 0; i < aprobados.length; i++) { suma += this.$limpiarFloat(aprobados[i].total) suma -= this.$limpiarFloat(aprobados[i].subtotal_bonos_de_transporte) } suma += parseInt(this.bonosDeTransporte)*15 return suma; } }, } </script> <style> </style>