Product entity
Products are stored in theProducto model with the following fields:
Unique product code identifier (primary key)
Foreign key reference to the product category. Links to the
Categorium tableDetailed product description (max 500 characters)
Purchase price or cost price (precision: 18 digits, 2 decimals)
Selling price to customers (precision: 18 digits, 2 decimals)
Current quantity available in inventory. Defaults to 0
Minimum stock level threshold for reorder alerts. Defaults to 5
Product status flag (true = active, false = inactive). Defaults to true
Timestamp when the product was created. Automatically set to current date/time
Database schema
Indexes
The products table includes optimized indexes:IDX_productos_descripcion- Fast text search on product descriptionsIDX_productos_idcategoria- Quick filtering by categoryIDX_productos_estado- Filter active/inactive productsIDX_productos_stock- Critical index on stock and minimum stock levels for reorder alerts
Relationships
Products have several important relationships:Category relationship
- CodCategoriaNavigation: Navigation property to the
Categoriumentity, allowing products to be organized into categories
Transaction relationships
- ComprasDetalles: Collection of purchase order line items containing this product
- VentasDetalles: Collection of sales order line items containing this product
Automated inventory management
Stock adjustment triggers
The system automatically manages inventory levels through database triggers:When a sale is created, the
TR_DisminuirStock trigger automatically decreases product stock by the quantity sold, but only if the sale is not voided.Reorder point monitoring
TheStock and StockMinimo fields work together to provide low stock alerts:
- When
Stockfalls belowStockMinimo, the product needs reordering - The indexed query on these fields enables fast identification of products requiring replenishment
- Default minimum stock is 5 units, but can be adjusted per product based on sales velocity
Product categories
Products can be organized using the category system. Categories are defined in theCategorium model:
Auto-incrementing category identifier (primary key)
Unique category code for easy reference
Category name (max 150 characters)
Detailed category description (max 300 characters)
Category status flag (true = active, false = inactive). Defaults to true
Timestamp when the category was created
User workflows
Adding a new product
Create product code
Assign a unique product identifier in the
Codprod field. Use a consistent naming convention (SKU, barcode, or custom code).Select category
Choose an appropriate category from the
CodCategoria dropdown to organize the product. Categories help with filtering and reporting.Enter description
Provide a clear product description including key features, specifications, or identifying characteristics.
Set pricing
Enter both purchase price (
PrecioCompra) and selling price (PrecioVenta). The difference represents your gross margin.Configure inventory levels
Set initial stock quantity and define the minimum stock threshold for reorder alerts. Adjust
StockMinimo based on product sales velocity and supplier lead time.Managing product pricing
Price updates: UpdatePrecioCompra when supplier prices change, and adjust PrecioVenta to maintain desired margins.
Monitoring inventory levels
Use the stock fields to manage inventory effectively:Current stock
View real-time inventory levels updated automatically with each sale and purchase
Low stock alerts
Identify products below minimum stock levels requiring immediate reordering
Stock history
Track inventory movements through purchase and sales transactions
Automated adjustments
Stock decreases automatically with sales, increases with purchase receipts
Managing product categories
Create categories
Define product categories with unique codes and descriptive names (e.g., “ELECTRONICS”, “OFFICE-SUPPLIES”, “FURNITURE”).
Assign products
Link products to categories during product creation or by updating the
CodCategoria field.Product status management
TheEstado field controls product availability:
- Active products (
Estado = true) are available for new sales and purchases - Inactive products (
Estado = false) are hidden from active catalogs but historical transactions remain accessible
Profit margin analysis
Use purchase and sale prices to calculate profitability:Best practices
Product code conventions
Product code conventions
Establish a systematic approach to product codes:
- Use manufacturer SKUs when available
- Include category prefixes:
ELEC-001,OFF-001 - Incorporate barcodes for retail products
- Keep codes short but meaningful
Inventory optimization
Inventory optimization
- Set
StockMinimobased on average sales velocity and supplier lead time - Review and adjust minimum stock levels quarterly
- Account for seasonal variations in demand
- Consider storage costs when setting stock levels
Pricing strategy
Pricing strategy
- Regularly review and update purchase prices based on supplier changes
- Maintain consistent profit margins within product categories
- Consider competitive pricing when setting
PrecioVenta - Document price change history for auditing
Category management
Category management
- Keep category structure simple and intuitive
- Avoid creating too many subcategories
- Ensure every product is assigned to a category
- Use categories for targeted promotions and analysis
Data quality
Data quality
- Write clear, searchable product descriptions
- Include brand, model, and specifications in descriptions
- Verify pricing accuracy before saving
- Perform regular audits of product data
Integration with sales and purchases
Products integrate seamlessly with other modules:- Sales orders: Products are added to
ventasDetalleline items, automatically decreasing stock - Purchase orders: Products are received through
comprasDetalle, increasing inventory levels - Pricing: Sale price from
PrecioVentais used in sales transactions - Inventory reporting: Real-time stock levels support accurate inventory valuation