Overview
The Sales Service (jea-venta) provides comprehensive sales transaction management for Sistema de Ventas. It handles the complete sales lifecycle from order creation to invoice generation, with automatic calculations for taxes and totals.
Key Features
Automatic Series & Numbers
Auto-generates unique series (3 letters) and sequential document numbers for invoice tracking
Tax Calculation
Automatically calculates IGV (18% VAT) and totals based on line items
Customer Integration
Links sales to customer records via Feign client integration
Payment Integration
Associates sales with payment methods for complete transaction tracking
Detailed Line Items
Support for multiple product line items per sale with individual pricing
Audit Trail
Automatic timestamps for all transactions and modifications
Sale Entity Structure
Each sale in the system contains comprehensive information about the transaction:Automatic Calculations
The system automatically calculates all financial amounts when a sale is created or updated. This ensures accuracy and consistency across all transactions.Sales Process Flow
Create Sale Request
Client sends sale data including customer ID, payment method, and line items with product details
Validate Customer
System fetches customer details from Customer Service using Feign client to validate the customer exists
Calculate Totals
Automatically calculates base amount, IGV (18%), and total for each line item and the entire sale
Generate Document Numbers
Creates unique series (3 random letters) and sequential number (6 digits) for invoice tracking
Save Transaction
Persists sale with all details to the database, creating a permanent transaction record
Available Endpoints
The Sales Service provides comprehensive CRUD operations and advanced querying capabilities:| Method | Endpoint | Description |
|---|---|---|
| POST | /venta | Create new sale |
| GET | /venta | List all sales |
| GET | /venta/{id} | Get sale by ID |
| PUT | /venta/{id} | Update sale |
| DELETE | /venta/{id} | Delete sale |
| GET | /venta/buscar-por-fechas | Search by date range |
| GET | /venta/buscar/serie | Search by series |
| GET | /venta/buscar/numero | Search by number |
| GET | /venta/buscar/serie-numero | Find by series and number |
| GET | /venta/productos-mas-vendidos | Top 10 best-selling products |
| GET | /venta/ventas-por-mes | Sales summary by month |
| GET | /venta/total-ventas | Total sales amount |
Sales Analytics
Top Selling Products
Track your best-performing products with the built-in analytics endpoint:Sales by Month
Monitor sales trends over time:Total Revenue
Get the cumulative sales total:Search and Filtering
Find specific sales using multiple search criteria:Date Range Search
Document Number Search
Find sales by series or number for quick invoice lookup:Integration Points
The Sales Service integrates with multiple microservices:- Customer Service - Validates customer information and retrieves customer details
- Catalog Service - Updates product inventory quantities after sale completion
- Payment Service - Retrieves payment method information for transaction records
- Category Service - Fetches product category information for reporting
Best Practices
Transaction Integrity
Transaction Integrity
Always include all line items in a single transaction. The service uses JPA cascade operations to ensure data consistency.
Inventory Management
Inventory Management
The system automatically updates inventory. Ensure products have sufficient stock before creating sales to avoid negative inventory.
Customer Validation
Customer Validation
Always validate that the customer exists before attempting to create a sale. The system will fail if the customer ID is invalid.
Document Numbers
Document Numbers
Document series and numbers are automatically generated. Do not attempt to set these values manually.
Next Steps
API Reference
Detailed API endpoint documentation
Customer Management
Learn about managing customer records
Inventory Control
Understand inventory tracking
Analytics & Reporting
Explore reporting capabilities