diff --git a/app/GrupoDeCompra.php b/app/GrupoDeCompra.php index cf13e65..09ec62b 100644 --- a/app/GrupoDeCompra.php +++ b/app/GrupoDeCompra.php @@ -89,6 +89,21 @@ class GrupoDeCompra extends Model return ceil($this->totalPedidosSinBonos() / 500); } + public function totalBonosBarriales() { + $total = 0; + $bonoBarrial = Producto::where('nombre','LIKE','%barrial%')->first(); + if ($bonoBarrial) { + $pedidos = $this->pedidosAprobados(); + foreach ($pedidos as $pedido) { + $bonoPedido = $pedido->productos()->find($bonoBarrial["id"]); + if ($bonoPedido) { + $total += $bonoPedido["pivot"]["total"]; + } + } + } + return $total; + } + public function exportarPedidoEnCSV(){ $productos_en_pedido = DB::table('pedidos_aprobados')->where('grupo_de_compra_id',$this->id)->get()->keyBy('producto_id'); diff --git a/resources/js/components/PedidosAdminBody.vue b/resources/js/components/PedidosAdminBody.vue index ff5d559..68b617d 100644 --- a/resources/js/components/PedidosAdminBody.vue +++ b/resources/js/components/PedidosAdminBody.vue @@ -1,21 +1,21 @@