Skip to main content
This quickstart guide will walk you through the essential operations to start managing your veterinary pharmacy inventory effectively.
Make sure you’ve completed the installation steps before proceeding.

Launching the Application

Start the application using one of these methods:
mvn exec:java -Dexec.mainClass="InventarioApp"
The main inventory window will open, displaying the Inventario Veterinaria interface (view/InventarioView.java:34).

Initial Launch Alert

On first launch, you may see a caducity alert dialog (view/InventarioView.java:161-172):
Medicamentos próximos a caducar: X
Medicamentos ya caducados: Y
This alert appears automatically when:
  • Medicines are within 30 days of expiration
  • Medicines have already expired
Don’t dismiss this alert without noting which products need attention. Check the inventory table for items highlighted in red.

Understanding the Interface

The main window consists of:

Search Bar

Filter inventory by name, lot, or expiration date

Inventory Table

Displays all products with columns: ID, Name, Stock, Lot, Expiration, Entry Date

Action Buttons

Agregar, Eliminar, Editar, Exportar a Excel, Ventas, Apartados

Color Coding

Red cells indicate expired/expiring medicines

Expiration Color Indicators

The table automatically highlights expiration dates (view/InventarioView.java:345-367):
  • Dark Red (RGB 255, 0, 0): Product has expired
  • Light Red (RGB 255, 153, 153): Product expires within 30 days
  • Normal: Product has more than 30 days until expiration

Adding Your First Medicine

Let’s add a medicine product to the inventory:
1

Open the Add Medicine dialog

Click the Agregar button in the main window. This opens AgregarMedicamentoView (view/AgregarMedicamentoView.java:17-21).Add Medicine Dialog
2

Fill in product details

Enter the following information:
FieldDescriptionExample
NombreMedicine nameAmoxicilina 500mg
ExistenciasInitial stock quantity (use spinner)100
LoteBatch/lot numberL2024-001
CaducidadExpiration year and monthAño: 2025, Mes: 12
The expiration date uses two dropdown menus for year and month. The system formats this as yyyy-MM (e.g., “2025-12”) internally (view/AgregarMedicamentoView.java:147-152).
3

Save the product

Click Guardar to add the medicine. The system will:
  1. Validate that all fields are filled (view/AgregarMedicamentoView.java:138-145)
  2. Validate the expiration date format (model/InventarioDAO.java:217-230)
  3. Ensure stock quantity is non-negative (model/InventarioDAO.java:114-116)
  4. Insert the record into the productos table (model/InventarioDAO.java:119-127)
  5. Automatically set fechaEntrada to today’s date (model/InventarioDAO.java:118)
String fechaEntrada = LocalDate.now().toString(); // ISO 8601 format
String sql = "INSERT INTO productos (nombre, existencias, lote, caducidad, fechaEntrada) VALUES (?, ?, ?, ?, ?)";
You’ll see a success confirmation, and the product will appear in the main table.
Validation Rules:
  • All fields are required
  • Stock quantity must be ≥ 0
  • Expiration date must be in yyyy-MM format (enforced by dropdowns)

Recording Your First Sale

Now let’s record a sale transaction:
1

Open the Sales window

From the main window, click Ventas. This opens VentasView which displays the sales history table.
2

Register a new sale

Click Agregar Venta to open RegistrarVentaView (view/RegistrarVentaView.java:13-18).Enter:
FieldDescriptionExample
ID del MedicamentoProduct ID from inventory1
Nombre del MedicamentoExact product name (must match)Amoxicilina 500mg
Cantidad VendidaUnits sold (use spinner, min: 1)10
The product name must exactly match the name in the database. The system validates this to prevent errors (model/InventarioDAO.java:266-270).
3

Save the sale

Click Guardar. The system performs several operations in a transaction (model/InventarioDAO.java:247-309):
// 1. Verify product exists and name matches
String selectQuery = "SELECT nombre, existencias FROM productos WHERE id = ?";

// 2. Check sufficient stock
if (cantidadVendida > existenciasActuales) {
    JOptionPane.showMessageDialog(null, "No hay suficientes existencias.");
    return false;
}

// 3. Start transaction
connection.setAutoCommit(false);

// 4. Deduct from inventory
String updateQuery = "UPDATE productos SET existencias = existencias - ? WHERE id = ?";

// 5. Record in sales history
String fechaVenta = LocalDate.now().toString();
String insertHistorial = "INSERT INTO historial_ventas (idProducto, nombre, cantidad, fechaVenta) VALUES (?, ?, ?, ?)";

// 6. Commit transaction
connection.commit();
The inventory stock will be automatically reduced, and the sale will appear in the sales history table.
Sales are recorded with a foreign key relationship to products. If a product is deleted, all associated sales history is also removed (CASCADE DELETE defined in model/InventarioDAO.java:85).

Viewing and Searching Inventory

The main inventory table provides powerful search and sorting capabilities:

Searching Products

1

Use the search bar

Type in the Buscar field at the top of the window (view/InventarioView.java:100-106). The table filters in real-time as you type.You can search by:
  • Medicine name
  • Lot number
  • Expiration date
// Case-insensitive regex filter
rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + criterio));
2

Clear the filter

Delete the text in the search field or click Refrescar to show all products.

Sorting Columns

Click any column header to sort:
  • Click once: Sort ascending
  • Click again: Sort descending
  • Click a third time: Return to default order
The Existencias column sorts numerically (not alphabetically) for accurate stock ordering (view/InventarioView.java:208-217).

Selecting Multiple Items

You can select multiple products for batch operations:
  • Click + Drag: Select range
  • Ctrl + Click (Windows/Linux) or Cmd + Click (macOS): Select individual items
  • Shift + Click: Select from last selection to current

Basic Inventory Operations

Editing a Product

1

Select a product

Click on any row in the inventory table to select a product.
2

Open edit dialog

Click the Editar button. The EditarMedicamentoView dialog opens with pre-filled fields.
3

Modify and save

Update any fields (name, stock, lot, expiration) and click Guardar.The system updates the product via editarProducto() (model/InventarioDAO.java:157-195):
String sql = "UPDATE productos SET nombre = ?, existencias = ?, lote = ?, caducidad = ?, fechaEntrada = ? WHERE id = ?";

Deleting Products

1

Select product(s)

Select one or more products to delete (hold Ctrl/Cmd for multiple).
2

Click Eliminar

Click the Eliminar button (red). You’ll see a confirmation dialog.
3

Confirm deletion

Click Yes to permanently delete. This removes:
  • The product from productos table
  • All associated sales records (CASCADE DELETE)
String sql = "DELETE FROM productos WHERE id = ?";
Deletion is permanent and cannot be undone. All sales history for deleted products will also be removed.

Refreshing the View

Click Refrescar at any time to reload data from the database. This is useful if:
  • You suspect data is stale
  • You’ve made changes in another window (Ventas, Apartados)
  • You want to clear search filters

Exporting Data

Export your inventory to CSV format for use in Excel or other tools:
1

Click Export button

Click Exportar a Excel in the main window.
2

Choose save location

A file dialog opens with default name inventario.csv. Choose where to save the file.
3

Open in Excel

The CSV file contains all inventory data with headers (model/InventarioDAO.java:459-482):
ID,Nombre,Existencias,Lote,Caducidad,Fecha Entrada
1,Amoxicilina 500mg,90,L2024-001,2025-12,2024-03-06
2,Ibuprofeno 400mg,50,L2024-002,2025-06,2024-03-06
You can also export sales history and reserved products from their respective windows using the same process.

Keyboard Shortcuts and Tips

  • Ctrl+A (Windows/Linux) or Cmd+A (macOS): Select all rows
  • Ctrl+Click: Add/remove individual rows from selection
  • Shift+Click: Select range of rows
  • Hover over rows: Highlights row with light blue background
  • Click column headers: Sort by that column
  • Double-click empty space: Deselect all rows
  • Right-click: Context menu (future feature)
  • Use search to filter large inventories instead of scrolling
  • Click Refrescar if the table seems out of sync
  • Export data regularly for backup purposes
  • Close unused windows (Ventas, Apartados) to save memory

Common Tasks Reference

Check expiring medicines

Look for red-highlighted rows in the Caducidad column. Dark red = expired, light red = expires soon.

Find a specific medicine

Type the name, lot, or date in the search bar. The table filters automatically.

Restock a product

Select the product, click Editar, increase Existencias, and save.

View low stock

Click the Existencias column header to sort by stock quantity (lowest first).

Undo a sale

Open Ventas window, select the sale, click Eliminar. Note: This does NOT restore inventory.

Reserve medicine

Click Apartados, then Registrar Apartado to mark products as reserved.

What’s Next?

Now that you’re familiar with the basics, explore more advanced features:

Inventory Management

Complete inventory guide

Sales Tracking

Track and manage sales transactions

Product Reservation

Handle reserved inventory

CSV Export

Export data to Excel/CSV

Expiration Monitoring

Monitor expiring products

Architecture

Understand the technical design

Getting Help

If you encounter issues or have questions:
1

Check the documentation

Browse the User Guide for detailed feature explanations.
2

Review error messages

The application shows descriptive error dialogs. Read them carefully for hints.
3

Verify data integrity

Check that:
  • Product IDs exist when recording sales
  • Product names match exactly (case-sensitive)
  • Stock quantities are sufficient for sales
4

Contact support

If problems persist, contact your system administrator with:
  • Error message text
  • Steps to reproduce the issue
  • Database backup (from ./db/baseDeDatosInventario.db)

Build docs developers (and LLMs) love