Overview
The Inventory Management module allows you to add, edit, and delete products in your veterinary pharmacy inventory. All operations are handled through theInventarioController class and persist data to a SQLite database.
Database Schema
Products are stored in theproductos table with the following fields:
id(INTEGER, PRIMARY KEY, AUTOINCREMENT)nombre(TEXT) - Product nameexistencias(INTEGER) - Stock quantitylote(TEXT) - Batch numbercaducidad(TEXT) - Expiration date inyyyy-MMformatfechaEntrada(TEXT) - Entry date inyyyy-MM-ddformatfecha_separado(TEXT, nullable) - Reservation date
Adding Products
Open the Add Product Dialog
Click the Agregar button in the main inventory view to open
AgregarMedicamentoView.Fill in Product Details
Enter the following required fields:
- Nombre: Product name (text field)
- Existencias: Stock quantity (spinner, minimum 0)
- Lote: Batch number (text field)
- Caducidad: Select year and month from dropdown menus
Method Signature
InventarioController.java:20-26DAO Implementation:
InventarioDAO.java:103-136
Validation Rules
Expiration Date Format
Expiration Date Format
The expiration date must be in
yyyy-MM format (e.g., 2025-07). The system uses:- Year dropdown: Current year to +10 years
- Month dropdown: 1-12
- Automatic validation via regex:
\\d{4}-\\d{2} - Additional parsing validation with
YearMonth.parse()
Stock Quantity Rules
Stock Quantity Rules
- Must be a valid integer
- Cannot be negative
- Validated in
InventarioDAO.java:114-116:
Entry Date
ThefechaEntrada is automatically set to the current date when adding a product:
Editing Products
Modify Fields
Update any of the following fields:
- Nombre
- Existencias
- Lote
- Caducidad (year and month)
- Fecha Entrada
Method Signature
InventarioController.java:36-47DAO Implementation:
InventarioDAO.java:157-195
The same validation rules apply to editing as to adding products. Expiration dates must be in
yyyy-MM format and stock cannot be negative.Deleting Products
Select Product(s)
Click on one or more products in the inventory table. Multiple selection is supported.
Method Signature
InventarioController.java:28-34DAO Implementation:
InventarioDAO.java:142-155
Batch Management
Batch Number Field
Thelote field stores batch/lot numbers for product tracking:
- No format restrictions
- Stored as TEXT in the database
- Required field when adding or editing products
Stock Management
Automatic Stock Updates
Stock quantities are automatically updated when:-
Sales are registered: Stock decreases by the sold quantity
-
Sales are edited: Stock adjusts based on the difference
- Sales are deleted: Stock is NOT automatically restored (manual adjustment required)
Viewing Current Stock
The main inventory table displays real-time stock levels in the Existencias column. This column is sortable (click the header) and uses numeric comparison:Searching and Filtering
Real-time Search
Use the search bar at the top of the inventory view to filter products:- Searches across: Name, Batch, and Expiration date
- Case-insensitive regex matching
- Real-time filtering as you type
Refresh Table
Click the Refrescar button to reload inventory data from the database:Visual Indicators
Expiration Date Colors
The Caducidad column uses color coding to highlight products requiring attention:- Red (255, 0, 0): Product has already expired
- Light Red (255, 153, 153): Product expires within 30 days
- Normal: Product has more than 30 days until expiration