Skip to main content
GET
/
api
/
catalogs
/
catnp
Parts Catalog (CatNP)
curl --request GET \
  --url https://api.example.com/api/catalogs/catnp
{
  "ID": 123,
  "NP": "<string>",
  "MATERIAL": "<string>",
  "PESO": 123,
  "COSTO": 123,
  "TIPO": "<string>",
  "DESCRIPCION": "<string>",
  "activo": 123
}

Overview

The Parts Catalog (Catálogo de Números de Parte - CatNP) stores part information including cost per unit, weight, and descriptions. This data is used for automatic cost calculation when registering scrap.
When scanning a barcode, the system automatically looks up the part in this catalog and fills in Material, Weight, and Cost fields.

Endpoints

List All Parts

curl -X GET http://localhost:3001/api/catalogs/catnp \
  -H "Authorization: Bearer YOUR_TOKEN"

Create Part

curl -X POST http://localhost:3001/api/catalogs/catnp \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "NP": "12345678",
    "MATERIAL": "Conector A1 - 16 Pines",
    "PESO": 0.25,
    "COSTO": 2.45,
    "TIPO": "Conector",
    "DESCRIPCION": "Conector automotriz resistente al calor",
    "activo": 1
  }'

Update Part

curl -X PUT http://localhost:3001/api/catalogs/catnp/1 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"COSTO": 2.75}'

Delete Part (Soft)

curl -X DELETE http://localhost:3001/api/catalogs/catnp/1 \
  -H "Authorization: Bearer YOUR_TOKEN"

Data Structure

ID
number
Unique identifier
NP
string
required
Part number (typically 8-12 digits)
MATERIAL
string
required
Material or part description
PESO
number
default:0
Weight per unit in kilograms
COSTO
number
default:0
Cost per unit in USD
TIPO
string
Part type or category (e.g., “Conector”, “Arnés”, “Terminal”)
DESCRIPCION
string
Detailed description
activo
number
Status: 1 = active, 0 = inactive

Response Example

[
  {
    "ID": 1,
    "NP": "12345678",
    "MATERIAL": "Conector A1 - 16 Pines",
    "PESO": 0.25,
    "COSTO": 2.45,
    "TIPO": "Conector",
    "DESCRIPCION": "Conector automotriz resistente al calor",
    "activo": 1
  },
  {
    "ID": 2,
    "NP": "87654321",
    "MATERIAL": "Arnés Principal 2.5m",
    "PESO": 1.2,
    "COSTO": 15.75,
    "TIPO": "Arnés",
    "DESCRIPCION": "Arnés principal con 24 circuitos",
    "activo": 1
  }
]

TypeScript Interface

export interface CatNP {
  ID: number;
  NP: string;
  MATERIAL: string;
  PESO: number;
  COSTO: number;
  TIPO?: string;
  DESCRIPCION?: string;
  activo: number;
}

Barcode Scanner Integration

When a barcode is scanned in the scrap registration form, the system:
  1. Searches for the part number in the CatNP catalog
  2. If found, auto-fills:
    • MATERIAL field with the part description
    • PESO field with the unit weight
    • COSTO field with the unit cost
  3. The user then enters the quantity to calculate total cost
Cost Calculation: Total cost = Unit cost (COSTO) × Quantity (TOTAL_PZAS)

Permissions

View

All authenticated users

Create/Edit

admin, calidad roles only

Import/Export

Parts can be imported in bulk via CSV upload. The CSV should have columns: NP, MATERIAL, PESO, COSTO, TIPO, DESCRIPCION

Common Use Cases

Search for Part by Number

const findPartByNumber = (partNumber, catalog) => {
  return catalog.find(part => 
    part.NP === partNumber && part.activo === 1
  );
};

// Usage
const scannedPart = findPartByNumber('12345678', catnpCatalog);
if (scannedPart) {
  form.setValues({
    MATERIAL: scannedPart.MATERIAL,
    PESO: scannedPart.PESO,
    COSTO: scannedPart.COSTO
  });
}

Calculate Total Cost

const calculateTotalCost = (partCost, quantity) => {
  return parseFloat(partCost) * parseInt(quantity);
};

// Usage
const unitCost = 2.45; // from catalog
const quantity = 150; // from user input
const totalCost = calculateTotalCost(unitCost, quantity); // 367.50

Build docs developers (and LLMs) love