Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/corpentunida-org/corpen/llms.txt

Use this file to discover all available pages before exploring further.

The Inventario module provides end-to-end asset lifecycle management for the cooperative: from purchase order registration and automatic asset creation, through warehouse assignments and state changes tracked as signed actas (PDF acts), to maintenance records and warranty alerts. All routes are grouped under /inventario with auth middleware. The module integrates Chart.js dashboards at both the global (tablero) and per-resource level, and supports PDF and Excel exports using DomPDF and PhpSpreadsheet.

Key Sub-modules

Assets (Activos)

The central entity. Each InvActivo is created automatically when a purchase detail line is saved. It holds nombre, codigo_activo, serial, id_Estado, id_ultimo_usuario_asignado, warranty dates, and a link back to its purchase detail. Search and filter by text, warehouse, brand, subgroup, and state.

Warehouses (Bodegas)

InvBodega records define physical storage locations. Assets are associated with a warehouse via the InvReferencia link (id_InvBodegas). The dashboard shows per-warehouse asset counts.

Purchases (Compras)

InvCompra records capture supplier invoices (numero_factura, fecha_factura, total_pago, payment method, optional S3 egreso attachment). Each purchase has detail lines (InvDetalleCompra) that drive automatic InvActivo creation in a single DB transaction.

Movements (Movimientos)

Actas de movimiento group one or more assets under a single codigo_acta. Each acta updates the state and assigned user of every included asset. Signed PDF actas can be uploaded back to S3 via POST /inventario/movimientos/{id}/upload.

Full Sub-module List

ControllerRoute prefixPurpose
TableroInventarioControllerinventario/tableroMain dashboard with Chart.js graphs
CompraControllerinventario/comprasPurchase (invoice) CRUD + auto asset generation
MovimientoControllerinventario/movimientosMovement actas with signed PDF upload
MantenimientoControllerinventario/mantenimientosMaintenance and repair records
ActivoControllerinventario/activosAsset master file with PDF/Excel reports and warranty alerts
MarcaControllerinventario/marcasBrand catalog
BodegaControllerinventario/bodegasWarehouse catalog
EstadoControllerinventario/estadosAsset state catalog
MetodoPagoControllerinventario/metodos-pagoPayment method catalog
ClasificacionControllerinventario/clasificacionHierarchical classification: Grupo → Linea → Tipo → Subgrupo

Database Tables

TablePurpose
inv_activosAsset master records
inv_comprasPurchase/invoice headers
inv_detalle_comprasPurchase line items (with soft deletes)
inv_movimientosMovement acta headers
inv_movimientos_detallePer-asset entries within a movement
inv_mantenimientosMaintenance/repair records
inv_referenciasProduct reference catalog (links marca + subgrupo + bodega)
inv_marcasBrand catalog
inv_bodegasWarehouse catalog
inv_estadosAsset state catalog (also used as movement type)
inv_metodosPayment method catalog
inv_subgruposClassification subgroups
inv_tiposClassification types
inv_lineasClassification lines
inv_gruposClassification groups

Adding a New Asset to Inventory

1

Set up the reference catalog

Before recording a purchase, ensure the asset’s product reference exists. Navigate to GET /inventario/compras/create and use the Nueva Referencia modal (AJAX) to create one if needed.
POST /inventario/referencias/ajax
Body: {
  referencia: required|string|unique:inv_referencias,
  id_InvSubGrupos: required|exists:inv_subgrupos,id,
  id_InvBodegas:   required|exists:inv_bodegas,id,
  id_InvMarcas:    required|exists:inv_marcas,id,
  detalle:         nullable|string
}
Existing references can be updated inline via PUT /inventario/referencias/ajax/{id}.
2

Record the purchase

Submit POST /inventario/compras. The controller wraps everything in a DB transaction:
// Purchase header validation
'cod_ter_proveedor' => 'required|exists:MaeTerceros,cod_ter',
'numero_factura'    => 'required|unique:inv_compras,numero_factura',
'fecha_factura'     => 'required|date',
'total_pago'        => 'required|numeric|min:0',
'id_InvMetodos'     => 'required|exists:inv_metodos,id',
'detalles'          => 'required|array|min:1',
'detalles.*.invReferencias_id' => 'required|exists:inv_referencias,id',
'detalles.*.cantidad'          => 'required|numeric|min:0.01',
'detalles.*.precio'            => 'required|numeric|min:0',
IVA and miscellaneous costs are stored as zero-quantity InvDetalleCompra lines with descriptive detalle values (IVA Total ($) / Otros Costos / Varios ($)).
3

Automatic asset creation

For each purchase detail line, the controller creates (int) $item['cantidad'] InvActivo records in a loop. Each asset is initialized with:
  • nombre → the subgroup name from the reference
  • id_Estado = 1 (first/default state)
  • id_MaeMunicipios = 382
  • invReferencias_id → from the detail
  • fecha_inicio_garantia → the purchase date
  • id_InvDetalleCompras → the detail line ID
for ($i = 0; $i < $cantidadActivos; $i++) {
    InvActivo::create([
        'nombre'                 => $nombreSubgrupo,
        'unidad_medida'          => '1',
        'id_MaeMunicipios'       => 382,
        'id_Estado'              => 1,
        'id_InvDetalleCompras'   => $detalle->id,
        'id_usersRegistro'       => auth()->id(),
        'invReferencias_id'      => $detalle->invReferencias_id,
        'fecha_inicio_garantia'  => $compra->fecha_factura,
    ]);
}
4

Update the asset's technical record

Open GET /inventario/activos/{id}/edit to fill in the remaining fields: codigo_activo, serial, id_Estado, vida_util_meses, warranty end date, assigned user, and municipality. Changes are persisted via PUT /inventario/activos/{id}.
'nombre'                => 'required|string|max:255',
'codigo_activo'         => 'required|string|unique:inv_activos,codigo_activo,{id}',
'invReferencias_id'     => 'required|exists:inv_referencias,id',
'id_Estado'             => 'required',
'fecha_inicio_garantia' => 'nullable|date',
'fecha_fin_garantia'    => 'nullable|date|after_or_equal:fecha_inicio_garantia',
'vida_util_meses'       => 'nullable|integer|min:0',
5

Generate a movement acta

Navigate to GET /inventario/movimientos/create and select one or more assets plus an assignment type (state). Submit POST /inventario/movimientos:
'codigo_acta'              => 'required|unique:inv_movimientos,codigo_acta',
'id_InvTiposRegistros'     => 'required|exists:inv_estados,id',
'id_usersAsignado'         => 'required|exists:users,id',
'activos_seleccionados'    => 'required|array|min:1',
The controller wraps creation in a DB transaction. If the selected state name contains disponible or devuel (case-insensitive), the acta is treated as a return and id_ultimo_usuario_asignado is set to null; otherwise the user is assigned.Download the unsigned acta PDF via GET /inventario/movimientos/{id}/pdf. Upload the signed version via POST /inventario/movimientos/{id}/upload (mimes:pdf, max 5 MB → stored at corpentunida/inventario/{timestamp}_{original_name}).

Warranty Alerts

GET /inventario/activos/alertas surfaces all assets whose fecha_fin_garantia is set and falls on or before 30 days from today (i.e., already expired or expiring soon). The view includes two KPI cards (expired vs. expiring) and a Chart.js pie chart. Filters by search (name or codigo_activo) and estado_garantia (vencido / por_vencer) are available.

Reports

GET /inventario/activos/reporte-pdf?bodega_id=X&marca_id=Y&search=Z
Applies the same filter engine as the index and generates a DomPDF letter landscape report with asset totals. Downloaded as Reporte_Inventario_{Ymd}.pdf.

Classification Hierarchy

Asset categorization follows a four-level hierarchy managed by ClasificacionController:
Grupo → Linea → Tipo → Subgrupo (inv_subgrupos)
Each InvReferencia is linked to one InvSubgrupo. Dynamic AJAX selects are available to populate dependent levels:
GET /inventario/clasificacion/lineas/{grupo_id}    →  inventario.ajax.lineas
GET /inventario/clasificacion/subgrupos/{linea_id} →  inventario.ajax.subgrupos

Build docs developers (and LLMs) love