Implementacion de modulo de pedidos
This commit is contained in:
@@ -14,8 +14,8 @@ class VentaController extends Component
|
||||
|
||||
const CODIGO_VENTA = 1;
|
||||
|
||||
public $buscador = '', $modal = false;
|
||||
public $venta, $cambio, $faltante;
|
||||
public $buscador = '', $modal = false, $modalDate = false;
|
||||
public $venta, $cambio, $faltante, $created_at;
|
||||
|
||||
protected $rules = [
|
||||
'venta.codigo' => 'min:0',
|
||||
@@ -24,6 +24,7 @@ class VentaController extends Component
|
||||
'venta.pago_vales' => 'numeric',
|
||||
'venta.precio_venta' => 'required|numeric|gte:1',
|
||||
'venta.pago_transferencia' => 'numeric',
|
||||
'venta.nota_credito' => 'numeric',
|
||||
'venta.estado_movimiento_id' => 'numeric',
|
||||
'venta.user_id',
|
||||
];
|
||||
@@ -52,6 +53,7 @@ class VentaController extends Component
|
||||
'pago_tarjeta' => 0,
|
||||
'pago_vales' => 0,
|
||||
'pago_transferencia' => 0,
|
||||
'nota_credito' => 0,
|
||||
'estado_movimiento_id' => 1,
|
||||
]);
|
||||
$this->cambio;
|
||||
@@ -74,6 +76,33 @@ class VentaController extends Component
|
||||
}
|
||||
}
|
||||
|
||||
public function calcularTotalPagar($venta)
|
||||
{
|
||||
return ((float)$venta->precio_venta - ((float)$venta->pago_efectivo +
|
||||
(float)$venta->pago_tarjeta + (float)$venta->pago_vales +
|
||||
(float)$venta->pago_transferencia + (float)$venta->nota_credito));
|
||||
}
|
||||
|
||||
public function editDate(Movimiento $movimiento)
|
||||
{
|
||||
$this->venta = $movimiento;
|
||||
$this->showModal('modalDate');
|
||||
}
|
||||
|
||||
public function saveDate()
|
||||
{
|
||||
$this->validate([
|
||||
'created_at' => 'required',
|
||||
]);
|
||||
|
||||
$this->venta->created_at = $this->created_at;
|
||||
$this->venta->save();
|
||||
session()->flash('message',"La fecha ha sido cambiada correctamente.");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModal('modalDate');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
@@ -82,6 +111,7 @@ class VentaController extends Component
|
||||
'venta.pago_tarjeta' => 'required|numeric',
|
||||
'venta.pago_vales' => 'numeric',
|
||||
'venta.pago_transferencia' => 'numeric',
|
||||
'venta.nota_credito' => 'numeric',
|
||||
'venta.estado_movimiento_id' => 'numeric',
|
||||
]);
|
||||
|
||||
@@ -91,6 +121,12 @@ class VentaController extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->calcularTotalPagar($this->venta)>0)
|
||||
{
|
||||
session()->flash("error","El pago debe ser igual o mayor a la venta.");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->venta->ajusteCambio();
|
||||
|
||||
$this->venta->user_id = Auth::user()->id;
|
||||
@@ -112,15 +148,14 @@ class VentaController extends Component
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function showModal()
|
||||
public function showModal($modal = "modal")
|
||||
{
|
||||
$this->modal = true;
|
||||
$this->{$modal} = true;
|
||||
}
|
||||
|
||||
public function closeModal()
|
||||
public function closeModal($modal = "modal")
|
||||
{
|
||||
$this->modal = false;
|
||||
$this->{$modal} = false;
|
||||
}
|
||||
|
||||
public function clearInputs()
|
||||
|
||||
Reference in New Issue
Block a user