Se reparo error en el buscador

This commit is contained in:
Guillermo Gutierrez
2023-08-18 09:21:26 -07:00
parent 0946d9e951
commit c74c21a34a
7 changed files with 45 additions and 6 deletions

View File

@@ -5,9 +5,12 @@ namespace App\Http\Livewire;
use App\Models\Movimiento;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Livewire\WithPagination;
class CancelacionController extends Component
{
use WithPagination;
const CODIGO_CANCELACION = 3;
public $buscador = '' , $modal = false;

View File

@@ -60,6 +60,8 @@ class VentaController extends Component
public function updated()
{
if(!$this->modal)
return;
if($this->venta->cambio()>0)
{
$this->cambio = $this->venta->cambio();
@@ -83,6 +85,12 @@ class VentaController extends Component
'venta.estado_movimiento_id' => 'numeric',
]);
if($this->venta->isTotalMayorCambio())
{
session()->flash("error","Pago diferente al efectivo no pueden superar el total de venta.");
return;
}
$this->venta->ajusteCambio();
$this->venta->user_id = Auth::user()->id;

View File

@@ -129,10 +129,14 @@ class VentaEspecialController extends Component
]);
if(($this->calcularTotalPagar($this->ventaEspecial) - $this->ventaAnterior->totalAbono()) >0){
// session()->flash("message_abono",($this->calcularTotalPagar($this->ventaEspecial) - $this->ventaAnterior->totalAbono()));
session()->flash("message_abono","Debes liquidar la deuda para cerrarla.");
return;
}
if($this->ventaEspecial->isTotalMayorCambio())
{
session()->flash("error","Pago diferente al efectivo no pueden superar el total de venta.");
return;
}
$this->ventaAnterior->is_liquidado = true;
$this->ventaAnterior->save();

View File

@@ -65,9 +65,20 @@ class Movimiento extends Model
public function ajusteCambio()
{
if(((float)$this->pago_efectivo) - $this->cambio()>0)
if(((float)$this->pago_efectivo) - $this->cambio()>=0)
{
$this->pago_efectivo-= $this->cambio();
}
}
/**
* Create a new Eloquent model instance.
*
* @return void
*/
public function isTotalMayorCambio() : bool
{
return ($this->pago_tarjeta + $this->pago_vales + $this->pago_transferencia)>$this->precio_venta;
}
}

View File

@@ -70,7 +70,7 @@ return [
|
*/
'timezone' => 'UTC',
'timezone' => 'America/Tijuana',
/*
|--------------------------------------------------------------------------

View File

@@ -41,7 +41,7 @@
</tr>
</thead>
<tbody>
@foreach ($ventas as $venta)
@forelse ($ventas as $venta)
<th>{{ $venta->codigo }}</th>
<th>{{ $venta->pago_efectivo }}</th>
<th>{{ $venta->pago_tarjeta }}</th>
@@ -58,7 +58,13 @@
@endif
</th>
</tr>
@endforeach
@empty
<div class="alert alert-info my-4 max-w-3xl mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span>No hay ventas registradas en el sistema.</span>
</div>
@endforelse
</tbody>
</table>
{{$ventas->links()}}
@@ -123,7 +129,7 @@
</div>
</div>
@error('ventaEspecial.pago_vales')<span class="block text-sm mx-2 text-error">{{ $message }}</span>@enderror
<div class="flex gap-3">
<button wire:click="save()" class="btn btn-success btn-block">Guardar</button>
</div>
@@ -197,6 +203,9 @@
@if (session()->has('message_abono'))
<span class="block text-lg mx-auto text-error">{{ session('message_abono') }}</span>
@endif
@if (session()->has('error'))
<span class="block text-lg mx-auto text-error">{{ session('error') }}</span>
@endif
<div class="flex gap-3">
<button wire:click="saveLiquidar()" class="btn btn-success btn-block">Guardar</button>
</div>

View File

@@ -123,6 +123,10 @@
</div>
@error('venta.pago_vales')<span class="block text-sm mx-2 text-error">{{ $message }}</span>@enderror
@if (session()->has('error'))
<span class="block text-lg mx-auto text-error">{{ session('error') }}</span>
@endif
<div class="flex gap-3">
<button wire:click="save()" class="btn btn-success btn-block">Guardar</button>
</div>