Update ShowServicios.php

This commit is contained in:
lizandrogd
2024-05-13 11:17:59 -05:00
parent cef1e3be2b
commit cbe662fece
+11 -7
View File
@@ -177,23 +177,27 @@ class ShowServicios extends Component
->whereDate('vencimiento', '<=', $this->fecha_final_2)
->where('servicio_id', $servicio_tarifa->id)
->where('estado', 'activo')
->with('perfil')
->whereDoesntHave('perfil', function ($query) use ($cantidad_restante) {
$query->select('cuenta_id')
->groupBy('cuenta_id')
->havingRaw("COUNT(*) >= $cantidad_restante");
})
//->with('perfil')
//->whereDoesntHave('perfil', function ($query) use ($cantidad_restante) {
// $query->select('cuenta_id')
// ->groupBy('cuenta_id')
// ->havingRaw("COUNT(*) >= $cantidad_restante");
//})
->withCount('historiales')
->where('estado', 'activo')
->having('historiales_count', '<=', $cantidad_restante)
->get();
//dd($cuentas_pantallas);
$cuentas_pantallas_tomadas = Historial_cuenta::whereIn('cuenta_id', $cuentas_pantallas
->pluck('id'))
->count();
//dd($cuentas_pantallas_tomadas);
//Validar si el numero pantallas del servicio es igual o mayor que lo solicitado
if ($servicio_tarifa->pantallas >= $cantidad_solicitada) {
//Cantidad de cuentas restantes * cantidad de pantallas del servicio / en las pantalla de la tarifa.
$this->disponibles = (($cuentas_pantallas->count() * $servicio_tarifa->pantallas) - $cuentas_pantallas_tomadas) / $tarifa_seleccionada->pantallas;
//dd($this->disponibles) ;
} else {
$this->disponibles = $cuentas_pantallas;
}