suma os dias a la cuenta

This commit is contained in:
Felipe
2023-07-27 11:35:46 -05:00
parent 305924b6ca
commit c35847f86c
3 changed files with 20 additions and 11 deletions
+19 -8
View File
@@ -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>