Overview
The client management system maintains customer records, tracks service history, manages loyalty points, and enables quick client lookup during service creation and sales.Prerequisites
- Permission:
clientes.ver(View Clients) - Active user account
Viewing Clients
const filtrados = items.filter((c) => {
return (
(c.nombre || "").toLowerCase().includes(searchTerm) ||
(c.telefono || "").toString().includes(searchTerm)
);
});
Client Data Structure
src/js/services/clientes_firestore.js
Creating Clients
Clients are typically created automatically through two workflows:1. During Service Creation
const nuevo = await crearCliente({
nombre: form.nombre,
telefono: form.telefono,
direccion: form.direccion,
numeroSeriePreferido: form.omitirNumeroSerie ? "" : form.numeroSerie,
omitirNumeroSerie: !!form.omitirNumeroSerie,
});
clienteIdFinal = nuevo.id;
2. During POS Sales
When entering customer phone number in POS:Client Search & Matching
Fuzzy Name Search
The system uses Levenshtein distance for smart matching:- Triggered after 300ms debounce
- Minimum 3 characters required
- Fetches up to 50 recent clients
- Returns top 8 matches by similarity score
- Normalizes text (removes accents, lowercase)
src/pages/Hoja_service.jsx:164-201
Phone Number Lookup
Phone lookup is exact match only. Ensure consistent formatting (10 digits, no spaces or dashes).
Client Details Page
The detail view (/clientes/{id}) displays:
- Contact Information: Name, phone, address
- Service History: All services linked to this client
- Loyalty Points: Current balance and transaction history
- Quick Actions: Create new service for this client
Prefilling Service Form
From client detail, click “Nuevo Servicio” to:src/pages/Hoja_service.jsx:115-141
Loyalty Points System
Earning Points
Customers earn points on every POS sale:Redeeming Points
During POS checkout:- Customer is linked by phone
- Cashier checks “Usar Puntos”
- Points apply as 1:1 discount (1 point = $1)
- Cannot exceed subtotal amount
Serial Number Preferences
Clients can have saved serial number preferences:- numeroSeriePreferido: Last serial number used for services
- omitirNumeroSerie: Boolean flag if client prefers to skip serial entry
Service History Linking
Querying Client Services
Service-to-Client Relationship
Every service stores aclienteId reference:
- Client detail page to show all their services
- Service pages to link back to client
- Reporting by customer
- Revenue tracking per client
Best Practices
Always Search First
Use the fuzzy search before creating services to find existing clients and avoid duplicates.
Keep Phone Numbers Clean
Store phone numbers as 10 digits without formatting for consistent lookup.
Update Contact Info
Client records update automatically when creating services, keeping data current.
Promote Loyalty Points
Inform customers about points during checkout to encourage return visits.
Data Privacy
Client records contain personal information (name, phone, address). Ensure your team follows appropriate data protection practices and only accesses client data when necessary for business operations.
Troubleshooting
Client not appearing in search?- Verify they exist in the database
- Try searching by phone number instead of name
- Check for typos or alternative spellings
- Search is limited to 50 most recent clients
- This happens when technicians don’t use the search/suggestion feature
- Manually merge by updating all services to reference the correct
clienteId - Consider adding a duplicate detection report
- Check sales history for the client
- Verify points were properly applied/deducted in each transaction
- Points are cumulative: +earned on sales, -redeemed when used
- Confirm service has correct
clienteIdfield - Old services might only have phone/name without clienteId
- Consider data migration script to link legacy services
Related Workflows
- Creating Service Tickets - Client creation during service intake
- Processing Sales - Loyalty points in POS
- Permissions & Roles - Understanding the
clientes.verpermission
