diff --git a/app/Http/Livewire/CancelacionController.php b/app/Http/Livewire/CancelacionController.php
index 94d2699..af22c95 100644
--- a/app/Http/Livewire/CancelacionController.php
+++ b/app/Http/Livewire/CancelacionController.php
@@ -12,9 +12,9 @@ class CancelacionController extends Component
use WithPagination;
const CODIGO_CANCELACION = 3;
- public $buscador = '' , $modal = false;
+ public $buscador = '' , $modal = false, $modalDate = false;
- public $cancelacion;
+ public $cancelacion, $created_at;
protected $rules = [
'cancelacion.codigo' => 'min:0',
@@ -71,6 +71,26 @@ class CancelacionController extends Component
$this->closeModal();
}
+ public function editDate(Movimiento $movimiento)
+ {
+ $this->cancelacion = $movimiento;
+ $this->showModal('modalDate');
+ }
+
+ public function saveDate()
+ {
+ $this->validate([
+ 'created_at' => 'required',
+ ]);
+
+ $this->cancelacion->created_at = $this->created_at;
+ $this->cancelacion->save();
+ session()->flash('message',"La fecha ha sido cambiada correctamente.");
+
+ $this->clearInputs();
+ $this->closeModal('modalDate');
+ }
+
public function delete(Movimiento $venta)
{
@@ -82,14 +102,14 @@ class CancelacionController 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()
diff --git a/app/Http/Livewire/DashboardController.php b/app/Http/Livewire/DashboardController.php
index 32801b8..765c521 100644
--- a/app/Http/Livewire/DashboardController.php
+++ b/app/Http/Livewire/DashboardController.php
@@ -58,7 +58,11 @@ class DashboardController extends Component
Movimiento::where([
['estado_movimiento_id','=', $tipo_movimiento],
[DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')],
- ])->sum('pago_vales');
+ ])->sum('pago_vales') +
+ Movimiento::where([
+ ['estado_movimiento_id','=', $tipo_movimiento],
+ [DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')],
+ ])->sum('pago_transferencia');
}
public function validarCaja()
diff --git a/app/Http/Livewire/ImpresoraController.php b/app/Http/Livewire/ImpresoraController.php
new file mode 100644
index 0000000..8d7b86c
--- /dev/null
+++ b/app/Http/Livewire/ImpresoraController.php
@@ -0,0 +1,102 @@
+ 'required',
+ 'impresora.nombre_impresora' => 'required',
+ 'impresora.is_compartida' => 'required'
+ ];
+ public function render()
+ {
+ $impresoraUser = auth()->user()->impresora_id;
+ return view('impresora.impresora',[
+ 'impresoras' => Impresora::paginate(10),
+ ]);
+ }
+
+ public function create()
+ {
+ $this->impresora = new Impresora();
+ $this->impresora->is_compartida = false;
+ $this->openModal();
+ }
+
+ public function saveImpresora()
+ {
+ $user = User::findOrFail(auth()->user()->id);
+
+ $user->impresora_id = $this->impresoraUser;
+ $user->save();
+ session()->flash('messageImpresora','Impresora vinculada correctamente.');
+ }
+
+ public function save()
+ {
+ $this->validate([
+ 'impresora.estacion' => 'required',
+ ]);
+
+ if($this->impresora->is_compartida)
+ {
+ $this->validate([
+ 'impresora.nombre_impresora' => 'required'
+ ]);
+ }
+ else if(!is_numeric($this->impresora->nombre_impresora))
+ {
+ $this->impresora->nombre_impresora = 9100;
+ }
+
+ $this->impresora->save();
+
+ session()->flash('message','La impresora se guardo correctamente.');
+ $this->closeModal();
+ $this->clearInputs();
+ }
+
+ public function imprimir(Impresora $impresora)
+ {
+ try {
+ $printer = new PrinterHandler($impresora, $impresora->is_compartida?PrinterHandler::PRINTER_BY_SHARED:PrinterHandler::PRINTER_BY_IP);
+ // 32 caracteres
+ $printer->testPage();
+
+ session()->flash('message','Impresion enviada a: '.'smb://'.$impresora->estacion.'/'.$impresora->nombre_impresora);
+ } catch (\Throwable $th) {
+ session()->flash('error','No se pudo establecer conexión con la impresora, verifica configuración.'.$th->getMessage());
+ }
+ }
+
+ public function delete(Impresora $impresora)
+ {
+ $impresora->delete();
+ session()->flash('message','La impresora se ha eliminado correctamente.');
+ }
+ public function openModal()
+ {
+ $this->modal = true;
+ }
+
+ public function closeModal()
+ {
+ $this->modal = false;
+ }
+
+ public function clearInputs()
+ {
+ $this->reset();
+ }
+}
diff --git a/app/Http/Livewire/PedidoController.php b/app/Http/Livewire/PedidoController.php
new file mode 100644
index 0000000..afb9769
--- /dev/null
+++ b/app/Http/Livewire/PedidoController.php
@@ -0,0 +1,410 @@
+ 'required',
+ 'productos.*.codigo' => 'required',
+ 'productos.*.descripcion' => 'required',
+ 'productos.*.ruta_id' => 'required',
+ 'productos.*.cantidad' => 'required',
+ 'productos.*.precio_unitario' => 'required',
+ 'pedido.cuenta' => 'required',
+ 'pedido.folio_proveedor' => 'required',
+ 'pedido.telefono' => 'required',
+ 'pedido.year' => 'required',
+ 'pedido.marca' => 'required',
+ 'pedido.modelo' => 'required',
+ 'pedido.motor' => 'required',
+ 'pedido.user_id' => 'required',
+ 'pedido.comentarios' => 'required',
+ 'pedido.numero_remision' => 'required',
+ 'totals.*' => 'required',
+ 'ventaEspecial.codigo' => 'min:0',
+ 'ventaEspecial.pago_efectivo' => 'numeric',
+ 'ventaEspecial.pago_tarjeta' => 'numeric',
+ 'ventaEspecial.pago_vales' => 'numeric',
+ 'ventaEspecial.precio_venta' => 'numeric',
+ 'ventaEspecial.pago_transferencia' => 'numeric',
+ 'ventaEspecial.nota_credito' => 'numeric',
+ 'ventaEspecial.estado_movimiento_id' => 'numeric',
+ ];
+
+ protected $messages = [
+ 'productos.*.linea.required' => 'Campo obligatorio.',
+ 'productos.*.codigo.required' => 'Campo obligatorio.',
+ 'productos.*.descripcion.required' => 'Campo obligatorio.',
+ 'productos.*.ruta_id.required' => 'Campo obligatorio.',
+ 'productos.*.cantidad.required' => 'Campo obligatorio.',
+ 'productos.*.precio_unitario.required' => 'Campo obligatorio.',
+ 'productos.*.unidades.required' => 'Campo obligatorio.',
+
+ 'productos.*.linea.max' => 'Campo debe ser menor a :max.',
+ 'productos.*.codigo.max' => 'Campo debe ser menor a :max.',
+ 'productos.*.descripcion.max' => 'Campo debe ser menor a :max.',
+ 'productos.*.ruta_id.max' => 'Campo debe ser menor a :max.',
+ 'productos.*.cantidad.max' => 'Campo debe ser menor a :max.',
+ 'productos.*.precio_unitario.max' => 'Campo debe ser menor a :max.',
+ ];
+
+ protected $listeners = ['agregar','save','saveArrivo','cerrarVenta','entregarVenta'];
+
+ public function render()
+ {
+ if($this->buscador != "")
+ {
+ $pedidos = Pedido::where('pedido','like','%'.$this->buscador.'%')
+ ->orderBy('is_venta_cerrada','asc')
+ ->orderBy('is_venta_entregada','asc')
+ ->orderBy('id','desc')
+ ->paginate(10);
+ }
+ else
+ {
+ $pedidos = Pedido::Where('user_id',"=",auth()->user()->id)
+ ->orderBy('is_venta_cerrada','ASC')
+ ->orderBy('is_venta_entregada','ASC')
+ ->orderBy('id','desc')
+ ->paginate(10);
+ }
+ return view('pedido.pedido',[
+ // 'pedidos' => Pedido::where('pedido','like','%'.$this->buscador.'%')->orWhere('user_id',"=",auth()->user()->id)->orderBy('id','desc')->paginate(10),
+ 'pedidos' => $pedidos,
+ 'productosList' => Producto::where('descripcion','like','%'.$this->buscadorProducto.'%')
+ ->orWhere('codigo','like','%'.$this->buscadorProducto.'%')->paginate(10),
+ 'rutas' => Ruta::all(),
+ ]);
+ }
+
+ public function create()
+ {
+ $this->reset();
+ $this->pago_efectivo = 0;
+ $this->cambio = 0;
+ $this->pedido = new Pedido();
+ $this->ventaEspecial = new Movimiento([
+ 'codigo' => 0,
+ 'pago_efectivo' => 0,
+ 'pago_tarjeta' => 0,
+ 'pago_vales' => 0,
+ 'pago_transferencia' => 0,
+ 'nota_credito' => 0,
+ 'precio_venta' => 0,
+ 'estado_movimiento_id' => VentaEspecialController::CODIGO_VENTA_ESPECIAL,
+
+ ]);
+ $this->showModal();
+ }
+
+ public function agregar($id = '')
+ {
+ // if(auth()->user()->hasRole('admin'))
+ $this->buscadorProducto = '';
+ $this->productos[] = Producto::firstOrNew(['id' => $id]);
+ $this->totals[] = 0;
+ $this->emit('addProductEvent');
+ }
+
+ public function agregarProductoArrivo($id = '')
+ {
+ if(auth()->user()->hasRole('admin'))
+ {
+ $this->buscadorProducto = '';
+ $this->productos[] = Producto::firstOrNew(['id' => $id]);
+ $this->totals[] = 0;
+ $this->emit('addProductEvent');
+ }
+ }
+
+ public function total($id)
+ {
+ return ((key_exists('cantidad',$this->productos[$id]) && key_exists('precio_unitario',$this->productos[$id]) ) &&
+ (is_numeric($this->productos[$id]['cantidad']) && is_numeric($this->productos[$id]['precio_unitario'])))
+ ?$this->productos[$id]['cantidad'] * $this->productos[$id]['precio_unitario']
+ :'0';
+ }
+
+ public function updatedPagoEfectivo($value)
+ {
+ if($value)
+ {
+ $this->cambio = $this->pago_efectivo - $this->ventaEspecial->pago_efectivo;
+ }
+ }
+
+
+ public function updatedProductos($value, $key)
+ {
+ $key = intval(explode('.',$key)[0]);
+ $this->totals[$key] = $this->total($key);
+ if($this->totals[$key] != 0)
+ {
+ $this->updateTotal($this->totals);
+ }
+ }
+
+ public function updateTotal($totals)
+ {
+ $total = array_sum(array_filter($totals,'is_numeric'));
+ $this->totalPagar = $total/1.08;
+ $this->IVA = $this->totalPagar*0.08;
+ $this->totalPagar += $this->IVA;
+ }
+
+ public function updatedModal()
+ {
+ if(!$this->modal){
+ $this->clearInputs();
+ }
+ }
+
+ public function updatedModalPedido()
+ {
+ if(!$this->modalPedido){
+ $this->clearInputs();
+ }
+ }
+
+ public function show(Pedido $pedido)
+ {
+ // dd($pedido->is_venta_cerrada,$pedido->is_venta_entregada);
+ $this->totalPagar = 0;
+ $this->IVA = 0;
+ $this->pedido = $pedido;
+ foreach ($this->pedido->productos as $producto) {
+ $producto->unidades = $producto->pivot->unidades;
+ $producto->precio_unitario = $producto->pivot->precio_unitario;
+ $producto->producto_id = $producto->pivot->producto_id;
+ $producto->is_arrivo = $producto->pivot->is_arrivo;
+ $this->productos[] = $producto;
+ $this->totalPagar+= ($producto->pivot->unidades*$producto->pivot->precio_unitario);
+ }
+
+ $this->totalPagar/= 1.08;
+ $this->IVA = $this->totalPagar*0.08;
+ $this->totalPagar += $this->IVA;
+
+ $this->showModal('modalPedido');
+ }
+ public function save()
+ {
+ if(!$this->productos)
+ {
+ return;
+ }
+ $this->pedido->user_id = auth()->user()->id;
+ $this->validate([
+ 'pedido.cuenta' => 'required',
+ 'pedido.telefono' => 'required',
+ 'pedido.year' => 'required',
+ 'pedido.marca' => 'required',
+ 'pedido.modelo' => 'required',
+ 'pedido.motor' => 'required',
+ 'productos.*.linea' => 'required|max:20',
+ 'productos.*.codigo' => 'required|max:20',
+ 'productos.*.descripcion' => 'required|max:100',
+ 'productos.*.ruta_id' => 'required',
+ 'productos.*.cantidad' => 'required|max:4',
+ 'productos.*.precio_unitario' => 'required|max:8',
+
+ 'ventaEspecial.pago_efectivo' => 'numeric',
+ 'ventaEspecial.pago_tarjeta' => 'numeric',
+ 'ventaEspecial.pago_vales' => 'numeric',
+ 'ventaEspecial.pago_transferencia' => 'numeric',
+ 'ventaEspecial.nota_credito' => 'numeric',
+ 'ventaEspecial.estado_movimiento_id' => 'numeric',
+ ]);
+
+ $this->pedido->is_venta_cerrada = 0;
+ $this->pedido->is_venta_entregada = 0;
+
+ $this->pedido->save();
+
+ $this->ventaEspecial->user_id = auth()->user()->id;
+ $this->ventaEspecial->precio_venta = $this->totalPagar;
+ $this->ventaEspecial->codigo = $this->pedido->pedido;
+ $this->ventaEspecial->save();
+ // $this->ventaEspecial->save();
+
+ foreach ($this->productos as $producto) {
+ $productoCreated = Producto::firstOrCreate(
+ ['linea' => $producto['linea'], 'codigo' => $producto['codigo']],
+ [
+ 'linea' => $producto['linea'],
+ 'codigo' => $producto['codigo'],
+ 'descripcion' => $producto['descripcion'],
+ 'ruta_id' => $producto['ruta_id'],
+ 'precio_unitario' => $producto['precio_unitario'],
+ ]
+ );
+
+ $productoCreated->precio_unitario = $producto['precio_unitario'];
+ $productoCreated->save();
+
+ $this->pedido->productos()->attach($productoCreated->id,['unidades' => $producto['cantidad'], 'precio_unitario' => $producto['precio_unitario'], 'is_arrivo' => false]);
+ }
+ $this->pedido->cambio = $this->cambio;
+ // $this->imprimirTicket($this->pedido);
+ // $this->imprimirTicket($this->pedido,false);
+ session()->flash('message','El pedido se ha generado correctamente.');
+ $this->closeModal();
+ $this->clearInputs();
+ }
+
+ public function entregarVenta()
+ {
+ $this->pedido->is_venta_entregada = true;
+ $this->pedido->venta_entregada_user_id = auth()->user()->id;
+ $this->pedido->venta_entregada_at = Carbon::now();
+ $this->pedido->save();
+
+ $this->closeModal('modalPedido');
+ session()->flash('message','El pedido se ha entregado correctamente.');
+ $this->clearInputs();
+ }
+
+ public function cerrarVenta()
+ {
+ if(!$this->pedido->is_venta_entregada)
+ {
+ session()->flash('error','No puedes cerrar la venta si no la has entregado.');
+ $this->closeModal('modalPedido');
+ return;
+ }
+ $this->pedido->is_venta_cerrada = true;
+ $this->pedido->venta_cerrada_user_id = auth()->user()->id;
+ $this->pedido->venta_cerrada_at = Carbon::now();
+ $this->pedido->save();
+
+ $this->closeModal('modalPedido');
+ session()->flash('message','El pedido se ha cerrado correctamente.');
+ $this->clearInputs();
+ }
+
+ public function saveArrivo()
+ {
+ if(auth()->user()->hasRole('admin'))
+ {
+ $this->validate([
+ 'pedido.cuenta' => 'required',
+ 'pedido.telefono' => 'required',
+ 'pedido.year' => 'required',
+ 'pedido.marca' => 'required',
+ 'pedido.modelo' => 'required',
+ 'pedido.motor' => 'required',
+ 'productos.*.linea' => 'required|max:20',
+ 'productos.*.codigo' => 'required|max:20',
+ 'productos.*.descripcion' => 'required|max:100',
+ 'productos.*.ruta_id' => 'required',
+ 'productos.*.unidades' => 'required|max:10',
+ 'productos.*.precio_unitario' => 'required|max:8',
+ ]);
+
+ foreach ($this->productos as $index => $producto) {
+ $productoCreado = Producto::updateOrCreate(
+ ['id' => $producto['id']??""],
+ [
+ 'linea' => $producto['linea'],
+ 'codigo' => $producto['codigo'],
+ 'descripcion' => $producto['descripcion'],
+ 'ruta_id' => $producto['ruta_id'],
+ 'precio_unitario' => $producto['precio_unitario'],
+ ]
+ );
+ $this->productos[$index]['producto_id'] = $productoCreado->id;
+ $this->productos[$index]['id'] = $productoCreado->id;
+ }
+ }
+
+
+ // if(auth()->user()->hasRole('admin'))
+ // {
+ $this->validate([
+ 'pedido.cuenta' => 'required',
+ 'pedido.telefono' => 'required',
+ 'pedido.year' => 'required',
+ ]);
+
+ $this->pedido->save();
+ $productosSync = [];
+ foreach ($this->productos as $producto) {
+ $productosSync[$producto['id']] = [
+ 'unidades' => $producto['unidades'],
+ 'precio_unitario' => $producto['precio_unitario'],
+ 'is_arrivo' => $producto['is_arrivo'] ?? 0
+ ];
+ }
+ $this->pedido->productos()->sync($productosSync);
+
+ session()->flash('message','El pedido se ha actualizado correctamente.');
+ // }
+ $this->closeModal('modalPedido');
+ $this->clearInputs();
+ }
+
+ public function delete(Pedido $pedido)
+ {
+ if(auth()->user()->hasRole('admin'))
+ {
+ $pedido->productos()->detach();
+ $pedido->delete();
+ session()->flash('message','El pedido se ha eliminado correctamente.');
+ }
+ }
+
+ public function eliminarProducto($id)
+ {
+ unset($this->productos[$id]);
+ unset($this->totals[$id]);
+ }
+
+ public function imprimirTicket(Pedido $pedido,$hashed = true)
+ {
+ // foreach ($pedido->productos as $producto) {
+ // dd('Codigo:'.$producto->codigo.' desc:'.substr($producto->descripcion,0,11).' Cant:'.$producto->pivot->unidades.' Total:'.round($producto->pivot->unidades*$producto->pivot->precio_unitario/1.16,2));
+ // // dd($producto->pivot);
+ // }
+ // try {
+ $impresora = Impresora::findOrFail(auth()->user()->impresora_id);
+ $printer = new PrinterHandler($impresora,$impresora->is_compartida?PrinterHandler::PRINTER_BY_SHARED:PrinterHandler::PRINTER_BY_IP);
+ $printer->printPedido($pedido,$hashed);
+ $printer->feed();
+ $printer->cut();
+ $printer->close();
+ // } catch (\Throwable $th) {
+ // throw $th;
+ // }
+ }
+
+ public function showModal($modal = 'modal')
+ {
+ $this->{$modal} = true;
+ }
+
+ public function closeModal($modal = 'modal')
+ {
+ $this->{$modal} = false;
+ }
+
+ public function clearInputs()
+ {
+ $this->reset();
+ }
+}
diff --git a/app/Http/Livewire/ReportePedidoController.php b/app/Http/Livewire/ReportePedidoController.php
new file mode 100644
index 0000000..16f1f62
--- /dev/null
+++ b/app/Http/Livewire/ReportePedidoController.php
@@ -0,0 +1,63 @@
+when($this->is_venta_entregada, function ($query) {
+ return $query->where('is_venta_entregada',"=",$this->is_venta_entregada);
+ });
+ $query->when($this->is_venta_cerrada, function ($query) {
+ return $query->where('is_venta_cerrada',"=",$this->is_venta_cerrada);
+ });
+
+ $query->when(($this->fn_inicio && $this->fn_final), function ($query) {
+ return $query->whereBetween('created_at', [$this->fn_inicio, $this->fn_final]);
+ });
+ return view('pedido.reporte-pedido',[
+ 'pedidos' => $query->get(),
+ ]);
+ }
+
+ public function updatedFechaInicio()
+ {
+ $this->fn_inicio= Carbon::parse($this->fecha_inicio)->startOfDay();
+ }
+
+ public function updatedFechaFinal()
+ {
+ $this->fn_final= Carbon::parse($this->fecha_final)->endOfDay();
+ }
+
+ public function export()
+ {
+ $query = Pedido::query();
+
+ $query->when($this->is_venta_entregada, function ($query) {
+ return $query->where('is_venta_entregada',"=",$this->is_venta_entregada);
+ });
+ $query->when($this->is_venta_cerrada, function ($query) {
+ return $query->where('is_venta_cerrada',"=",$this->is_venta_cerrada);
+ });
+
+ $query->when(($this->fn_inicio && $this->fn_final), function ($query) {
+ return $query->whereBetween('created_at', [$this->fn_inicio, $this->fn_final]);
+ });
+
+ return Excel::download(new PedidosExport($this->fn_inicio, $this->fn_final,$this->is_venta_cerrada,$this->is_venta_entregada),'pedido-'.Carbon::now()->format('Y-m-d').'.xlsx');
+ }
+}
diff --git a/app/Http/Livewire/RutaController.php b/app/Http/Livewire/RutaController.php
new file mode 100644
index 0000000..3a9ef14
--- /dev/null
+++ b/app/Http/Livewire/RutaController.php
@@ -0,0 +1,79 @@
+ 'required',
+ 'ruta.prefijo' => 'required',
+ ];
+ public function render()
+ {
+ $rutas = Ruta::where('ruta','like','%'.$this->buscador.'%')->paginate(10);
+ return view('ruta.ruta',[
+ 'rutas' => $rutas,
+ ]);
+ }
+
+ public function create()
+ {
+ $this->clearInputs();
+ $this->ruta = new Ruta();
+ $this->showModal();
+ }
+
+ public function save()
+ {
+ $this->validate([
+ 'ruta.ruta' => 'required|max:50',
+ 'ruta.prefijo' => 'required|max:10',
+ ]);
+
+ $id = $this->ruta->id;
+
+ $this->ruta->save();
+
+ session()->flash('message',$id?"La ruta se a modificado correctamente.":"La ruta se ha registrado correctamente!");
+
+ $this->clearInputs();
+ $this->closeModal();
+ }
+
+ public function edit(Ruta $ruta)
+ {
+ $this->ruta = $ruta;
+ $this->showModal();
+ }
+
+ public function delete(Ruta $ruta)
+ {
+
+ if(auth()->user()->hasRole('admin'))
+ {
+ $ruta->delete();
+ session()->flash('message',"La ruta se ha eliminado del sistema.");
+ }
+ }
+
+
+ public function showModal()
+ {
+ $this->modal = true;
+ }
+
+ public function closeModal()
+ {
+ $this->modal = false;
+ }
+
+ public function clearInputs()
+ {
+ $this->reset();
+ }
+}
diff --git a/app/Http/Livewire/UserController.php b/app/Http/Livewire/UserController.php
index 8c86bc9..a3219f4 100644
--- a/app/Http/Livewire/UserController.php
+++ b/app/Http/Livewire/UserController.php
@@ -58,7 +58,7 @@ class UserController extends Component
}
$this->validate([
'user.name' => 'required|min:3',
- 'password' => 'required|min:6'
+ // 'password' => 'required|min:6'
]);
$this->user->password = Hash::make($this->password);
diff --git a/app/Http/Livewire/VentaController.php b/app/Http/Livewire/VentaController.php
index 69c7c68..769c13d 100644
--- a/app/Http/Livewire/VentaController.php
+++ b/app/Http/Livewire/VentaController.php
@@ -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()
diff --git a/app/Http/Livewire/VentaEspecialController.php b/app/Http/Livewire/VentaEspecialController.php
index afed243..ca77999 100644
--- a/app/Http/Livewire/VentaEspecialController.php
+++ b/app/Http/Livewire/VentaEspecialController.php
@@ -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()
diff --git a/app/Models/Impresora.php b/app/Models/Impresora.php
new file mode 100644
index 0000000..6fc84bc
--- /dev/null
+++ b/app/Models/Impresora.php
@@ -0,0 +1,17 @@
+pago_efectivo +
(float)$this->pago_tarjeta +
(float)$this->pago_vales +
- (float)$this->pago_transferencia);
+ (float)$this->pago_transferencia +
+ (float)$this->nota_credito);
}
public function cambio()
@@ -47,6 +49,7 @@ class Movimiento extends Model
((float)$this->pago_efectivo +
(float)$this->pago_tarjeta +
(float)$this->pago_vales +
+ (float)$this->nota_credito +
(float)$this->pago_transferencia) -
(float)$this->precio_venta
);
@@ -59,7 +62,8 @@ class Movimiento extends Model
((float)$this->pago_efectivo +
(float)$this->pago_tarjeta +
(float)$this->pago_vales +
- (float)$this->pago_transferencia)
+ (float)$this->pago_transferencia +
+ (float)$this->nota_credito)
);
}
@@ -79,6 +83,30 @@ class Movimiento extends Model
public function isTotalMayorCambio() : bool
{
- return ($this->pago_tarjeta + $this->pago_vales + $this->pago_transferencia)>$this->precio_venta;
+ return ($this->pago_tarjeta + $this->pago_vales + $this->pago_transferencia + $this->nota_credito)>$this->precio_venta;
+ }
+
+ public function getAbonos()
+ {
+ $collecion = collect($this->getFillable());
+ $elements = [];
+ foreach ($collecion as $value) {
+ if(str_contains($value,"pago_"))
+ {
+ if($this->{$value} > 0)
+ {
+ $elements[] = [$this->{$value},str_replace("pago_","",$value)];
+ }
+ }
+ else if(str_contains($value,"nota_credito"))
+ {
+ if($this->{$value} > 0)
+ {
+ $elements[] = [$this->{$value},str_replace("nota_","Nota de ",$value)];
+ }
+ }
+ }
+
+ return $elements;
}
}
diff --git a/app/Models/Pedido.php b/app/Models/Pedido.php
new file mode 100644
index 0000000..d1679df
--- /dev/null
+++ b/app/Models/Pedido.php
@@ -0,0 +1,78 @@
+pedido = 'PE-'.$model->id;
+ $model->save();
+ } );
+ }
+
+
+ public function user()
+ {
+ return $this->belongsTo(User::class);
+ }
+
+ public function productos()
+ {
+ return $this->belongsToMany(Producto::class,'producto_pedidos','pedido_id','producto_id')->withPivot(['unidades','is_arrivo','precio_unitario']);
+ }
+
+ public function ultimaVenta()
+ {
+ return $this->hasOne(Movimiento::class,'codigo','pedido')->latest();
+ }
+
+ public function primeraVenta()
+ {
+ return $this->hasOne(Movimiento::class,'codigo','pedido')->first();
+ }
+
+ public function ultimaVentaBy()
+ {
+ return $this->ultimaVenta()->where('is_liquidado', '=', '1')->first();
+ }
+
+ public function ventaEntregadaUser()
+ {
+ return $this->belongsTo(User::class,'venta_entregada_user_id','id');
+ }
+
+ public function ventaCerradaUser()
+ {
+ return $this->belongsTo(User::class,'venta_cerrada_user_id','id');
+ }
+}
diff --git a/app/Models/Producto.php b/app/Models/Producto.php
new file mode 100644
index 0000000..71aa156
--- /dev/null
+++ b/app/Models/Producto.php
@@ -0,0 +1,30 @@
+belongsTo(Ruta::class);
+ }
+ // public function total()
+ // {
+ // return (is_int($this->cantidad) && is_int($this->precio_unitario))?$this->cantidad * $this->precio_unitario:'';
+ // }
+}
diff --git a/app/Models/Ruta.php b/app/Models/Ruta.php
new file mode 100644
index 0000000..e6cca70
--- /dev/null
+++ b/app/Models/Ruta.php
@@ -0,0 +1,16 @@
+
*/
protected $fillable = [
- 'name', 'email', 'password',
+ 'name', 'email', 'password','impresora_id',
];
/**
@@ -60,4 +60,9 @@ class User extends Authenticatable
protected $appends = [
'profile_photo_url',
];
+
+ public function impresora()
+ {
+ return $this->belongsTo(Impresora::class);
+ }
}
diff --git a/app/Printer/PrinterHandler.php b/app/Printer/PrinterHandler.php
new file mode 100644
index 0000000..5a9b588
--- /dev/null
+++ b/app/Printer/PrinterHandler.php
@@ -0,0 +1,172 @@
+impresora = $impresora;
+ if($type_printer == PrinterHandler::PRINTER_BY_IP)
+ {
+ $connector = new NetworkPrintConnector($impresora->estacion,$impresora->nombre_impresora);
+ }
+ else if($type_printer == PrinterHandler::PRINTER_BY_SHARED)
+ {
+ $connector = new WindowsPrintConnector("smb://".$impresora->estacion."/".$impresora->nombre_impresora."");
+ }
+ $this->printer = new Printer($connector);
+ }
+
+
+ public function text(string $message="") : void {
+ $this->printer->text($message."\n");
+ }
+
+ public function testPage()
+ {
+ $img = EscposImage::load('storage/img/proone_print.jpg',false);
+ $this->printer->bitImage($img);
+
+ $this->text("***** ESTRADA AUTOPARTES *****");
+ $this->text("Pagina de prueba de impresion");
+ $this->text("Estacion:".$this->impresora->estacion);
+ $this->text("Nombre Impresora:".$this->impresora->nombre_impresora);
+ $this->text("Desarrollado por Super Dev Bros");
+ $this->feed();
+ $this->cut();
+ $this->close();
+ }
+
+ public function printImage($path)
+ {
+ $img = EscposImage::load($path);
+ $this->printer->bitImage($img);
+ }
+
+ public function printPedido (Pedido $pedido, $hashed = true)
+ {
+ $IVA = 0;
+ $subTotal = 0;
+ $total = 0;
+ $this->printer->setJustification(Printer::JUSTIFY_CENTER);
+ $this->printImage('storage/img/proone_print.jpg');
+ $this->feed();
+ $this->printer -> setTextSize(2, 2);
+ if($hashed)
+ {
+ $this->text("CLIENTE");
+ }
+ $this->text("No. Pedido:");
+ $this->text($pedido->pedido);
+ $this->printer -> setTextSize(1, 1);
+ $this->printer->setJustification(Printer::JUSTIFY_CENTER);
+ $this->feed(1);
+ $this->text("MIGUEL ANGEL ROMERO ESTRADA");
+ $this->text("DIEGO ESQUIVEL #130 INT. 3");
+ $this->text("PLAYAS DE ROSARITO, BC 22706 Mexico");
+ $this->text("R.F.C. : ROEM691011EZ4");
+ $this->text("TELEFONOS: (661) 613-5549, (661) 104-4313");
+ $this->text(" (661) 104-4590, (661) 120-0015");
+ $this->text("CORREO: ventas@stradaautopartes.com");
+ $this->printer->setJustification(Printer::JUSTIFY_LEFT);
+ $this->feed(1);
+ $this->text("Atendido por: ".$pedido->user->name);
+ $this->feed(1);
+
+ $this->text("---------------- Datos Cliente ----------------");
+ $this->text("Cuenta: ".$pedido->cuenta);
+ $this->text("Telefono: ".$pedido->telefono);
+ $this->text("Fecha: ".now()->format('Y-m-d H:m:s'));
+ $this->text("Año:".$pedido->year);
+ $this->text("Marca:".$pedido->marca);
+ $this->text("Modelo:".$pedido->modelo);
+ $this->text("Motor:".$pedido->motor);
+ $this->text("---------------- Datos De Pago ----------------");
+ foreach ($pedido->primeraVenta()->getAbonos() as $value) {
+ $this->text("Metodo: ".$value[1]." | Anticipo: ".$value[0]);
+ }
+ $this->text("Adeudo: ".$pedido->primeraVenta()->faltante());
+
+ // $this->printer->setJustification(Printer::JUSTIFY_CENTER);
+ $this->text("-------------------- Pedido --------------------");
+ if($hashed)
+ {
+ $this->text('Codigo Linea Descripcion Cant Precio ');
+ }
+ else
+ {
+ // 48 digitos.
+ $this->text('Codigo Linea RT Descripcion Cant Precio ');
+ }
+ foreach ($pedido->productos as $producto) {
+ if($hashed)
+ {
+ $this->text(str_pad(substr(Hash::make($producto->codigo),0,10),11)."".str_pad($producto->linea,7)."".str_pad(substr($producto->descripcion,0,18),19)."".str_pad(intval($producto->pivot->unidades),5)."".round($producto->pivot->precio_unitario,8));
+ }
+ else
+ {
+ $this->text(str_pad(substr($producto->codigo ,0,10),11)."".str_pad($producto->linea,6)."".str_pad($producto->ruta->prefijo,5)."".str_pad(substr($producto->descripcion,0,11),12)."".str_pad(intval($producto->pivot->unidades),5)."".round($producto->pivot->precio_unitario,8));
+ }
+ // $this->text(str_pad(substr($producto->codigo,0,9),10)."".str_pad($producto->prefijo,6)."".str_pad(substr($producto->descripcion,0,14),15)."".str_pad($producto->pivot->unidades,10)."".round($producto->pivot->unidades*$producto->pivot->precio_unitario/1.16,2));
+ $subTotal+=$producto->pivot->unidades*$producto->pivot->precio_unitario/1.16;
+ }
+ $this->text("________________________________________________");
+ $IVA = $subTotal*0.16;
+ $total = round($subTotal+$IVA,2);
+ $this->feed(1);
+ $this->printer->setJustification(Printer::JUSTIFY_RIGHT);
+ $this->text("SubTotal: ".round($subTotal));
+ $this->text("IVA 8%: ".round($IVA));
+ $this->text("Total a Pagar: ".$total);
+ if($pedido->cambio>0)
+ {
+ $this->text("Cambio: ".$pedido->cambio);
+ }
+ $this->feed(1);
+ $this->printer->setJustification(Printer::JUSTIFY_CENTER);
+ $this->text("-------------------COMENTARIOS------------------");
+ $this->text($pedido->comentarios ?? "");
+ $this->text("________________________________________________");
+ $this->feed(1);
+ $this->text("Revise bien su mercancia, en partes electronicas");
+ $this->text("no hay garantia, no hay devolucion de efectivo.");
+ $this->text("Toda orden requiere un anticipo del 50%,");
+ $this->text("y toda cancelacion se cobrara el 50%");
+
+ $this->feed(1);
+ $this->feed(1);
+
+ $this->printer -> setTextSize(2, 2);
+ $this->text("¡Gracias por su compra!");
+
+ }
+
+ public function cut()
+ {
+ $this->printer->cut();
+ }
+
+ public function close()
+ {
+ $this->printer->close();
+ }
+ public function feed($lines=2)
+ {
+ $this->printer->feed($lines);
+ }
+}
diff --git a/app/exports/PedidosExport.php b/app/exports/PedidosExport.php
new file mode 100644
index 0000000..9660afc
--- /dev/null
+++ b/app/exports/PedidosExport.php
@@ -0,0 +1,58 @@
+fecha_inicio = $fecha_inicio;
+ $this->fecha_final = $fecha_final;
+ $this->is_venta_cerrada = $is_venta_cerrada;
+ $this->is_venta_entregada = $is_venta_entregada;
+
+ }
+
+ public function collection()
+ {
+ return Pedido::select(
+ 'pedido',
+ 'cuenta',
+ 'telefono',
+ 'year',
+ 'marca',
+ 'modelo',
+ 'motor',
+ )->get();
+ }
+
+ public function view(): View
+ {
+ $query = Pedido::query();
+
+ $query->when($this->is_venta_entregada, function ($query) {
+ return $query->where('is_venta_entregada',"=",$this->is_venta_entregada);
+ });
+ $query->when($this->is_venta_cerrada, function ($query) {
+ return $query->where('is_venta_cerrada',"=",$this->is_venta_cerrada);
+ });
+
+ $query->when(($this->fecha_inicio && $this->fecha_final), function ($query) {
+ return $query->whereBetween('created_at', [$this->fecha_inicio, $this->fecha_final]);
+ });
+
+ return view('export.reportePedidoExport',[
+ // 'pedidos' => Pedido::whereBetween('created_at',[$this->fecha_inicio,$this->fecha_final])->get(),
+ 'pedidos' => $query->get(),
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index f886c54..4bbd597 100644
--- a/composer.json
+++ b/composer.json
@@ -13,6 +13,7 @@
"laravel/tinker": "^2.8",
"livewire/livewire": "^2.11",
"maatwebsite/excel": "^3.1",
+ "mike42/escpos-php": "^4.0",
"spatie/laravel-permission": "^5.10"
},
"require-dev": {
diff --git a/composer.lock b/composer.lock
index 4545843..66448b3 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "14e9faecb70a51de80bbf489ed9e7322",
+ "content-hash": "78117f62189eddfbc5c660d5c182522c",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -2663,6 +2663,112 @@
},
"time": "2022-12-02T22:17:43+00:00"
},
+ {
+ "name": "mike42/escpos-php",
+ "version": "v4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/mike42/escpos-php.git",
+ "reference": "74fd89a3384135c90a8c6dc4b724e03df7c0e4f9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/mike42/escpos-php/zipball/74fd89a3384135c90a8c6dc4b724e03df7c0e4f9",
+ "reference": "74fd89a3384135c90a8c6dc4b724e03df7c0e4f9",
+ "shasum": ""
+ },
+ "require": {
+ "ext-intl": "*",
+ "ext-json": "*",
+ "ext-zlib": "*",
+ "mike42/gfx-php": "^0.6",
+ "php": ">=7.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9",
+ "squizlabs/php_codesniffer": "^3.3"
+ },
+ "suggest": {
+ "ext-gd": "Used for image printing if present.",
+ "ext-imagick": "Will be used for image printing if present. Required for PDF printing or use of custom fonts."
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Mike42\\": "src/Mike42"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Billington",
+ "email": "michael.billington@gmail.com"
+ }
+ ],
+ "description": "PHP receipt printer library for use with ESC/POS-compatible thermal and impact printers",
+ "homepage": "https://github.com/mike42/escpos-php",
+ "keywords": [
+ "Epson",
+ "barcode",
+ "escpos",
+ "printer",
+ "receipt-printer"
+ ],
+ "support": {
+ "issues": "https://github.com/mike42/escpos-php/issues",
+ "source": "https://github.com/mike42/escpos-php/tree/v4.0"
+ },
+ "time": "2022-05-23T11:05:09+00:00"
+ },
+ {
+ "name": "mike42/gfx-php",
+ "version": "v0.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/mike42/gfx-php.git",
+ "reference": "ed9ded2a9298e4084a9c557ab74a89b71e43dbdb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/mike42/gfx-php/zipball/ed9ded2a9298e4084a9c557ab74a89b71e43dbdb",
+ "reference": "ed9ded2a9298e4084a9c557ab74a89b71e43dbdb",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.0.0"
+ },
+ "require-dev": {
+ "phpbench/phpbench": "@dev",
+ "phpunit/phpunit": "^6.5",
+ "squizlabs/php_codesniffer": "^3.3.1"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Mike42\\": "src/Mike42"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-2.1-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Michael Billington",
+ "email": "michael.billington@gmail.com"
+ }
+ ],
+ "description": "The pure PHP graphics library",
+ "homepage": "https://github.com/mike42/gfx-php",
+ "support": {
+ "issues": "https://github.com/mike42/gfx-php/issues",
+ "source": "https://github.com/mike42/gfx-php/tree/v0.6"
+ },
+ "time": "2019-10-05T02:44:33+00:00"
+ },
{
"name": "mobiledetect/mobiledetectlib",
"version": "2.8.41",
diff --git a/database/migrations/2023_09_18_185246_create_productos_table.php b/database/migrations/2023_09_18_185246_create_productos_table.php
new file mode 100644
index 0000000..0797a06
--- /dev/null
+++ b/database/migrations/2023_09_18_185246_create_productos_table.php
@@ -0,0 +1,32 @@
+id();
+ $table->string('linea',5);
+ $table->string('codigo',50);
+ $table->string('descripcion');
+ // $table->string('prefijo',30);
+ $table->decimal('precio_unitario');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('productos');
+ }
+};
diff --git a/database/migrations/2023_09_18_185619_create_pedidos_table.php b/database/migrations/2023_09_18_185619_create_pedidos_table.php
new file mode 100644
index 0000000..dda730e
--- /dev/null
+++ b/database/migrations/2023_09_18_185619_create_pedidos_table.php
@@ -0,0 +1,55 @@
+id();
+ // Datos del cliente
+ $table->string('pedido',30)->nullable();
+ $table->string('cuenta',20);
+ $table->string('telefono',15);
+ // Datos del auto
+ $table->string('year',4);
+ $table->string('marca',40);
+ $table->string('modelo',40);
+ $table->string('motor',20);
+ // Datos envio del producto
+ $table->string('folio_proveedor')->nullable();
+ $table->string('numero_remision')->nullable();
+
+ $table->boolean('is_venta_cerrada')->nullable();
+ $table->unsignedBigInteger('venta_cerrada_user_id')->nullable();
+ $table->foreign('venta_cerrada_user_id')->references('id')->on('users');
+
+ $table->boolean('is_venta_entregada')->nullable();
+ $table->unsignedBigInteger('venta_entregada_user_id')->nullable();
+ $table->foreign('venta_entregada_user_id')->references('id')->on('users');
+
+
+
+ $table->unsignedBigInteger('user_id');
+ $table->foreign('user_id')->references('id')->on('users');
+
+ $table->timestamp('venta_cerrada_at')->nullable();
+ $table->timestamp('venta_entregada_at')->nullable();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('pedidos');
+ }
+};
diff --git a/database/migrations/2023_09_18_190734_create_producto_pedidos_table.php b/database/migrations/2023_09_18_190734_create_producto_pedidos_table.php
new file mode 100644
index 0000000..9324e2e
--- /dev/null
+++ b/database/migrations/2023_09_18_190734_create_producto_pedidos_table.php
@@ -0,0 +1,36 @@
+id();
+
+ $table->unsignedBigInteger('pedido_id');
+ $table->unsignedBigInteger('producto_id');
+
+ $table->foreign('pedido_id')->references('id')->on('pedidos');
+ $table->foreign('producto_id')->references('id')->on('productos');
+ $table->decimal('unidades');
+ $table->decimal('precio_unitario');
+ $table->boolean('is_arrivo');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('producto_pedidos');
+ }
+};
diff --git a/database/migrations/2023_10_11_172723_create_impresoras_table.php b/database/migrations/2023_10_11_172723_create_impresoras_table.php
new file mode 100644
index 0000000..dc4ffca
--- /dev/null
+++ b/database/migrations/2023_10_11_172723_create_impresoras_table.php
@@ -0,0 +1,30 @@
+id();
+ $table->string('estacion');
+ $table->string('nombre_impresora');
+ $table->boolean('is_compartida');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('impresoras');
+ }
+};
diff --git a/database/migrations/2023_10_11_173349_add_impresora_id_to_users_table.php b/database/migrations/2023_10_11_173349_add_impresora_id_to_users_table.php
new file mode 100644
index 0000000..16e1d82
--- /dev/null
+++ b/database/migrations/2023_10_11_173349_add_impresora_id_to_users_table.php
@@ -0,0 +1,31 @@
+unsignedBigInteger('impresora_id')->nullable();
+ $table->foreign('impresora_id')->references('id')->on('impresoras')->onDelete('set null');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropForeign(['impresora_id']);
+ $table->dropColumn('impresora_id');
+ });
+ }
+};
diff --git a/database/migrations/2023_10_25_191254_add_nota_credito_to_movimientos_table.php b/database/migrations/2023_10_25_191254_add_nota_credito_to_movimientos_table.php
new file mode 100644
index 0000000..265e057
--- /dev/null
+++ b/database/migrations/2023_10_25_191254_add_nota_credito_to_movimientos_table.php
@@ -0,0 +1,29 @@
+float('nota_credito',30)->after('pago_transferencia')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('movimientos', function (Blueprint $table) {
+ //
+ $table->dropColumn('nota_credito');
+ });
+ }
+};
diff --git a/database/migrations/2023_11_22_195005_add_comentarios_to_pedidos_table.php b/database/migrations/2023_11_22_195005_add_comentarios_to_pedidos_table.php
new file mode 100644
index 0000000..c170a51
--- /dev/null
+++ b/database/migrations/2023_11_22_195005_add_comentarios_to_pedidos_table.php
@@ -0,0 +1,29 @@
+string('comentarios')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('pedidos', function (Blueprint $table) {
+ //
+ $table->dropColumn('comentarios');
+ });
+ }
+};
diff --git a/database/migrations/2023_12_19_185943_create_rutas_table.php b/database/migrations/2023_12_19_185943_create_rutas_table.php
new file mode 100644
index 0000000..e46d11f
--- /dev/null
+++ b/database/migrations/2023_12_19_185943_create_rutas_table.php
@@ -0,0 +1,29 @@
+id();
+ $table->string('ruta',50);
+ $table->string('prefijo',10);
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('rutas');
+ }
+};
diff --git a/database/migrations/2024_01_16_204157_add_ruta_id_to_productos_table.php b/database/migrations/2024_01_16_204157_add_ruta_id_to_productos_table.php
new file mode 100644
index 0000000..22941f0
--- /dev/null
+++ b/database/migrations/2024_01_16_204157_add_ruta_id_to_productos_table.php
@@ -0,0 +1,30 @@
+unsignedBigInteger('ruta_id')->after('descripcion');
+ $table->foreign('ruta_id')->references('id')->on('rutas');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('productos', function (Blueprint $table) {
+ //
+ });
+ }
+};
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index 47b2b7b..651441e 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
EstadoCajaMovimientoSeeder::class,
RoleSeeder::class,
UserSeeder::class,
+ GenericSeeder::class,
]);
}
}
diff --git a/database/seeders/GenericSeeder.php b/database/seeders/GenericSeeder.php
new file mode 100644
index 0000000..bf10b0d
--- /dev/null
+++ b/database/seeders/GenericSeeder.php
@@ -0,0 +1,19 @@
+ 'compras']);
+ }
+}
diff --git a/resources/js/app.js b/resources/js/app.js
index 363fb93..f57461e 100644
--- a/resources/js/app.js
+++ b/resources/js/app.js
@@ -7,3 +7,112 @@ window.Alpine = Alpine;
Alpine.plugin(focus);
Alpine.start();
+
+document.addEventListener("DOMContentLoaded", ()=> {
+
+ //estados
+ let inputs = document.querySelectorAll('.input-enter');
+ let inputsProduct = document.querySelectorAll('.input-product');
+ let btnAdd = document.querySelector('#btn-add');
+
+ init();
+
+ function init()
+ {
+ inputEnterInit();
+ inputProductsEvent();
+ addKeyListener();
+ }
+
+
+
+ function inputEnterInit() {
+ inputs.forEach(function(input, index) {
+ input.addEventListener('keydown', function(event) {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault();
+ let nextIndex = index + 1;
+ if (nextIndex < inputs.length) {
+ inputs[nextIndex].focus();
+ }
+ }
+ });
+ });
+ }
+
+ function addKeyListener()
+ {
+ const keysPressed = ['F6','F7','F8','F9'];
+
+ document.addEventListener('keydown',function(event){
+
+ if(!keysPressed.includes(event.key)) return;
+
+ event.preventDefault();
+
+ if(event.key === 'F8' && document.querySelector('#modal-1').checked)
+ {
+ event.preventDefault();
+ Livewire.emit('agregar');
+ }
+ else if(event.key === 'F9' && document.querySelector('#modal-1').checked)
+ {
+ Livewire.emit('save');
+ }
+ else if(event.key === 'F6' && document.querySelector('#modal-2').checked)
+ {
+ event.preventDefault();
+ Livewire.emit('agregar');
+ }
+ else if(event.key === 'F7')
+ {
+ Livewire.emit('cerrarVenta' && document.querySelector('#modal-2').checked);
+ }
+ else if(event.key === 'F8' && document.querySelector('#modal-2').checked)
+ {
+ Livewire.emit('entregarVenta');
+ }
+ else if(event.key === 'F9' && document.querySelector('#modal-2').checked)
+ {
+ Livewire.emit('saveArrivo');
+ }
+ })
+ }
+
+
+ function inputProductsEvent() {
+ inputsProduct.forEach(function(inputProduct, index) {
+ inputProduct.addEventListener('keydown', function(event) {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault();
+ let nextIndex = index + 1;
+ console.log(`nextIndex:${nextIndex} | Length: ${inputs.length}`);
+ if (nextIndex < inputsProduct.length) {
+ inputsProduct[nextIndex].focus();
+ }
+ if( (nextIndex == inputsProduct.length))
+ {
+ btnAdd.click();
+ updateProductsDOM();
+ }
+ }
+ });
+ });
+ }
+
+ function updateListProducts()
+ {
+ inputsProduct[inputsProduct.length-6]?.focus();
+ }
+
+ Livewire.on('addProductEvent',function(){
+ updateProductsDOM();
+ updateListProducts();
+ });
+
+ async function updateProductsDOM()
+ {
+ inputsProduct = document.querySelectorAll('.input-product');
+ inputProductsEvent();
+ }
+});
diff --git a/resources/views/export/reportePedidoExport.blade.php b/resources/views/export/reportePedidoExport.blade.php
new file mode 100644
index 0000000..da26063
--- /dev/null
+++ b/resources/views/export/reportePedidoExport.blade.php
@@ -0,0 +1,52 @@
+
+
+
+ Orden
+ Fecha
+ Cuenta
+ Telefono
+ Liquidado por
+ Creado por
+ Entregado por
+ Cerrado por
+ Comentarios
+
+ Codigo
+ Linea
+ Descripcion
+ Almacen
+ Cantidad
+ ¿Recibido?
+
+
+
+ @foreach ($pedidos as $pedido)
+
+ {{ $pedido->pedido }}
+ {{ $pedido->created_at->format('Y-m-d') }}
+ {{ $pedido->cuenta }}
+ {{ $pedido->telefono }}
+ {{ $pedido->ultimaVentaBy()?->user->name ?? "No Liquidado" }}
+ {{ $pedido->user->name }}
+ {{ $pedido->ventaEntregadaUser?->name ?? "No Entregado" }}
+ {{ $pedido->ventaCerradaUser?->name ?? "No Cerrado" }}
+ {{ $pedido->comentarios }}
+
+
+
+ @foreach ($pedido->productos as $producto)
+
+ {{ $producto->codigo }}
+ {{ $producto->linea }}
+ {{ $producto->descripcion }}
+ {{ $producto->prefijo }}
+ {{ $producto->pivot->unidades }}
+ {{ $producto->pivot->is_arrivo?"Recibido":"No Recibido" }}
+
+ @endforeach
+
+
+
+ @endforeach
+
+
\ No newline at end of file
diff --git a/resources/views/impresora/impresora.blade.php b/resources/views/impresora/impresora.blade.php
new file mode 100644
index 0000000..68cc586
--- /dev/null
+++ b/resources/views/impresora/impresora.blade.php
@@ -0,0 +1,129 @@
+
+
+
+ {{ __('Impresora') }}
+
+
+
+
+
+ Mi impresora
+ Selecciona una impresora para utilizar en tu perfil.
+
+
+ @if (session()->has('messageImpresora'))
+
+
+
{{ session('messageImpresora') }}
+
+ @endif
+
+ Seleciona impresora:
+
+ Selecciona una opción
+ @foreach ($impresoras as $impresora)
+ {{$impresora->estacion}}:{{$impresora->nombre_impresora}}
+ @endforeach
+
+ Guardar Impresora
+
+
+
+
+ Agrega una impresora
+ Puedes agregar una impresora de tu estación local, solo recuerda que para agregar una impresora debes tener la impresora compartida desde la computadora.
+
+
+
+ Agregar Impresora
+
+ @if (session()->has('message'))
+
+
+
{{ session('message') }}
+
+ @endif
+ @if (session()->has('error'))
+
+
+
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+ Estacion / IP
+ Nombre Impresora / Puerto
+ Acciones
+
+
+
+ @forelse ($impresoras as $impresora)
+ {{ $impresora->estacion }}
+ {{ $impresora->nombre_impresora }}
+ @role('admin')
+
+
+
+
+
+
+
+
+ @endrole
+
+ @empty
+
+
+
No hay impresoras registradas en el sistema.
+
+ @endforelse
+
+
+ {{$impresoras->links()}}
+
+
+
+
+
+
+
+
+
+
+
✕
+
+
Agregar Impresora
+
+
+ @error('impresora.estacion')
{{ $message }} @enderror
+
+
+ @error('impresora.nombre_impresora')
{{ $message }} @enderror
+
+
+
+
+ ¿Es impresora compartida?
+
+
+
+ Guardar
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/livewire/ruta-controller.blade.php b/resources/views/livewire/ruta-controller.blade.php
new file mode 100644
index 0000000..bc7718c
--- /dev/null
+++ b/resources/views/livewire/ruta-controller.blade.php
@@ -0,0 +1,3 @@
+
+ {{-- A good traveler has no fixed plans and is not intent upon arriving. --}}
+
diff --git a/resources/views/navigation-menu.blade.php b/resources/views/navigation-menu.blade.php
index 0e7eda2..3bf976f 100644
--- a/resources/views/navigation-menu.blade.php
+++ b/resources/views/navigation-menu.blade.php
@@ -12,7 +12,8 @@
-
+
+ @role('usuario|admin')
{{ __('Dashboard') }}
@@ -25,10 +26,25 @@
{{ __('Cancelacion') }}
- @role('admin')
-
- {{ __('Reporte') }}
+ @endrole
+
+ {{ __('Pedido') }}
+ @role('admin')
+
+ {{ __('Rutas') }}
+
+ @endrole
+ @role('admin|compras')
+
+ Reportes
+
+
+ @endrole
+ @role('admin')
{{ __('Usuarios') }}
@@ -68,6 +84,10 @@
{{ __('Profile') }}
+
+ {{ __('Impresora') }}
+
+
@if (Laravel\Jetstream\Jetstream::hasApiFeatures())
{{ __('API Tokens') }}
diff --git a/resources/views/pedido/pedido.blade copy.php b/resources/views/pedido/pedido.blade copy.php
new file mode 100644
index 0000000..8a333c2
--- /dev/null
+++ b/resources/views/pedido/pedido.blade copy.php
@@ -0,0 +1,484 @@
+
+
+
+
+ {{ __('Pedidos') }}
+
+ Impresora: {{auth()->user()?->impresora?->estacion ?? "Sin Asignar"}}:{{auth()->user()?->impresora?->nombre_impresora}}
+
+
+
+
+
+
+
+
+ @if (session()->has('message'))
+
+
+
{{ session('message') }}
+
+ @endif
+ @if (session()->has('error'))
+
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+ Pedido
+ Cuenta
+ Recibidos
+ Registrado por
+ Entregado por
+ Cerrado por
+ Fecha
+ Acciones
+
+
+
+ @forelse ($pedidos as $pedido)
+ {{ $pedido->pedido }}
+ {{ $pedido->cuenta }}
+ {{-- {{ $pedido->folio_proveedor?$pedido->folio_proveedor:"No asignado" }} --}}
+ {{-- {{ $pedido->year }} {{ $pedido->marca }} {{ $pedido->modelo }} --}}
+ {{ $pedido->productos->where('pivot.is_arrivo', 1)->count()." de ".$pedido->productos->count()." Productos";}}
+ {{ $pedido->user->name }}
+ {{ $pedido->ventaEntregadaUser?->name ?? "Sin Entregar" }}
+ {{ $pedido->ventaCerradaUser?->name ?? "Sin Cerrar" }}
+ {{ $pedido->created_at }}
+
+
+
+
+
+
+
+
+ @role('admin')
+
+
+
+
+ @endrole
+
+ @empty
+
+
+
No hay pedidos registrados en el sistema.
+
+ @endforelse
+
+
+ {{$pedidos->links()}}
+
+
+
+
+
+
+
+
+
+
+
✕
+
+
Registrar Pedido
+
+
Datos del cliente
+
+
+
+
Datos del vehiculo
+
+
+
+
+
+
+
Productos a cotizar
+
+
+
+ @if ($buscadorProducto!="")
+
+ @endif
+
+
+
+
+
+ @foreach ($productos as $key => $producto)
+
+
+
+
+
+ {{--
--}}
+
+ Ruta:
+
+ - Ruta -
+ @foreach ($rutas as $ruta)
+ {{$ruta->prefijo}} - {{ $ruta->ruta }}
+ @endforeach
+
+ @error("productos.{$key}.ruta_id"){{ $message }} @enderror
+
+
+
+
+
+
+
+ @endforeach
+
SubTotal: {{round($totalPagar - $IVA,2)}}
+
IVA 8%: {{round($IVA,2)}}
+
Total a Pagar: {{round($totalPagar,2)}}
+
+
+
Deposito del producto
+
+
+
+
+
+
+ Agregar producto [F8]
+ Guardar [F9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
✕
+
+
Registrar Pedido
+
+
Datos del cliente
+
+
+
+
+
+
Datos del vehiculo
+
+
+
+
+
+
Pedido
+
+
+ @isset($this->pedido)
+ @foreach ($this->pedido->productos as $key => $producto)
+
+
+ @endforeach
+ @endisset
+
SubTotal: {{round($this->totalPagar - $this->IVA,2)}}
+
IVA 8%: {{round($this->IVA,2)}}
+
Total a Pagar: {{round($this->totalPagar,2)}}
+
+
+ @if (!$this->pedido?->is_venta_cerrada)
+ Cerrar Pedido [F7]
+ @endif
+ @if (!$this->pedido?->is_venta_entregada)
+ Entregar Pedido [F8]
+ @endif
+ Guardar Pedido [F9]
+
+
+
+
diff --git a/resources/views/pedido/pedido.blade.php b/resources/views/pedido/pedido.blade.php
new file mode 100644
index 0000000..185a463
--- /dev/null
+++ b/resources/views/pedido/pedido.blade.php
@@ -0,0 +1,517 @@
+
+
+
+
+ {{ __('Pedidos') }}
+
+ Impresora: {{auth()->user()?->impresora?->estacion ?? "Sin Asignar"}}:{{auth()->user()?->impresora?->nombre_impresora}}
+
+
+
+
+
+
+
+
+ @if (session()->has('message'))
+
+
+
{{ session('message') }}
+
+ @endif
+ @if (session()->has('error'))
+
+
+
{{ session('error') }}
+
+ @endif
+
+
+
+
+
+ Pedido
+ Cuenta
+ Recibidos
+ Registrado por
+ Entregado por
+ Cerrado por
+ Fecha
+ Acciones
+
+
+
+ @forelse ($pedidos as $pedido)
+ {{ $pedido->pedido }}
+ {{ $pedido->cuenta }}
+ {{-- {{ $pedido->folio_proveedor?$pedido->folio_proveedor:"No asignado" }} --}}
+ {{-- {{ $pedido->year }} {{ $pedido->marca }} {{ $pedido->modelo }} --}}
+ {{ $pedido->productos->where('pivot.is_arrivo', 1)->count()." de ".$pedido->productos->count()." Productos";}}
+ {{ $pedido->user->name }}
+ {{ $pedido->ventaEntregadaUser?->name ?? "Sin Entregar" }}
+ {{ $pedido->ventaCerradaUser?->name ?? "Sin Cerrar" }}
+ {{ $pedido->created_at }}
+
+
+
+
+
+
+
+
+
+
+
+ @role('admin')
+
+
+
+
+ @endrole
+
+ @empty
+
+
+
No hay pedidos registrados en el sistema.
+
+ @endforelse
+
+
+ {{$pedidos->links()}}
+
+
+
+
+
+
+
+
+
+
+
✕
+
+
Registrar Pedido
+
+
Datos del cliente
+
+
+
+
Datos del vehiculo
+
+
+
+
+
+
+
Productos a cotizar
+
+
+
+ @if ($buscadorProducto!="")
+
+ @endif
+
+
+
+
+
+ @foreach ($productos as $key => $producto)
+
+
+
+
+
+
+ Ruta:
+
+ - Ruta -
+ @foreach ($rutas as $ruta)
+ {{$ruta->prefijo}} - {{ $ruta->ruta }}
+ @endforeach
+
+ @error("productos.{$key}.ruta_id"){{ $message }} @enderror
+
+
+
+
+
+
+
+ @endforeach
+
SubTotal: {{round($totalPagar - $IVA,2)}}
+
IVA 8%: {{round($IVA,2)}}
+
Total a Pagar: {{round($totalPagar,2)}}
+
+
+
Deposito del producto
+
+
+
+
+
+
+ Agregar producto [F8]
+ Guardar [F9]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
✕
+
+
Registrar Pedido
+
+
Datos del cliente
+
+
+
+
+
+
Datos del vehiculo
+
+
+
+
+
+ @role('admin')
+
+
Productos a cotizar
+
+
+
+ @if ($buscadorProducto!="")
+
+ @endif
+
+
+
+ @endrole
+
+
Pedido
+
+
+ @isset($this->pedido)
+ @foreach ($this->productos as $key => $producto)
+
+
+
+
+
+ Ruta:
+
+ - Ruta -
+ @foreach ($rutas as $ruta)
+ {{$ruta->prefijo}} - {{ $ruta->ruta }}
+ @endforeach
+
+ @error("productos.{$key}.ruta_id"){{ $message }} @enderror
+
+
+
+
+ @role('admin')
+
+ @endrole
+
+ @endforeach
+ @endisset
+
SubTotal: {{round($this->totalPagar - $this->IVA,2)}}
+
IVA 8%: {{round($this->IVA,2)}}
+
Total a Pagar: {{round($this->totalPagar,2)}}
+
+
+ @role('admin')
+ Agregar producto [F6]
+ @endrole
+ @if (!$this->pedido?->is_venta_cerrada)
+ Cerrar Pedido [F7]
+ @endif
+ @if (!$this->pedido?->is_venta_entregada)
+ Entregar Pedido [F8]
+ @endif
+ Guardar Pedido [F9]
+
+
+
+
diff --git a/resources/views/pedido/reporte-pedido.blade.php b/resources/views/pedido/reporte-pedido.blade.php
new file mode 100644
index 0000000..009aef4
--- /dev/null
+++ b/resources/views/pedido/reporte-pedido.blade.php
@@ -0,0 +1,100 @@
+
+
+
+ {{ __('Reporte Pedido') }}
+
+
+
+
+
+
+
+
+
+
+
+ ¿Venta Cerrada?
+ Si
+ No
+
+
+ ¿Venta Entregada?
+ Si
+ No
+
+
+
Generar Reporte
+
+
+
+
+
+
+ Orden
+ Fecha
+ Cuenta
+ Telefono
+ Liquidado por
+ Creado por
+ Entregado por
+ Cerrado por
+ Comentarios
+
+ Productos
+
+
+
+ @foreach ($pedidos as $pedido)
+
+ {{ $pedido->pedido }}
+ {{ $pedido->created_at->format('Y-m-d') }}
+ {{ $pedido->cuenta }}
+ {{ $pedido->telefono }}
+ {{ $pedido->ultimaVentaBy()?->user->name ?? "No Liquidado" }}
+ {{ $pedido->user->name }}
+ {{ $pedido->ventaEntregadaUser?->name ?? "No Entregado" }}
+ {{ $pedido->ventaCerradaUser?->name ?? "No Cerrado" }}
+ {{ $pedido->comentarios }}
+
+
+
+ Codigo
+ Linea
+ Descripcion
+ Almacen
+ Cantidad
+ ¿Recibido?
+
+ @foreach ($pedido->productos as $producto)
+
+ {{ $producto->codigo }}
+ {{ $producto->linea }}
+ {{ $producto->descripcion }}
+ {{ $producto->prefijo }}
+ {{ $producto->pivot->unidades }}
+ {{ $producto->pivot->is_arrivo?"Recibido":"No Recibido" }}
+
+ @endforeach
+
+
+
+ @endforeach
+
+
+
+
+
+
+
diff --git a/resources/views/ruta/ruta.blade.php b/resources/views/ruta/ruta.blade.php
new file mode 100644
index 0000000..2d31a96
--- /dev/null
+++ b/resources/views/ruta/ruta.blade.php
@@ -0,0 +1,95 @@
+
+
+
+ {{ __('Rutas') }}
+
+
+
+
+
+
+
+ @if (session()->has('message'))
+
+
+
{{ session('message') }}
+
+ @endif
+
+
+
+
+
+ Nombre Ruta
+ Prefijo
+ Fecha
+ @role('admin')Acciones @endrole
+
+
+
+ @forelse ($rutas as $ruta)
+ {{ $ruta->ruta }}
+ {{ $ruta->prefijo }}
+ {{ $ruta->created_at }}
+ @role('admin')
+
+ Editar
+ Eliminar
+
+ @endrole
+
+ @empty
+ {{$rutas->links()}}
+
+
+
No hay rutas registradas en el sistema.
+
+ @endforelse
+
+
+ {{$rutas->links()}}
+
+
+
+
+
+
+
+
+
+
+
✕
+
+
Registrar Ruta
+
+
+ @error('ruta.ruta')
{{ $message }} @enderror
+
+
+ @error('ruta.prefijo')
{{ $message }} @enderror
+
+
+
+ Guardar
+
+
+
+
diff --git a/resources/views/venta/cancelacion.blade.php b/resources/views/venta/cancelacion.blade.php
index 597df99..91c67e4 100644
--- a/resources/views/venta/cancelacion.blade.php
+++ b/resources/views/venta/cancelacion.blade.php
@@ -44,7 +44,12 @@
{{$cancelacion->motivo}}
{{$cancelacion->user->name}}
{{$cancelacion->created_at}}
- @role('admin') Eliminar @endrole
+ @role('admin')
+
+ Editar Fecha
+ Eliminar
+
+ @endrole
@empty
@@ -72,7 +77,7 @@
@error('cancelacion.codigo')
{{ $message }} @enderror
@@ -80,7 +85,7 @@
@error('cancelacion.pago_efectivo')
{{ $message }} @enderror
@@ -89,7 +94,7 @@
Motivo:
{{-- --}}
-
+
@error('cancelacion.motivo'){{ $message }} @enderror
@@ -99,4 +104,26 @@
+
+
+
+
+
+
✕
+
+
Cambiar Fecha de Cancelacion
+
+
+ @error('created_at')
{{ $message }} @enderror
+
+
+ Guardar
+
+
+
diff --git a/resources/views/venta/venta-especial.blade.php b/resources/views/venta/venta-especial.blade.php
index 2d127f8..6542b91 100644
--- a/resources/views/venta/venta-especial.blade.php
+++ b/resources/views/venta/venta-especial.blade.php
@@ -33,6 +33,7 @@
Pago Efectivo
Pago Tarjeta
Pago Tarjeta Vales
+ Pago Nota Credito
Pago Transferencia
Total a pagar
Registrado por
@@ -46,6 +47,7 @@
{{ $venta->pago_efectivo }}
{{ $venta->pago_tarjeta }}
{{ $venta->pago_vales }}
+ {{ $venta->nota_credito }}
{{ $venta->pago_transferencia }}
{{ $venta->precio_venta }}
{{ $venta->user->name }}
@@ -56,7 +58,10 @@
@else
Liquidar
@endif
- @role('admin') Eliminar @endrole
+ @role('admin')
+ Editar Fecha
+ Eliminar
+ @endrole
@@ -86,7 +91,7 @@
@error('ventaEspecial.codigo'){{ $message }} @enderror
@@ -94,7 +99,7 @@
@error('ventaEspecial.precio_venta'){{ $message }} @enderror
@@ -102,7 +107,7 @@
@error('ventaEspecial.pago_efectivo'){{ $message }} @enderror
@@ -110,7 +115,7 @@
@error('ventaEspecial.pago_tarjeta'){{ $message }} @enderror
@@ -118,7 +123,7 @@
@error('ventaEspecial.pago_transferencia'){{ $message }} @enderror
@@ -126,11 +131,19 @@
@error('ventaEspecial.pago_vales'){{ $message }} @enderror
+
+ @error('ventaEspecial.nota_credito'){{ $message }} @enderror
+
Guardar
@@ -157,7 +170,7 @@
@error('ventaEspecial.codigo'){{ $message }} @enderror
@@ -165,7 +178,7 @@
@error('ventaEspecial.pago_efectivo'){{ $message }} @enderror
@@ -173,7 +186,7 @@
@error('ventaEspecial.pago_tarjeta'){{ $message }} @enderror
@@ -181,7 +194,7 @@
@error('ventaEspecial.pago_transferencia'){{ $message }} @enderror
@@ -189,15 +202,23 @@
@error('ventaEspecial.pago_vales'){{ $message }} @enderror
+
+ @error('ventaEspecial.nota_credito'){{ $message }} @enderror
+
@error('ventaEspecial.precio_venta'){{ $message }} @enderror
@@ -213,4 +234,25 @@
+
+
+
+
+
✕
+
+
Cambiar Fecha de Venta Especial
+
+
+ @error('created_at')
{{ $message }} @enderror
+
+
+ Guardar
+
+
+
diff --git a/resources/views/venta/venta.blade.php b/resources/views/venta/venta.blade.php
index b107f77..68c04da 100644
--- a/resources/views/venta/venta.blade.php
+++ b/resources/views/venta/venta.blade.php
@@ -32,6 +32,7 @@
Pago Efectivo
Pago Tarjeta
Pago Tarjeta Vales
+ Pago Nota Credito
Pago Transferencia
Total Venta
Registrado por
@@ -45,11 +46,17 @@
{{ $venta->pago_efectivo }}
{{ $venta->pago_tarjeta }}
{{ $venta->pago_vales }}
+ {{ $venta->nota_credito }}
{{ $venta->pago_transferencia }}
{{ $venta->precio_venta }}
{{ $venta->user->name }}
{{ $venta->created_at }}
- @role('admin') Eliminar @endrole
+ @role('admin')
+
+ Editar Fecha
+ Eliminar
+
+ @endrole
@empty
{{$ventas->links()}}
@@ -82,7 +89,7 @@
@error('venta.codigo'){{ $message }} @enderror
@@ -90,7 +97,7 @@
@error('venta.precio_venta'){{ $message }} @enderror
@@ -98,7 +105,7 @@
@error('venta.pago_efectivo'){{ $message }} @enderror
@@ -106,7 +113,7 @@
@error('venta.pago_tarjeta'){{ $message }} @enderror
@@ -114,7 +121,7 @@
@error('venta.pago_transferencia'){{ $message }} @enderror
@@ -122,18 +129,49 @@
@error('venta.pago_vales'){{ $message }} @enderror
+
+
+ @error('venta.nota_credito'){{ $message }} @enderror
@if (session()->has('error'))
{{ session('error') }}
@endif
- Guardar
+ Guardar
+
+
+
+
+
+
✕
+
+
Cambiar Fecha de Venta
+
+
+ @error('created_at')
{{ $message }} @enderror
+
+
+ Guardar
+
+
+
+
diff --git a/routes/web.php b/routes/web.php
index ee767d2..8c410eb 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -2,7 +2,11 @@
use App\Http\Livewire\CancelacionController;
use App\Http\Livewire\DashboardController;
+use App\Http\Livewire\ImpresoraController;
+use App\Http\Livewire\PedidoController;
use App\Http\Livewire\ReporteController;
+use App\Http\Livewire\ReportePedidoController;
+use App\Http\Livewire\RutaController;
use App\Http\Livewire\UserController;
use App\Http\Livewire\VentaController;
use App\Http\Livewire\VentaEspecialController;
@@ -35,6 +39,8 @@ Route::middleware([
Route::get('/venta',VentaController::class)->name('venta');
Route::get('/venta-especial',VentaEspecialController::class)->name('venta-especial');
Route::get('/cancelacion',CancelacionController::class)->name('cancelacion');
+ Route::get('/pedido',PedidoController::class)->name('pedido');
+ Route::get('/configuracion-impresora',ImpresoraController::class)->name('impresora');
});
Route::middleware([
@@ -50,6 +56,16 @@ Route::middleware([
'role:admin'
])->group(function(){
- Route::get('/reporte',ReporteController::class)->name('reporte');
+ Route::get('/reporte-ventas',ReporteController::class)->name('reporte-ventas');
+ Route::get('/rutas',RutaController::class)->name('rutas');
Route::get('/usuarios',UserController::class)->name('usuarios');
});
+
+Route::middleware([
+ 'auth:sanctum',
+ config('jetstream.auth_session'),
+ 'verified',
+ 'role:admin|compras'
+])->group(function(){
+ Route::get('/reporte-pedidos',ReportePedidoController::class)->name('reporte-pedidos');
+});
\ No newline at end of file