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