Agregado total devoluciones y devoluciones habilitadas a resource + metodo para total devoluciones

This commit is contained in:
Alejandro Tasistro 2025-03-18 19:34:02 -03:00
parent c46073ed06
commit 2ca91addb0
2 changed files with 12 additions and 1 deletions

View file

@ -52,6 +52,15 @@ class GrupoDeCompra extends Model
return $total; return $total;
} }
public function totalDevoluciones()
{
$total = 0;
foreach ($this->pedidosAprobados() as $subpedido) {
$total = $total + $subpedido->devoluciones_total;
}
return $total;
}
public function totalATransferir() public function totalATransferir()
{ {
return $this->totalCentralesQueNoPaganTransporte() return $this->totalCentralesQueNoPaganTransporte()

View file

@ -17,9 +17,11 @@ class GrupoDeCompraResource extends JsonResource
return [ return [
'id' => $this->id, 'id' => $this->id,
'nombre' => $this->nombre, 'nombre' => $this->nombre,
'pedidos' => $this->subpedidos, 'devoluciones_habilitadas' => $this->devoluciones_habilitadas,
'pedidos' => SubpedidoResource::collection($this->subpedidos),
'total_a_recaudar' => $this->totalARecaudar(), 'total_a_recaudar' => $this->totalARecaudar(),
'total_barrial' => $this->totalBarrial(), 'total_barrial' => $this->totalBarrial(),
'total_devoluciones' => $this->totalDevoluciones(),
'total_a_transferir' => $this->totalATransferir(), 'total_a_transferir' => $this->totalATransferir(),
'total_transporte' => $this->totalTransporte(), 'total_transporte' => $this->totalTransporte(),
'cantidad_transporte' => number_format($this->cantidadTransporte(),0), 'cantidad_transporte' => number_format($this->cantidadTransporte(),0),