Skip to main content

Overview

The Inventory Management module provides comprehensive control over dental supplies, materials, and clinic inventory. It tracks stock levels, generates low-stock alerts, and records all inventory transactions (entries and exits).
Access requires VIEW_INVENTORY permission. Transaction management requires MANAGE_INVENTORY permission.

Key Metrics

The inventory page displays three critical statistics:

Stock Bajo

Count of items at or below minimum stock threshold

Artículos

Total number of inventory items tracked

Valor Total

Total inventory value (stock × price) in DOP

Inventory Items

Item Properties

Each inventory item contains:
FieldTypeDescription
idnumberUnique inventory item ID
namestringMaterial/supply name
descriptionstringTechnical observations
categorystringItem category (e.g., “Resinas”, “Instrumental”)
unitstringUnit of measure (“unidades”, “ml”, “cajas”)
stocknumberCurrent stock quantity
min_stocknumberMinimum threshold for alerts
pricenumberUnit cost in DOP

Status Indicators

Red badge - Displayed when stock <= min_stockIndicates immediate reorder required. Items with this status appear with:
  • Red background tint (#fffafb)
  • Alert pulse animation
  • 6px left border accent

Core Features

Add New Material

Admins can register new inventory items using the ”➕ Nuevo Material” button. Form Fields:
  • Nombre del Material: Item name (e.g., “Resina A2 Filtek”)
  • Categoría: Classification (default: “General”)
  • Unidad de Medida: Unit type (default: “unidades”)
  • Costo Unitario: Price per unit in DOP
  • Alerta de Stock Mínimo: Minimum threshold quantity
  • Observaciones Técnicas: Optional description
API Call:
POST /api/inventory
{
  "name": "Resina A2 Filtek",
  "description": "Composite resin for anterior restorations",
  "category": "Resinas",
  "unit": "jeringas",
  "min_stock": 5,
  "price": 450.00
}
Backend: Calls sp_create_inventory_item stored procedure.

Stock Transactions

Inventory movements are tracked through two transaction types:

📥 Entrada

Entry TransactionRecords incoming inventory (purchases, restocks)
  • Increases stock level
  • Tracks supplier reference
  • Logs date and user

📤 Salida

Exit TransactionRecords outgoing inventory (usage, consumption)
  • Decreases stock level
  • Documents usage reason
  • Links to procedures (optional)

Transaction Workflow

1

Select Item

Click the 📥 (entry) or 📤 (exit) button on an inventory item
2

Enter Quantity

Specify the transaction quantity
3

Add Reference

Provide reason or reference note (e.g., “Reposición mensual”, “Uso en cirugía”)
4

Confirm

Submit transaction to update stock levels
API Call:
PATCH /api/inventory
{
  "id": 123,
  "type": "entry",  // or "exit"
  "quantity": 10,
  "notes": "Reposición mensual"
}
Backend: Executes sp_update_stock(id, type, quantity, notes, user_id) procedure.

Data Display

The inventory module uses the DataTable component with two view modes:

Table View

  1. Material: Item name with category avatar
  2. Estado: Status badge (Reorden/Suficiente)
  3. Stock Actual: Current quantity with units
  4. Acciones: Entry/exit transaction buttons

Grid View (Mobile)

Compact card layout showing:
  • Category tag
  • Item name
  • Current stock (large display)
  • Minimum threshold
  • Unit price (formatted currency)
  • Transaction buttons

API Endpoints

List Inventory

GET /api/inventory
Authorization: Requires VIEW_INVENTORY permission Response:
{
  "success": true,
  "items": [
    {
      "id": 1,
      "name": "Resina A2 Filtek",
      "description": "",
      "category": "Resinas",
      "unit": "jeringas",
      "stock": 3,
      "min_stock": 5,
      "price": 450.00
    }
  ]
}
Source: /src/routes/api/inventory/+server.js
Procedure: sp_list_inventory()

Create Item

POST /api/inventory
Authorization: Requires MANAGE_INVENTORY permission Body: Item properties (name, description, category, unit, min_stock, price) Response:
{
  "success": true,
  "message": "Material registrado",
  "id": 123
}
Procedure: sp_create_inventory_item(name, description, category, unit, min_stock, price, user_id)

Update Stock

PATCH /api/inventory
Authorization: Requires MANAGE_INVENTORY permission Body:
{
  "id": 123,
  "type": "entry",
  "quantity": 10,
  "notes": "Reposición mensual"
}
Response:
{
  "success": true,
  "message": "Stock actualizado"
}
Procedure: sp_update_stock(id, type, quantity, notes, user_id)

Low Stock Alerts

The system automatically generates alerts when inventory items reach critical levels:
Items with stock <= min_stock trigger reorder alerts visible on:
  • Dashboard low stock counter
  • Inventory page with red badges
  • Alert feed (via /api/dashboard/alerts)

Alert Calculation

const lowStockCount = items.filter(i => i.stock <= i.min_stock).length;
Items meeting this condition:
  • Display “Reorden Requerido” badge
  • Show red stock values
  • Appear with alert styling in both table and grid views

Currency Formatting

All prices display in Dominican Peso (DOP) format:
function formatCurrency(val) {
  return new Intl.NumberFormat('es-DO', {
    style: 'currency',
    currency: 'DOP'
  }).format(Number(val) || 0);
}

// Example output: "RD$450.00"

Usage Examples

Example 1: Register New Supply

{
  "name": "Resina Filtek Z350 XT A2",
  "description": "Composite resin for anterior and posterior restorations",
  "category": "Resinas",
  "unit": "jeringas",
  "min_stock": 5,
  "price": 450.00
}

Example 2: Record Stock Entry

// Monthly supply restock
{
  "id": 15,
  "type": "entry",
  "quantity": 20,
  "notes": "Reposición mensual - Factura #12345"
}

Example 3: Record Stock Exit

// Procedure consumption
{
  "id": 15,
  "type": "exit",
  "quantity": 2,
  "notes": "Uso en endodoncia - Paciente #789"
}

Dashboard

View low stock alerts on main dashboard

Reports

Analyze inventory trends and costs

Build docs developers (and LLMs) love