Skip to main content

Overview

The Spare Parts entity (Repuesto) represents the master catalog of auto parts. Each spare part can exist in multiple inventory locations with different stock levels.

Repuesto

Core spare part entity with catalog information.

Properties

id_repuesto
string
required
Unique identifier for the spare part
referencia
string
required
Part reference code or SKU
nombre
string
required
Name or description of the part
descontinuado
boolean
required
Whether the part has been discontinued
tipo
string
required
Part category or type (e.g., “Frenos”, “Motor”, “Suspensión”)
fecha_estimada
string | null
Estimated date for restocking (ISO 8601 format)
url_imagen
string | null
URL to the part image
created_at
string
required
Timestamp when the part was created (ISO 8601 format)
marca
string
required
Brand or manufacturer name
descripcion
string
required
Detailed description of the part

Extended Properties (from vista_repuestos_inventario)

These fields are available when querying through inventory views:
stock_actual
number
Current stock at the location
posicion
string
Physical storage position
veces_contado
number
Number of times the part has been counted
estado_stock
string
Stock status (e.g., “disponible”, “bajo”, “agotado”)
cantidad_minima
number
Minimum stock threshold
nuevo_hasta
string | null
Date until which the item is marked as “new”
nombre_localizacion
string
Name of the location where stock exists
fecha_creacion_repuesto
string
Part creation date
alerta_minimo
boolean
Whether the stock is below minimum threshold
es_nuevo
boolean
Whether the part is currently marked as new

Example

{
  "id_repuesto": "RP-98765",
  "referencia": "FLT-OIL-2024",
  "nombre": "Oil Filter - Premium Grade",
  "descontinuado": false,
  "tipo": "Filtros",
  "fecha_estimada": null,
  "url_imagen": "https://example.com/images/oil-filter.jpg",
  "created_at": "2025-11-20T10:15:30Z",
  "marca": "Mann Filter",
  "descripcion": "Premium oil filter compatible with diesel engines",
  "stock_actual": 120,
  "posicion": "B-05-12",
  "estado_stock": "disponible",
  "cantidad_minima": 20,
  "alerta_minimo": false
}

RepuestosParams

Query parameters for fetching spare parts.

Properties

page
number
default:"1"
Page number for pagination
limit
number
default:"10"
Number of items per page
Search query to filter by name or reference
tipo
string
Filter by part type/category
descontinuado
boolean
Filter by discontinued status
order_by
keyof Repuesto
default:"fecha_ingreso_inventario"
Field to sort results by
direction
'asc' | 'desc'
default:"desc"
Sort direction

PaginatedRepuestosResponse

Paginated response structure for spare parts queries.

Properties

items
Repuesto[]
required
Array of spare parts for the current page
total_count
number
required
Total number of parts matching the query
page
number
required
Current page number
limit
number
required
Items per page
page_count
number
required
Total number of pages

RepuestoFormData

Data structure for creating or updating spare parts.

Properties

referencia
string
required
Part reference code
nombre
string
required
Part name
descontinuado
boolean
required
Discontinued status
tipo
string
required
Part type/category
fecha_estimada
string | null
Estimated restock date
url_imagen
string | null
Image URL
marca
string
Brand name
descripcion
string
Detailed description

Example

{
  "referencia": "BRK-PAD-2024",
  "nombre": "Ceramic Brake Pad Set",
  "descontinuado": false,
  "tipo": "Frenos",
  "fecha_estimada": null,
  "url_imagen": "https://example.com/brake-pad.jpg",
  "marca": "Brembo",
  "descripcion": "High-performance ceramic brake pads for heavy-duty vehicles"
}

API Methods

getRepuestos

Fetches paginated spare parts from the database.
import { getRepuestos } from '@/entities/repuestos/api';

const response = await getRepuestos({
  page: 1,
  limit: 25,
  search: 'filter',
  tipo: 'Filtros',
  descontinuado: false,
  order_by: 'nombre',
  direction: 'asc'
});
Source: src/entities/repuestos/api/index.ts:4

createRepuesto

Creates a new spare part in the catalog.
import { createRepuesto } from '@/entities/repuestos/api';

const newPart = await createRepuesto({
  referencia: 'SPK-PLG-001',
  nombre: 'Spark Plug Set',
  descontinuado: false,
  tipo: 'Ignición',
  marca: 'NGK',
  descripcion: 'Platinum spark plugs'
});
Source: src/entities/repuestos/api/index.ts:55

updateRepuesto

Updates an existing spare part.
import { updateRepuesto } from '@/entities/repuestos/api';

const updated = await updateRepuesto('RP-12345', {
  descontinuado: true,
  fecha_estimada: null
});
Source: src/entities/repuestos/api/index.ts:70

deleteRepuesto

Deletes a spare part from the catalog.
import { deleteRepuesto } from '@/entities/repuestos/api';

await deleteRepuesto('RP-12345');
Source: src/entities/repuestos/api/index.ts:86

Relationships

  • Has many: Inventory Items - stock levels at different locations
  • Used in: Movements - technical movements of parts
  • Referenced by: Requests - cart items for part requests
  • Appears in: Guarantees - warranty claims for parts

Build docs developers (and LLMs) love