Overview
The Sales module provides comprehensive order management and tracking capabilities. It enables you to monitor sales performance, manage order statuses, and track revenue metrics in real-time.Order Tracking
Monitor all orders with real-time status updates: Completed, Pending, In Transit, and Returned
Revenue Analytics
Track sales performance with monthly revenue charts and key metrics
Client Relations
Link sales directly to client profiles for better relationship management
Invoice Integration
Automatic invoice generation for completed sales
Venta Model
TheVenta model represents sales transactions in the system:
app/Models/Venta.php
Model Relationships
- Cliente Relationship
- Factura Relationship
Each sale belongs to a client (Usage Example:
belongsTo):Database Schema
Theventas table structure from the migration:
database/migrations/2026_03_03_191659_create_ventas_table.php
Table Fields
| Field | Type | Description |
|---|---|---|
id | bigint | Primary key |
numero_orden | string | Unique order number |
cliente_id | foreignId | Reference to clients table |
producto | string | Product name/description |
total | decimal(10,2) | Total amount |
estado | enum | Order status |
timestamps | timestamps | created_at, updated_at |
Order Statuses
The system supports four distinct order statuses to track the complete sales lifecycle.
- Completado
- Pendiente
- En Camino
- Devuelto
Completed OrdersOrders that have been successfully fulfilled and delivered to the customer.
Sales View Features
The sales interface (ventas.blade.php) provides:
Dashboard Cards
- Total Sales: Monthly revenue total ($78,450)
- Orders: Total order count (342) with growth percentage
- Pending: Orders awaiting processing (18)
- Returns: Returned orders this month (5)
Analytics Charts
Monthly Sales Chart
Bar chart showing sales revenue by month (January - June)
Order Status Chart
Pie chart displaying distribution of order statuses
Sales Table
The main sales table displays:- Order number (
#1045,#1044, etc.) - Client name
- Product description
- Total amount
- Order date
- Status badge (color-coded)
- Action buttons (View, Cancel)
The table supports real-time search and filtering for quick order lookup.
Usage Examples
Creating a New Sale
Querying Sales with Client Data
Updating Order Status
Sales by Status Report
Key Features
Unique Order Numbers
Each sale has a unique order identifier for tracking
Client Integration
Direct relationship with client records
Cascade Deletion
Sales are automatically deleted when clients are removed
Decimal Precision
Total amounts stored with 2 decimal precision
Status Tracking
Four-stage order lifecycle monitoring
Timestamp Tracking
Automatic created_at and updated_at timestamps
