Se reparo error en el buscador
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user