Finalizacion de la primera version del proyecto
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\EstadoVenta;
|
||||
use App\Models\Venta;
|
||||
use App\Models\EstadoMovimiento;
|
||||
use App\Models\Movimiento;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
@@ -15,16 +15,16 @@ class VentaController extends Component
|
||||
const CODIGO_VENTA = 1;
|
||||
|
||||
public $buscador = '', $modal = false;
|
||||
public $venta;
|
||||
public $venta, $cambio, $faltante;
|
||||
|
||||
protected $rules = [
|
||||
'venta.codigo' => 'min:0',
|
||||
'venta.pago_efectivo' => 'numeric',
|
||||
'venta.pago_tarjeta_debito' => 'numeric',
|
||||
'venta.pago_tarjeta_credito' => 'numeric',
|
||||
'venta.pago_tarjeta' => 'numeric',
|
||||
'venta.pago_vales' => 'numeric',
|
||||
'venta.precio_venta' => 'numeric',
|
||||
'venta.estado_venta_id' => 'numeric',
|
||||
'venta.precio_venta' => 'required|numeric|gte:1',
|
||||
'venta.pago_transferencia' => 'numeric',
|
||||
'venta.estado_movimiento_id' => 'numeric',
|
||||
'venta.user_id',
|
||||
];
|
||||
|
||||
@@ -35,39 +35,55 @@ class VentaController extends Component
|
||||
|
||||
public function render()
|
||||
{
|
||||
$ventas = Venta::where([['codigo','like','%'.$this->buscador.'%'],['estado_venta_id','=',VentaController::CODIGO_VENTA]])->paginate(10);
|
||||
$ventas = Movimiento::where([['codigo','like','%'.$this->buscador.'%'],['estado_movimiento_id','=',VentaController::CODIGO_VENTA]])->paginate(10);
|
||||
return view('venta.venta',[
|
||||
'ventas' => $ventas,
|
||||
'estadoVentas' => EstadoVenta::all(),
|
||||
'estadoVentas' => EstadoMovimiento::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->clearInputs();
|
||||
$this->venta = new Venta([
|
||||
$this->venta = new Movimiento([
|
||||
'codigo' => 0,
|
||||
'pago_efectivo' => 0,
|
||||
'pago_tarjeta_debito' => 0,
|
||||
'pago_tarjeta_credito' => 0,
|
||||
'pago_vales' => 0,
|
||||
'precio_venta' => 0,
|
||||
'estado_venta_id' => 1,
|
||||
'pago_efectivo' => 0,
|
||||
'pago_tarjeta' => 0,
|
||||
'pago_vales' => 0,
|
||||
'pago_transferencia' => 0,
|
||||
'estado_movimiento_id' => 1,
|
||||
]);
|
||||
$this->cambio;
|
||||
$this->showModal();
|
||||
}
|
||||
|
||||
public function updated()
|
||||
{
|
||||
if($this->venta->cambio()>0)
|
||||
{
|
||||
$this->cambio = $this->venta->cambio();
|
||||
$this->faltante = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->faltante = $this->venta->faltante();
|
||||
$this->cambio = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'venta.pago_efectivo' => 'numeric',
|
||||
'venta.pago_tarjeta_debito' => 'numeric',
|
||||
'venta.pago_tarjeta_credito' => 'numeric',
|
||||
'venta.precio_venta' => 'required|numeric|gte:1',
|
||||
'venta.pago_tarjeta' => 'required|numeric',
|
||||
'venta.pago_vales' => 'numeric',
|
||||
'venta.precio_venta' => 'numeric',
|
||||
'venta.estado_venta_id' => 'numeric',
|
||||
'venta.pago_transferencia' => 'numeric',
|
||||
'venta.estado_movimiento_id' => 'numeric',
|
||||
]);
|
||||
|
||||
$this->venta->ajusteCambio();
|
||||
|
||||
$this->venta->user_id = Auth::user()->id;
|
||||
$this->venta->save();
|
||||
|
||||
Reference in New Issue
Block a user