Overview
The Sales module is your point-of-sale (POS) interface for processing customer transactions. It provides a streamlined workflow for adding products, selecting payment methods, and completing sales with automatic inventory updates.Accessing the Sales Interface
Navigate to Venta (Sales) or Nueva Venta (New Sale) from the main menu to access the POS interface.Sales Interface Layout
The sales screen is organized into functional sections:Product Selection
Top Section
- Autocomplete product search
- Quantity input
- Add button
Payment Options
Right Section
- Payment method selector (Efectivo/Tarjeta)
- Running total display
Cart/Order List
Middle Section
- Products added to sale
- Quantities and line totals
- Remove items option
Complete Sale
Bottom Section
- Register sale button
- Enabled only when cart has items
Processing a Sale
Search for Product
Start typing in the Producto (Product) field. The autocomplete feature displays matching products as you type.
- Only active products with stock > 0 appear in results
- Search by product name
- Dropdown shows available products (
venta.component.ts:37-41)
Select Product and Quantity
- Click on a product from the autocomplete dropdown
- Enter the desired Cantidad (Quantity) in the quantity field
- Click the Agregar (Add) button
Review Cart
The table displays all products in the current sale:
The Total display updates automatically with each addition.
| Column | Description |
|---|---|
| Producto | Product name |
| Cantidad | Quantity ordered |
| Precio | Unit price |
| Total | Line total (quantity × price) |
| Acción | Remove item button |
Select Payment Method
Choose the payment type from the dropdown:
- Efectivo (Cash) - Default option
- Tarjeta (Card)
Complete the Sale
Click the Registrar (Register) button to finalize the sale. The system:
- Validates the cart has at least one product
- Sends sale data to
/Venta/Registrar - Reduces stock for each product automatically
- Generates a sale number (numeroDocumento)
- Displays success message with sale number
- Clears the cart for the next transaction
Product Autocomplete
The product search uses intelligent autocomplete to speed up the checkout process:How It Works
- Start typing a product name (case-insensitive)
- Dropdown shows matching products in real-time
- Only displays products that are:
- Active (
esActivo == 1) - In stock (
stock > 0)
- Active (
- Results update as you continue typing
Selecting a Product
- Click on a product from the dropdown list
- Product details are captured automatically
- Price is retrieved from the product record
- Focus moves to quantity field
Managing the Cart
Adding Multiple Products
- Add products one at a time using the search and add workflow
- Each product appears as a new line in the cart table
- Can add the same product multiple times with different quantities
Calculating Totals
The system automatically calculates:- Line Total:
quantity × unit price(venta.component.ts:88-90) - Sale Total: Sum of all line totals
- Totals display with 2 decimal places
- Running total updates in real-time
Removing Products
To remove a product from the cart:- Click the red delete (trash) icon in the Actions column
- Product is removed immediately
- Total is recalculated automatically (
venta.component.ts:112-117)
Removing a product only removes it from the current cart. It doesn’t affect inventory or past sales.
Payment Methods
Sistema Venta supports two payment types:Efectivo (Cash)
Default Payment Method
- Selected by default for each new sale
- Used for cash transactions
- Recorded in sales history and reports
Tarjeta (Card)
Card Payments
- Credit/debit card transactions
- Select from dropdown before registering sale
- Tracked separately in reports
Sale Registration
When you click Registrar, the system processes the sale:Sale Data Structure
Backend Processing
The API endpoint/Venta/Registrar handles:
- Creating the sale record
- Generating unique sale number (numeroDocumento)
- Recording all line items (detalleVenta)
- Reducing product stock automatically
- Timestamping the transaction
Success Response
On successful registration:- Success alert appears with sale number
- Message: “Venta Registrada!” (Sale Registered!)
- Shows:
Numero de venta: {numeroDocumento} - Cart clears automatically
- Ready for next transaction
The sale number (numeroDocumento) is generated by the backend and can be used to look up the sale in the sales history.
Inventory Updates
Stock levels update automatically when sales are completed:- Each product quantity is deducted from current stock
- Updates happen during sale registration
- No manual stock adjustment needed
- If a product reaches 0 stock, it disappears from future sales autocomplete
Form Validation
The sales interface uses validation to prevent errors:| Validation | Behavior |
|---|---|
| Product Selection | Must select from autocomplete (typing only isn’t enough) |
| Quantity Required | Must enter a quantity before adding |
| Empty Cart | Register button disabled if cart is empty |
| During Registration | Register button disabled while processing to prevent double-submission |
Sales History
After completing a sale, you can view it in the Historial Venta (Sales History) section.Accessing Sales History
Navigate to Historial Venta from the main menu to view all past transactions.Search Options
Find specific sales using two search methods:- Search by Date
- Search by Sale Number
Por fechas (By dates)
- Select search type: “Por fechas”
- Choose Fecha Inicio (Start date)
- Choose Fecha Fin (End date)
- Click Buscar (Search)
Sales History Table
The history displays:- Fecha Registro: Registration date/time
- Numero Documento: Unique sale number
- Tipo Pago: Payment method (Efectivo/Tarjeta)
- Total: Total sale amount
- Acción: View details button
Viewing Sale Details
Click the view icon on any sale to open a detailed modal showing:- Complete product list
- Quantities and prices for each item
- Line totals
- Overall sale total
- Payment method
- Sale date and number
modal-detalle-venta.component.ts.
API Endpoints
The Sales module uses these API endpoints:Best Practices
Verify Product
Always confirm the correct product is selected before entering quantity.
Check Total
Review the total amount before registering to catch entry errors.
Save Sale Number
Note or print the sale number (numeroDocumento) for customer reference and future lookups.
Clear Cart After
The system clears automatically, but verify before starting a new sale to avoid mixing orders.
Keyboard Workflow
For faster checkout, use this keyboard-optimized flow:- Tab or click into Product field
- Type product name, arrow keys to select, Enter
- Tab to Quantity field
- Enter quantity, Enter to add
- Repeat for additional products
- Select payment method if not cash
- Click or Tab to Register button
Related Components
- Component:
venta.component.ts- Main sales processing logic - Template:
venta.component.html- POS interface layout - Service:
venta.service.ts:18-20- Sale registration API - Service:
producto.service.ts- Product list for autocomplete - History:
historial-venta.component.ts- Sales history viewer - Detail Modal:
modal-detalle-venta.component.ts- Sale detail view
Troubleshooting
Product doesn't appear in autocomplete
Product doesn't appear in autocomplete
Check that the product:
- Is set to Active status (esActivo = 1)
- Has stock greater than 0
- Exists in the database
- Name matches what you’re typing
lista.filter(p => p.esActivo == 1 && p.stock > 0)Can't add product - button stays disabled
Can't add product - button stays disabled
Register button is disabled
Register button is disabled
Sale registered but stock didn't decrease
Sale registered but stock didn't decrease
This is handled by the backend during registration. If stock isn’t updating:
- Check the API server logs
- Verify the
/Venta/Registrarendpoint includes stock reduction logic - Confirm the sale was actually registered (check sales history)
Total seems wrong
Total seems wrong
The total calculates as:
sum of (quantity × price) for all itemsVerify:- Product prices are correct in product management
- Quantities entered are accurate
- All line item totals are correct
- Check for decimal/formatting issues in price data