Commit Graph

172 Commits

Author SHA1 Message Date
e00dce7d5a feat(pos): add gunicorn, marketplace B2B, and subscription billing (#7, #8, #12)
- Gunicorn production server with auto-scaled workers, run.sh, updated systemd service
- Marketplace B2B: cross-tenant inventory search, ordering, seller management with full UI
- Subscription billing: plan limits enforced on products/employees/branches, billing API + upgrade flow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:17:33 +00:00
ecdc3526a6 feat(pos): add real thermal ticket printing via ESC/POS (#21)
- Add thermal_printer.py service generating raw ESC/POS bytes for 58mm/80mm printers
- Add /pos/api/sales/<id>/print endpoint (escpos_raw or browser mode)
- Add printer.js with WebUSB and Web Serial support for direct browser-to-printer
- Add thermal print button in ticket modal with connect/print workflow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:16:44 +00:00
f9589f4a4e feat(pos): add inventory-aware chat context (#31) and VIN decoder (#17)
Chat now fetches tenant inventory summary (brands, counts, low-stock)
and injects it into the AI system prompt so responses prioritize local
stock. VIN decoder uses free NHTSA vPIC API to decode 17-char VINs and
auto-fills the vehicle selector dropdowns when a catalog match is found.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:14:45 +00:00
5d5a2777eb feat(pos): add 3 improvements — Spanish translations, PDF quotes, push notifications
1. Spanish translations for TecDoc catalog (translations.py) applied to
   catalog_service.py and dashboard server.py endpoints
2. Printable quotation HTML endpoint (/pos/api/quotations/<id>/pdf) with
   @media print CSS for clean browser-to-PDF output
3. Web Push notifications to owner/admin on sale cancellation, stock zero,
   and cash register differences > $500. Includes service worker, VAPID
   key management, and subscription endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:05:11 +00:00
c61e58ac6a feat(pos): add 5 quick improvements — dark mode, email quotes, barcode scan, returns, offline catalog
1. Auto dark mode: detect system prefers-color-scheme, auto-switch industrial/modern theme
2. Email quotation endpoint: POST /quotations/:id/email sends HTML email via SMTP
3. Camera barcode scanner: BarcodeDetector API with getUserMedia overlay in catalog
4. Returns with warranty: POST /returns endpoint with stock restoration and sale status tracking
5. Partial offline catalog: cache top 500 parts in IndexedDB, search when offline

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:03:28 +00:00
39f2aaf98f feat(pos/chat): add 4 AI chatbot improvements — symptom diagnosis, smart quotes, photo ID, multilanguage
1. Symptom diagnosis: AI now detects vehicle symptoms and suggests probable parts
2. Smart quotations: "cotizame frenos completos" returns multiple search_queries (pipe-separated), backend searches each term and deduplicates
3. Photo identification: camera button in chat widget uploads image and sends placeholder prompt (ready for vision model)
4. Multilanguage: AI detects user language and responds accordingly, search_query always in English

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:00:41 +00:00
fd31864cea feat(pos): APK Android generado — Nexus POS app instalable
Build debug APK (8.3MB) con Capacitor + Android SDK 34.
Carga desde nexus.consultoria-as.com/pos con PWA offline.
Incluye plugins: camera, push notifications, haptics, status bar.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 03:06:04 +00:00
2463c2fbcf feat(pos): Capacitor mobile app setup — Android + iOS wrapper
Set up Capacitor to wrap the Nexus POS web app as a native mobile app.
The app loads from the remote server URL so no bundling is needed.
Includes native-bridge.js for camera, push notifications, haptics,
and status bar integration when running inside the native shell.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:51:07 +00:00
db5bbf6718 feat(pos): fleet management module — vehicles, maintenance schedules, alerts
Add full fleet management (Feature 13): database migration for fleet_vehicles,
fleet_maintenance_schedules, and fleet_maintenance_logs tables; REST API blueprint
with CRUD, scheduling, logging, alerts, and stats endpoints; frontend with tabbed
UI (vehicles grid, maintenance schedules, history, overdue alerts); sidebar nav entry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:43:26 +00:00
c645bc03f3 feat(pos): WhatsApp Business API integration — send/receive messages, quotations
Add full WhatsApp Cloud API integration for Nexus POS:
- Service layer (whatsapp_service.py): send text, templates, quotations,
  order confirmations, stock alerts; process incoming webhooks with AI auto-reply
- Blueprint (whatsapp_bp.py): public webhook endpoints for Meta verification +
  incoming messages; authenticated endpoints for send, send-quote, conversations
- Conversation UI (whatsapp.html + whatsapp.js): split-panel messenger with
  conversation list, chat bubbles, send input, quote sending; both themes
- Migration v1.4: whatsapp_messages table with phone/direction/status indexes
- Config: WHATSAPP_TOKEN, WHATSAPP_PHONE_ID, WHATSAPP_VERIFY_TOKEN env vars
- Sidebar: WhatsApp nav item under Gestion with message-bubble icon
- Ready for Meta Business credentials (infrastructure complete, no API keys needed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:42:17 +00:00
840790a4d0 feat(pos): sistema de imagenes — upload, thumbnail, display en inventario y catalogo
- Add POST/DELETE /items/{id}/image endpoints with Pillow processing (resize 800px, thumbnail 300px, JPEG 85%)
- Validate file type (jpg/png/webp) and size (max 5MB)
- Show image in product detail modal with upload/delete buttons
- Enrich catalog parts list with local inventory image when available
- Image directory created automatically on first upload (pos/static/images/parts/)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:34:01 +00:00
9702cdc9cc feat(pos): entrada por voz en chatbot — Web Speech API es-MX
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:28:47 +00:00
6676e5cb4c docs: design specs for WhatsApp, images, fleet, voice AI, mobile app
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:25:24 +00:00
31bfd0064e feat(pos): reportes funcionales — ventas, inventario, ABC, cortes de caja
Replace static demo data with live API calls across all four report tabs:
- Ventas: sales by period/employee/payment method with date filters
- Inventario: valuation, ABC classification, low stock, no movement
- Clientes: accounts receivable aging report
- Financieros: income statement, balance sheet, trial balance, register history

All tabs use lazy loading (fetch on first visit) and JWT auth.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:20:41 +00:00
f55925fa6a feat(pos): dashboard funcional con datos reales — ventas, alertas, cajas
Replace all hardcoded/demo data with live API calls:
- KPIs from /pos/api/register/daily-summary (ventas, tickets, promedio, cajas)
- Inventory alerts from /pos/api/inventory/alerts (zero, low, over stock)
- Top products aggregated from /pos/api/sales detail items
- Weekly bar chart from 7-day daily summaries
- Recent sales table with real items from sale detail endpoint
- Auto-refresh every 2 minutes, manual refresh button
- Dynamic greeting with time-of-day and JWT user name

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:17:02 +00:00
cc2336ca06 feat(pos): configuracion funcional — sucursales, empleados, tema
Replace hardcoded demo data in the config page with real API calls.
Branches and employees now load from /pos/api/config/* endpoints,
with create modals for both. Business data tab reads tenant_config
(read-only). Theme selector was already working and is preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:15:24 +00:00
f85e53cee8 feat(pos): onboarding wizard para nuevos tenants
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:15:01 +00:00
29174c9108 fix(pos): fix proxy Content-Type forwarding and SW auth caching
Proxy was using resp.raw.headers (urllib3) which could miss Content-Type;
switched to resp.headers. SW now skips /pos/api/auth/ to prevent stale
token caching, scopes fetch to /pos/ only, and bumps cache to v2.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 02:13:36 +00:00
8539720645 fix(pos): retry con backoff para rate limit 429 de OpenRouter
3 reintentos con espera 5s/10s/15s. Si agota reintentos,
muestra mensaje amigable en vez de error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 19:48:13 +00:00
d32de87d5f feat: proxy reverso POS desde puerto 5000 — accesible via Cloudflare
El servidor principal proxea /pos/* al POS en puerto 5001.
Elimina la necesidad de exponer puerto 5001 a internet.
Botones "Acceder al POS" en landing ahora usan /pos/login (mismo dominio).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 19:43:34 +00:00
b5d13c1f04 fix: corregir class duplicado en botones POS de landing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:58:40 +00:00
ff9bb87aa9 fix: corregir enlace al POS desde landing page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:34:59 +00:00
9f4e8bc290 feat: enlace al POS desde landing page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:32:19 +00:00
f85de24bf7 fix(pos): boton atras del navegador navega dentro del catalogo
Manejo de historial con pushState/popState. Cada nivel de navegacion
se registra en el historial del navegador. El boton atras regresa al
nivel anterior en vez de salir del catalogo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:29:15 +00:00
fa6f713b7d fix(pos): corregir model ID — qwen/qwen3.6-plus-preview:free
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:25:12 +00:00
0f979b7912 feat(pos): parsear nombres de modelos — solo nombre primario visible
Remueve codigos de generacion, numeros romanos, tipos de carroceria.
Deduplica por display_name. Toyota: 236 → 73 modelos limpios.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:23:31 +00:00
d1093ab9a2 fix(pos): corregir error 'state is not defined' y favicon 404
- catalog.js: state → nav (variable correcta del catalogo)
- vsClearAll: resetea nav en vez de state inexistente
- favicon.ico: sirve icon-192.png del PWA

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:18:13 +00:00
1547b35b14 feat(pos): scroll automatico al catalogo al seleccionar motor
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:15:35 +00:00
97704fd804 feat(pos): filtrar modelos a solo Norteamerica — elimina modelos de otros mercados
Lista de modelos por marca para Mexico/USA/Canada (36 marcas).
Toyota: 625 → 236, Nissan: 499 → 138, Ford: 288 → 114,
Chevrolet: 470 → 207, VW: 283 → 143, Honda: 223 → 117.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:12:02 +00:00
10e318bfd7 feat: dropdown filtra marcas y modelos por ano seleccionado
Al seleccionar ano, solo muestra marcas/modelos disponibles para ese ano.
Toyota 2020: 92 modelos vs 625 sin filtro.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:06:34 +00:00
67e214db15 fix(pos): bloquear modelos de pago — solo modelos :free permitidos
Validacion _validate_model() verifica que el modelo termine en ':free'.
Si alguien cambia MODEL a uno de pago, el chatbot lanza error en vez
de generar costos. Alternativas documentadas en comentario.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:02:10 +00:00
f30a782feb feat(pos): cambiar modelo de chatbot a Qwen 3.6 Plus Preview (free)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:00:43 +00:00
10d5b62e00 feat(pos): selector de vehiculo con dropdowns — Ano > Marca > Modelo > Motor
Barra de 4 dropdowns arriba del catalogo que se habilitan en cascada.
Al completar los 4, muestra categorias y partes para ese vehiculo.
Boton de limpiar para resetear. Endpoint /years-all para cargar anos.
Estilos con design system tokens (ambos temas).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:59:50 +00:00
1a770999f5 feat(pos): chatbot busca en inventario local + catalogo TecDoc
El chatbot ahora busca primero en el inventario local del tenant
y luego en el catalogo TecDoc. Resultados muestran badge:
- Verde "MI INVENTARIO" para partes locales
- Azul "CATALOGO" para partes del catalogo TecDoc
Busqueda local funciona en español e inglés.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:46:08 +00:00
77e45bdc1e feat(pos): cross-references en detalle de producto de inventario
Al abrir el detalle de un producto, se cargan automaticamente:
- Disponibilidad en bodegas (stock + precio)
- Partes equivalentes aftermarket (cross-references del catalogo TecDoc)
Usa catalog_part_id o busqueda por part_number contra el catalogo central.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:41:58 +00:00
b5d62c2812 fix(pos): chatbot busca partes automaticamente con traduccion ES→EN
- System prompt: SIEMPRE devuelve search_query en ingles
- Diccionario de traducciones (balatas→Brake Pad, etc.)
- Busca directo sin preguntar mas info
- Fallback: extrae keywords si AI no da search_query

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:39:47 +00:00
9908c045c9 fix(pos): chatbot — mover boton arriba del carrito, fondo opaco, variables CSS
- FAB movido a bottom:140px (arriba del carrito)
- Panel a bottom:200px
- Fondo usa --color-bg-elevated (opaco, no transparente)
- Bubbles usan --color-surface-2 con fallback
- Variables CSS inexistentes reemplazadas con equivalentes de tokens.css

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:33:34 +00:00
230407b750 fix(pos): eliminar redirect a nexusautoparts.com en subdomain middleware
Subdominio desconocido ya no redirige a dominio externo. En su lugar,
continua sin tenant y el login pide el tenant manualmente.
Agregados 'nexus', 'pos', 'app', 'dashboard' a subdominios reservados.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:30:32 +00:00
0a44fb5304 feat(pos): chatbot IA con OpenRouter — busqueda de partes por lenguaje natural
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:18:55 +00:00
32581739ad feat(pos): PWA con Service Worker + sync offline
- Add manifest.json, sw.js with cache-first/network-first strategies
- Add sync-engine.js with IndexedDB queue for offline operations
- Add /pos/api/sync/inventory endpoint for offline inventory cache
- Add /pos/sw.js route for proper SW scope registration
- Generate PWA icons (192x192, 512x512)
- Update all 10 HTML templates with manifest link, theme-color meta,
  SW registration, and sync-engine script

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:18:01 +00:00
6628f2deef feat: subdomain routing por tenant — refac-xxx.nexusautoparts.com
- Nginx wildcard config: *.nexusautoparts.com routes to POS app with X-Tenant-Subdomain header
- middleware_tenant.py: resolves subdomain -> tenant_id via nexus_master.tenants.subdomain
- auth_bp: login and employee list endpoints accept tenant from subdomain, URL param, or body
- login.html: auto-detects tenant from subdomain, shows business name, falls back to ?tenant=ID
- tenant_manager: generates subdomain slug from business name on provision_tenant()
- Migration v1.2: adds subdomain column + unique index to tenants table
- setup-nginx.sh: one-command install script for the nginx config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:16:49 +00:00
bdbbc78a15 feat: script de instalacion automatizado para Debian/Ubuntu/RPi
Adds install.sh and uninstall.sh for one-command deployment of Nexus POS
on Debian 12+, Ubuntu 22.04+, and Raspberry Pi OS. The installer handles
PostgreSQL setup, tenant provisioning, systemd service, and nginx reverse
proxy with interactive business configuration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 07:15:06 +00:00
fa7015e642 docs: documentacion completa — README, guia de uso, instalacion, API POS
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 03:38:10 +00:00
a389228048 feat: selector de region en catalogo publico (MX/USA/CA, Europa, Asia, Todos)
Filtra marcas por mercado regional. 4 opciones:
- Mexico/USA/Canada (36 marcas)
- Europa (27 marcas)
- Asia (15 marcas)
- Todos (546 marcas)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 23:33:43 +00:00
989a178143 feat: rebuild web — landing page + catalogo publico con navegacion por vehiculo
Removidas paginas viejas (demo, tienda, admin, pos, captura, cuentas).
Nueva landing page con estilo del design system (tokens.css, 2 temas).
Catalogo publico sin auth con navegacion Marca>Modelo>Ano>Motor>Categoria>Partes.
Endpoints /api/catalog/* publicos con filtro NORTH_AMERICA_BRANDS (36 marcas).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 23:21:45 +00:00
e7376ddaed fix(pos): wire buttons in contabilidad, facturacion, inventario, dashboard
- Contabilidad: Nueva Poliza modal + Exportar placeholder
- Facturacion: Nueva Factura modal (sale_id input) + Nota Credito placeholder
- Inventario: click en producto abre detalle con historial
- Dashboard: Ver Detalles navega a paginas relevantes, campana a alertas

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 22:36:49 +00:00
a74fe94187 feat(pos): filtrar marcas a solo Mexico/USA/Canada (36 marcas)
Eliminadas marcas de otros mercados (China, Australia, etc.)
Solo se muestran las relevantes para Norteamerica.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 22:21:52 +00:00
d5569d0cb6 perf(pos): eliminar JOIN vehicle_parts de queries de navegacion
vehicle_parts tiene 14B+ rows. Las queries de brands, models, years,
engines ahora solo usan model_year_engine (mucho mas rapido).
vehicle_parts solo se consulta para categories/groups/parts donde
se filtra por un mye_id especifico.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 22:16:31 +00:00
a3abb6d3a8 fix(pos): restaurar catalog_service.py real (sobreescrito por stub)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 22:10:55 +00:00
41a96ec1a4 feat(pos): rewrite catalog UI — vehicle hierarchy navigation with detail panel
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 21:49:35 +00:00