From 8fb810c73f427349df30dc43c8f9ea89fe36a83b Mon Sep 17 00:00:00 2001 From: ale Date: Fri, 20 Jun 2025 17:03:35 -0300 Subject: [PATCH] =?UTF-8?q?Omitiendo=20pedido=20de=20ollas=20de=20m=C3=A9t?= =?UTF-8?q?odos=20que=20trabajan=20con=20pedidos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/GrupoDeCompra.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/GrupoDeCompra.php b/app/GrupoDeCompra.php index 273237d..3395925 100644 --- a/app/GrupoDeCompra.php +++ b/app/GrupoDeCompra.php @@ -12,6 +12,7 @@ use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use League\Csv\Exception; +use Mpdf\MpdfException; class GrupoDeCompra extends Model { @@ -37,7 +38,14 @@ class GrupoDeCompra extends Model public function pedidosAprobados() { - return $this->subpedidos->where('aprobado', 1); + return $this->pedidosHogares() + ->where('aprobado', 1); + } + + public function pedidosHogares() + { + return $this->subpedidos + ->where('tipo_pedido_id', '=', 1); } public function totalARecaudar() @@ -120,11 +128,15 @@ class GrupoDeCompra extends Model return TransporteHelper::cantidadTransporte($this->totalCentralesQuePaganTransporte()); } + /** + * @throws MpdfException + */ public function exportarPedidosAPdf() { $subpedidos = $this->pedidosAprobados(); $fecha = now()->format('Y-m-d'); - PdfHelper::exportarPedidos($this->nombre . '-' . $fecha . '.pdf', $subpedidos); + $filepath = $this->nombre . '-' . $fecha . '.pdf'; + PdfHelper::exportarPedidos($filepath, $subpedidos); } function pedidoParaPdf(): array @@ -154,11 +166,15 @@ class GrupoDeCompra extends Model return $view->render(); } + /** + * @throws MpdfException + */ public static function exportarPedidosBarrialesAPdf() { $barrios = GrupoDeCompra::barriosMenosPrueba()->get(); $fecha = now()->format('Y-m-d'); - PdfHelper::exportarPedidos('pedidos_por_barrio-' . $fecha . '.pdf', $barrios); + $filepath = 'pedidos_por_barrio-' . $fecha . '.pdf'; + PdfHelper::exportarPedidos($filepath, $barrios); } static function filaVacia(string $product, int $columns): array