suma os dias a la cuenta
This commit is contained in:
@@ -265,22 +265,33 @@ class ShowClientes extends Component
|
||||
|
||||
public function renovar($id)
|
||||
{
|
||||
$historiale = Historiale::with('tarifa')->find($id);
|
||||
|
||||
$historiale = Historiale::with('tarifa','cuentas')->find($id);
|
||||
|
||||
if (!$historiale) {
|
||||
return;
|
||||
}
|
||||
|
||||
$newFechaInicio = Carbon::parse($historiale->fecha_inicio)->addDays($historiale->tarifa->dias);
|
||||
$newFechaFinal = Carbon::parse($historiale->fecha_final)->addDays($historiale->tarifa->dias);
|
||||
$tarifa = $historiale->tarifa;
|
||||
$diasTarifa = $tarifa->dias;
|
||||
$valorTarifa = $tarifa->valor;
|
||||
|
||||
$cuenta = $historiale->cuentas->first();
|
||||
$vencimientoCuenta = Carbon::parse($cuenta->vencimiento);
|
||||
$nuevaFechaVencimiento = $vencimientoCuenta->addDays($diasTarifa);
|
||||
|
||||
$newFechaInicio = Carbon::parse($historiale->fecha_inicio)->addDays($diasTarifa);
|
||||
$newFechaFinal = Carbon::parse($historiale->fecha_final)->addDays($diasTarifa);
|
||||
|
||||
$historiale->fecha_inicio = $newFechaInicio;
|
||||
$historiale->fecha_final = $newFechaFinal;
|
||||
$historiale->save();
|
||||
$nuevoHistorial = $historiale->replicate();
|
||||
$nuevoHistorial->fecha_inicio = $newFechaInicio;
|
||||
$nuevoHistorial->fecha_final = $newFechaFinal;
|
||||
$nuevoHistorial->save();
|
||||
|
||||
$cuenta->vencimiento = $nuevaFechaVencimiento;
|
||||
$cuenta->save();
|
||||
|
||||
$user = Auth::user();
|
||||
$user->saldo->valor -= $historiale->tarifa->valor;
|
||||
$user->saldo->valor -= $valorTarifa;
|
||||
$user->saldo->save();
|
||||
|
||||
$this->alert('success', 'Registro renovado con éxito. Nuevas fechas aplicadas.', [
|
||||
|
||||
@@ -126,8 +126,6 @@
|
||||
</td>
|
||||
@endif
|
||||
|
||||
{{$cliente->tarifa->valor}}
|
||||
|
||||
@if (!empty($cliente->tarifa_id))
|
||||
<td class=" w-[1rem]">
|
||||
<button
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
{{-- tabla --}}
|
||||
<div class="overflow-y-auto max-h-full">
|
||||
<table class="w-full sm-w-[20rem] text-center mt-4 border-separate border-spacing-y-2">
|
||||
<table wire:loading.class="opacity-50 cursor-wait" class="w-full sm-w-[20rem] text-center mt-4 border-separate border-spacing-y-2">
|
||||
<thead class="font-normal bg-[#000029] text-white h-9">
|
||||
<tr class="text-left">
|
||||
<th class="rounded-l-lg font-normal pl-[2rem]"></th>
|
||||
|
||||
Reference in New Issue
Block a user