Skip to main content
All TypeScript interfaces are defined in types/types.ts and extend RowDataPacket from the mysql2 library where applicable.

Compra

Represents a purchase record from the Corprecam system.
interface Compra extends RowDataPacket {
  com_codigo: number;
  comp_asociado: string;
  com_micro_ruta: string;
}

Fields

com_codigo
number
required
Unique purchase code identifier
comp_asociado
string
required
Associated company/partner identifier (typically a tax ID or NIT)
com_micro_ruta
string
required
Micro route code associated with this purchase. Used to fetch route details via getMicro()

Example

{
  "com_codigo": 12345,
  "comp_asociado": "900123456",
  "com_micro_ruta": "101"
}

CompraItem

Represents a line item within a purchase.
interface CompraItem extends RowDataPacket {
  citem_codigo: number;
  citem_id_compra: number;
  citem_material: number;
  citem_cantidad: number;
  citem_valor_unitario: number;
  citem_total: number;
  citem_rechazo: number;
}

Fields

citem_codigo
number
required
Unique purchase item identifier
citem_id_compra
number
required
Foreign key reference to the parent purchase (com_codigo)
citem_material
number
required
Material ID reference. Used to fetch material details via getMateriales()
citem_cantidad
number
required
Quantity of material purchased
citem_valor_unitario
number
required
Unit price of the material
citem_total
number
required
Total line item value (cantidad × valor_unitario)
citem_rechazo
number
required
Rejected quantity (amount not accepted)

Example

{
  "citem_codigo": 1,
  "citem_id_compra": 12345,
  "citem_material": 501,
  "citem_cantidad": 100,
  "citem_valor_unitario": 1500,
  "citem_total": 150000,
  "citem_rechazo": 0
}

Material

Represents a material/product in the system.
interface Material extends RowDataPacket {
  mat_id: number;
  mat_codigo: string;
  mat_nom: string;
  emp_id_fk: number;
}

Fields

mat_id
number
required
Unique material identifier
mat_codigo
string
required
Material code (SKU or product code)
mat_nom
string
required
Material name or description
emp_id_fk
number
required
Foreign key reference to the company/enterprise

Example

{
  "mat_id": 501,
  "mat_codigo": "MAT-001",
  "mat_nom": "Plastic Bottles",
  "emp_id_fk": 1
}

Micro

Represents a micro route in the collection system.
interface Micro extends RowDataPacket {
  mic_codigo: number;
  mic_nom: string;
}

Fields

mic_codigo
number
required
Unique micro route code identifier
mic_nom
string
required
Micro route name or description

Example

{
  "mic_codigo": 101,
  "mic_nom": "Ruta Norte"
}
The Micro interface is defined twice in the source (lines 9-12 and 29-31). The complete definition includes both mic_codigo and mic_nom fields.

Products

Represents a product entry in a Siigo document.
interface Products {
  codigo: string;
  cantidad: number;
  precio: number;
}

Fields

codigo
string
required
Product code/SKU
cantidad
number
required
Product quantity
precio
number
required
Product unit price

Example

{
  "codigo": "MAT-001",
  "cantidad": 100,
  "precio": 1500
}

DocumentoSoporte

Represents a support document structure used by Siigo for purchase recording. This is the final transformed structure sent to the Playwright automation.
interface DocumentoSoporte {
  proveedor_id: string;
  micro_id: string;
  corprecam: Products[];
  reciclemos: Products[];
}

Fields

proveedor_id
string
required
Provider/supplier identifier (typically the comp_asociado from Compra)
micro_id
string
required
Micro route identifier (from Micro.mic_nom)
corprecam
Products[]
required
Array of products for the Corprecam company
reciclemos
Products[]
required
Array of products for the Reciclemos company

Example

{
  "proveedor_id": "900123456",
  "micro_id": "Ruta Norte",
  "corprecam": [
    {
      "codigo": "MAT-001",
      "cantidad": 100,
      "precio": 1500
    },
    {
      "codigo": "MAT-002",
      "cantidad": 50,
      "precio": 2000
    }
  ],
  "reciclemos": [
    {
      "codigo": "MAT-003",
      "cantidad": 75,
      "precio": 1800
    }
  ]
}

Usage

This interface is used as the final payload passed to run_playwright() for automated data entry into the Siigo web interface. The data is transformed from the raw Corprecam data using the transfromDs() utility function.

Type Hierarchy

RowDataPacket (from mysql2)
├── Compra
├── CompraItem
├── Material
└── Micro

Standalone Types
├── Products
└── DocumentoSoporte
    └── contains: Products[]

Notes

  • All database-related interfaces extend RowDataPacket from mysql2 library
  • The DocumentoSoporte interface is the primary data structure for Siigo integration
  • Material IDs from CompraItem.citem_material are used to fetch full Material records
  • The com_micro_ruta from Compra is converted to a number before fetching Micro data

Build docs developers (and LLMs) love