Overview
The Product model represents inventory items in the Luis IT Repair system. Products can be physical goods, parts/refacciones, or billable services. The model includes pricing, stock tracking, and barcode support.Firestore Collection
Collection Name:productos
Core Fields
Product document ID. Stored redundantly in the document itself for convenience.
Product name or description.
Barcode or SKU for product identification. Must be unique across all products.Note: The system normalizes codes (trim + lowercase) for duplicate checking.
Product category for organization and filtering (e.g., “Accesorios”, “Cables”, “Pantallas”).
Product classification.Possible values:
producto- Physical goods for salerefaccion- Parts/components for repairsservicio- Billable service items
Pricing
Wholesale/purchase cost per unit. Used for margin calculation.
Retail sale price per unit (before tax).
Margin Calculation
Profit margin is calculated as:precioCompra = 100 and precioVenta = 150, margin = 50%
Inventory Management
Current available quantity. Automatically decremented on sales.
Minimum stock threshold for low-inventory alerts.
Additional Fields
Compatibility notes (e.g., “Compatible con iPhone 11/12/13”).
Whether this product generates loyalty points when purchased.Typical Rule: If true, customer earns 1 point per peso spent.
Product availability status. Inactive products are hidden from POS but remain in inventory.
Stock Adjustment Rules
Automatic Deduction
Stock is automatically decremented when:- POS Sale - Product sold directly through POS
- Service Delivery - Service with boleta (parts list) is marked as delivered
Boleta Integration
When a service ticket includes parts (boleta), stock is reserved but not deducted until:- Service status changes to “entregado” (delivered)
- Service is paid through POS
- System sets
boletaStockAjustado: trueto prevent duplicate deductions
Example JSON
Example: Service Part
Related Functions
Product Management
obtenerProductos()- Fetch all productscrearProducto()- Create new product (auto-generates document ID)actualizarProducto()- Update product detailseliminarProductoDB()- Delete product
POS Operations
descontarStock()- Manually adjust stock quantitybuscarClientePorTelefono()- Client lookup for loyalty pointssumarPuntosCliente()- Award points from purchaseregistrarVenta()- Record sale transaction
Usage Example
Code Validation
The system enforces unique barcode codes:Low Stock Alerts
Products withstock <= stockMinimo should trigger low-inventory alerts in the UI. Implement monitoring with:
