Skip to main content

Overview

The Inventory entity represents items in stock at specific locations. It combines inventory-specific data (stock levels, position) with spare part information (reference, name, specifications).

InventoryItem

Represents a complete inventory item with all related spare part data.

Properties

id_inventario
string
required
Unique identifier for the inventory item (UUID format)
id_localizacion
string
required
Location identifier where the item is stored
stock_actual
number
required
Current stock quantity available at this location
posicion
string
required
Physical position or bin location within the warehouse
id_repuesto
string
required
Reference to the spare part entity
referencia
string
required
Spare part reference code or SKU
nombre
string
required
Name or description of the spare part
cantidad_minima
number
required
Minimum stock threshold that triggers reorder alerts
descontinuado
boolean
required
Indicates if the spare part has been discontinued
tipo
string
required
Type or category of the spare part
fecha_estimada
string
required
Estimated date for restocking or availability (ISO 8601 format)
url_imagen
string
required
URL to the spare part image
estado_stock
string
required
Stock status indicator (e.g., “disponible”, “bajo”, “agotado”)
fecha_ingreso_inventario
string
required
Date when the item was added to inventory (ISO 8601 format)
nuevo_hasta
string | null
Date until which the item is considered “new” (ISO 8601 format)

Example

{
  "id_inventario": "550e8400-e29b-41d4-a716-446655440000",
  "id_localizacion": "LOC-001",
  "stock_actual": 45,
  "posicion": "A-12-03",
  "id_repuesto": "RP-12345",
  "referencia": "BRK-2023-XL",
  "nombre": "Brake Pad Set - Heavy Duty",
  "cantidad_minima": 10,
  "descontinuado": false,
  "tipo": "Frenos",
  "fecha_estimada": "2026-04-15T00:00:00Z",
  "url_imagen": "https://example.com/images/brk-2023-xl.jpg",
  "estado_stock": "disponible",
  "fecha_ingreso_inventario": "2026-02-10T08:30:00Z",
  "nuevo_hasta": "2026-03-10T00:00:00Z"
}

InventoryParams

Parameters for filtering and paginating inventory queries.

Properties

page
number
default:"1"
Page number for pagination
limit
number
default:"10"
Number of items per page
order_by
string
default:"referencia"
Field to sort by
direction
'asc' | 'desc'
default:"asc"
Sort direction
Search query to filter by name or reference
estado_stock
string
Filter by stock status
descontinuado
boolean
Filter by discontinued status
is_new
boolean
Filter to show only new items (where nuevo_hasta > current date)

PaginatedInventoryResponse

Response structure for paginated inventory queries.

Properties

items
InventoryItem[]
required
Array of inventory items for the current page
total_count
number
required
Total number of items matching the query
page
number
required
Current page number
limit
number
required
Number of items per page
page_count
number
required
Total number of pages available

Example

{
  "items": [
    {
      "id_inventario": "550e8400-e29b-41d4-a716-446655440000",
      "stock_actual": 45,
      "referencia": "BRK-2023-XL",
      "nombre": "Brake Pad Set"
    }
  ],
  "total_count": 234,
  "page": 1,
  "limit": 10,
  "page_count": 24
}

TimelineEvent

Represents a historical event in the inventory timeline.

Properties

fecha
string
required
Event timestamp (ISO 8601 format)
tipo_evento
'CONTEO' | 'GARANTIA' | 'MOVIMIENTO_TECNICO' | 'AJUSTE_MANUAL'
required
Type of inventory event
titulo
string
required
Event title or summary
operacion
string
required
Operation performed (e.g., “add”, “remove”, “adjust”)
estado
string
required
Event status
usuario_responsable
string
required
Name of the user responsible for the event
tecnico_asociado
string | null
Associated technician name, if applicable
observaciones
string | null
General observations or notes
informacion_adicional
string | null
Additional contextual information
orden
string | null
Work order number associated with the event
id_repuesto
string
required
Related spare part identifier
id_localizacion
string
required
Location where the event occurred

API Methods

getInventory

Fetches paginated inventory data from the v_inventario_completo view.
import { getInventory } from '@/entities/inventario/api';

const response = await getInventory({
  page: 1,
  limit: 20,
  search: 'brake',
  estado_stock: 'disponible',
  order_by: 'nombre',
  direction: 'asc'
});
Source: src/entities/inventario/api/index.ts:8

getAllInventoryItems

Retrieves all inventory items for autocomplete or dropdown components (limited to 1000 items).
import { getAllInventoryItems } from '@/entities/inventario/api';

const allItems = await getAllInventoryItems();
Source: src/entities/inventario/api/index.ts:95

updateItemComplete

Updates an inventory item using the actualizar_item_inventario RPC function.
import { updateItemComplete } from '@/entities/inventario/api';

await updateItemComplete(
  'inv-uuid-123',
  50,              // stock_actual
  'A-12-05',       // posicion
  10,              // cantidad_minima
  false,           // descontinuado
  'Frenos',        // tipo
  '2026-05-01',    // fecha_estimada
  '2026-04-01'     // nuevo_hasta
);
Source: src/entities/inventario/api/index.ts:120

searchInventoryItems

Searches inventory by name or reference, returns up to 50 matches.
import { searchInventoryItems } from '@/entities/inventario/api';

const results = await searchInventoryItems('brake pad');
Source: src/entities/inventario/api/index.ts:152

searchRepuestos

Searches spare parts across inventory or the repuestos table.
import { searchRepuestos } from '@/entities/inventario/api';

const results = await searchRepuestos('filter', 'LOC-001');
Source: src/entities/inventario/api/index.ts:181

Relationships

  • Belongs to: Location via id_localizacion
  • References: SparePart via id_repuesto
  • Related to: Movements - inventory changes from technical movements
  • Related to: Guarantees - inventory affected by warranty claims

Build docs developers (and LLMs) love