Overview
The Sale (Venta) model represents a completed transaction in the Luis IT Repair POS system. It captures the full transaction details including items sold, payment methods, tax calculations, and loyalty point redemption/earning.Firestore Collection
Collection Name:ventas
Core Fields
Sale document ID, automatically generated by Firestore.
Transaction date and time.
Customer phone number if provided. Links to customer loyalty account.
Financial Details
Sum of all items before discounts and tax.Calculation:
Σ (producto.precioVenta * producto.cantidad)Manual discount amount applied by cashier.
Discount from redeemed loyalty points. Typically 1 point = 1 peso.
Whether sales tax (IVA) was applied to this transaction.Note: Configurable per transaction based on POS settings.
Tax rate applied (e.g.,
0.16 for 16% IVA).Calculated tax amount.Calculation:
(subtotal - descuentoManual - descuentoPuntos) * ivaPorcentajeFinal transaction amount.Calculation:
subtotal - descuentoManual - descuentoPuntos + ivaPayment Information
Primary payment method.Possible values:
efectivo- Cashtarjeta- Credit/debit cardtransferencia- Bank transfermixto- Multiple payment methods
Detailed breakdown of payment by method. Used for end-of-day reconciliation.
Loyalty Program
Loyalty points earned from this transaction.Calculation Logic:
- Only products with
generaPuntos: truecontribute - Typically 1 point per peso spent
- Points awarded to customer account after sale completion
Items Sold
Array of items included in the transaction. Each item contains:
Example JSON
Simple Product Sale
Service Delivery Sale
Mixed Sale (Products + Service)
Related Functions
registrarVenta()- Create new sale recorddescontarStock()- Update product inventory after salesumarPuntosCliente()- Award/redeem loyalty pointsimprimirTicketVenta()- Generate receipt
Transaction Flow
- Item Selection - Build cart with products/services
- Client Lookup - Optional phone number for loyalty
- Discount Application - Manual + points redemption
- Tax Calculation - Apply IVA if enabled
- Payment Processing - Record method(s) and amounts
- Inventory Update - Deduct stock for sold products
- Loyalty Update - Award/redeem points
- Service Update - Mark services as
entregadoandcobradoEnPOS - Receipt Generation - Print transaction details
End-of-Day Reconciliation
Sales data is used in cash register close-out reports (cortes_caja):
Analytics & Reports
Sales records enable business intelligence queries:- Daily Revenue: Sum
totalgrouped by date - Payment Mix: Aggregate
pagoDetalleamounts - Top Products: Count/sum by product ID
- Customer Frequency: Count sales by
clienteTelefono - Tax Reporting: Sum
ivafor tax filings - Discount Analysis: Track
descuentoManualanddescuentoPuntos
