Implementacion de modulo de pedidos
This commit is contained in:
@@ -12,7 +12,7 @@ class VentaEspecialController extends Component
|
||||
use WithPagination;
|
||||
|
||||
const CODIGO_VENTA_ESPECIAL = 2;
|
||||
public $buscador = '', $modal = false, $modalLiquidar;
|
||||
public $buscador = '', $modal = false, $modalDate = false, $created_at, $modalLiquidar;
|
||||
public $ventaEspecial, $total_pagar, $ventaAnterior, $abonado, $cambio, $faltante;
|
||||
|
||||
protected $rules = [
|
||||
@@ -22,6 +22,7 @@ class VentaEspecialController extends Component
|
||||
'ventaEspecial.pago_vales' => 'numeric',
|
||||
'ventaEspecial.precio_venta' => 'numeric',
|
||||
'ventaEspecial.pago_transferencia' => 'numeric',
|
||||
'ventaEspecial.nota_credito' => 'numeric',
|
||||
'ventaEspecial.estado_movimiento_id' => 'numeric',
|
||||
];
|
||||
|
||||
@@ -47,6 +48,7 @@ class VentaEspecialController extends Component
|
||||
'pago_tarjeta' => 0,
|
||||
'pago_vales' => 0,
|
||||
'pago_transferencia' => 0,
|
||||
'nota_credito' => 0,
|
||||
'precio_venta' => 0,
|
||||
'estado_movimiento_id' => VentaEspecialController::CODIGO_VENTA_ESPECIAL,
|
||||
|
||||
@@ -64,6 +66,7 @@ class VentaEspecialController extends Component
|
||||
'pago_tarjeta' => 0,
|
||||
'pago_vales' => 0,
|
||||
'pago_transferencia' => 0,
|
||||
'nota_credito' => 0,
|
||||
'precio_venta' => $this->ventaAnterior->faltante(),
|
||||
'estado_movimiento_id' => VentaEspecialController::CODIGO_VENTA_ESPECIAL,
|
||||
]);
|
||||
@@ -93,7 +96,9 @@ class VentaEspecialController extends Component
|
||||
|
||||
public function calcularTotalPagar($venta)
|
||||
{
|
||||
return ($venta->precio_venta - $venta->pago_efectivo - $venta->pago_tarjeta - $venta->pago_vales - $venta->pago_transferencia);
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +109,7 @@ class VentaEspecialController extends Component
|
||||
'ventaEspecial.pago_tarjeta' => 'numeric',
|
||||
'ventaEspecial.pago_vales' => 'numeric',
|
||||
'ventaEspecial.pago_transferencia' => 'numeric',
|
||||
'ventaEspecial.nota_credito' => 'numeric',
|
||||
'ventaEspecial.precio_venta' => 'numeric|gte:2',
|
||||
'ventaEspecial.estado_movimiento_id' => 'numeric',
|
||||
]);
|
||||
@@ -124,10 +130,12 @@ class VentaEspecialController extends Component
|
||||
'ventaEspecial.pago_tarjeta' => 'numeric',
|
||||
'ventaEspecial.pago_vales' => 'numeric',
|
||||
'ventaEspecial.pago_transferencia' => 'numeric',
|
||||
'ventaEspecial.nota_credito' => 'numeric',
|
||||
'ventaEspecial.precio_venta' => 'numeric|gte:2',
|
||||
'ventaEspecial.estado_movimiento_id' => 'numeric',
|
||||
]);
|
||||
|
||||
|
||||
if(($this->calcularTotalPagar($this->ventaEspecial) - $this->ventaAnterior->totalAbono()) >0){
|
||||
session()->flash("message_abono","Debes liquidar la deuda para cerrarla.");
|
||||
return;
|
||||
@@ -137,7 +145,7 @@ class VentaEspecialController extends Component
|
||||
session()->flash("error","Pago diferente al efectivo no pueden superar el total de venta.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->ventaAnterior->is_liquidado = true;
|
||||
$this->ventaAnterior->save();
|
||||
|
||||
@@ -156,6 +164,26 @@ class VentaEspecialController extends Component
|
||||
$this->closeModalLiquidar();
|
||||
}
|
||||
|
||||
public function editDate(Movimiento $movimiento)
|
||||
{
|
||||
$this->ventaEspecial = $movimiento;
|
||||
$this->showModal('modalDate');
|
||||
}
|
||||
|
||||
public function saveDate()
|
||||
{
|
||||
$this->validate([
|
||||
'created_at' => 'required',
|
||||
]);
|
||||
|
||||
$this->ventaEspecial->created_at = $this->created_at;
|
||||
$this->ventaEspecial->save();
|
||||
session()->flash('message',"La fecha ha sido cambiada correctamente.");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModal('modalDate');
|
||||
}
|
||||
|
||||
public function delete(Movimiento $venta)
|
||||
{
|
||||
|
||||
@@ -167,14 +195,14 @@ class VentaEspecialController 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 showModalLiquidar()
|
||||
|
||||
Reference in New Issue
Block a user