Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Medinaallan/ContabilidadISV/llms.txt

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

The bitácora (audit log) is ContabilidadISV’s system-wide record of all meaningful user and system events. Every create, update, delete, login, and error action is written to the system_logs table in SQL Server by the SystemLog model. The LogsSection React component renders these records in a reverse-chronological timeline visible only to administrators.
Only users with the admin role can access the audit log. Non-admin users who navigate to the Logs section will see an “Acceso Denegado” screen with a red shield icon. The same restriction is enforced at the API level — GET /api/logs requires an admin-scoped JWT token.

What Gets Logged

The table below lists every action type that generates a log entry in the bitácora:
ActionTrigger
USER_LOGINSuccessful user authentication
USER_LOGOUTExplicit user sign-out
consolidacion_createdA new consolidation (Generales or Hoteles) is saved
consolidacion_updatedA consolidation is edited via ConsolidacionEditModal
consolidacion_deletedA consolidation is soft-deleted (activo = 0)
user_createdA new user account is registered
user_updatedA user account is modified
user_deletedA user account is deactivated or removed
cliente_createdA new client (empresa) is added
cliente_updatedA client record is modified
reporte_generatedA report or export is generated
database_backupA database backup operation is performed
errorAn unhandled server-side error is caught and logged
SYSTEM_INITThe backend application starts up
api_request action entries — generated automatically for every HTTP request — are filtered out of the bitácora display. Only meaningful business events from the list above are shown to administrators. This keeps the log focused and readable.

Log Categories

Each log entry is automatically assigned a category by the log formatter based on the action value:
CategoryAssigned to actions
Inicio de SesiónUSER_LOGIN
Cierre de SesiónUSER_LOGOUT
Contabilidadconsolidacion_created, consolidacion_updated, consolidacion_deleted
Gestión de Usuariosuser_created, user_updated, user_deleted
Gestión de Clientescliente_created, cliente_updated
Reportesreporte_generated
SistemaSYSTEM_INIT, database_backup
Erroreserror
Each category also has an associated emoji icon (category_icon) rendered in the timeline to make scanning the feed fast.

Log Priorities

Every log entry carries a priority level that controls the badge color displayed in the UI:
PriorityBadge colorUsed for
normalGreenRoutine successful operations (logins, data reads)
importanteBlueSignificant state changes (consolidation edits, client updates)
criticoRedErrors, deletions, and security-related events
The priority value is set by the log formatter at write time and stored on the system_logs row.

Viewing Logs in the Dashboard

The LogsSection component is accessible from the Bitácora entry in the sidebar (admin users only).

Interface Overview

  • Header card: Shows “Bitácora del Sistema” title and a green “Sistema Activo” indicator.
  • Statistics cards: Displays the total log count and the number of distinct categories currently in the log.
  • Filter bar: Two dropdowns — Todas las categorías and Todas las prioridades — filter the visible entries client-side without re-fetching. An Actualizar button reloads the latest 100 entries from the server.
  • Timeline feed: Each entry shows:
    • Category emoji icon in a circular avatar
    • formatted_title (or raw action as fallback)
    • Priority badge (colored pill with icon)
    • Category badge (gray pill)
    • formatted_message (human-readable description)
    • Username (or “Sistema” for automated events)
    • Friendly date formatted for Honduras UTC−6 (e.g., "15/11/2024 2:32:07 PM")
    • location_info (source IP address, when available)
Entries are loaded in reverse-chronological order (newest first). The timeline is capped at 100 entries per load to keep the view responsive.

API Access

Endpoint: GET /api/logs Requires: Authorization: Bearer <admin_token> Returns paginated log entries with aggregate statistics. Query parameters:
ParameterTypeDescription
limitnumberMaximum number of entries to return (default 100)
userIdnumberFilter entries by a specific user ID
actionstringFilter entries by action type
Example — fetch last 50 consolidation events:
GET /api/logs?limit=50&action=consolidacion_created
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Example response shape:
{
  "logs": [
    {
      "id": 1042,
      "username": "jmendoza",
      "action": "consolidacion_created",
      "description": "Usuario jmendoza creó nueva consolidación GENERALES para cliente ID: 12",
      "ip_address": "192.168.1.45",
      "created_at": "2024-11-15T14:32:07.000Z",
      "formatted_title": "Nueva Consolidación Creada",
      "formatted_message": "Se registró una consolidación Generales para el cliente ID 12.",
      "category": "Contabilidad",
      "priority": "importante",
      "category_icon": "📊",
      "friendly_date": "15/11/2024 2:32:07 PM",
      "location_info": "Desde: 192.168.1.45"
    }
  ],
  "total": 1042,
  "statistics": {
    "total": 1042,
    "today": 14,
    "thisWeek": 87,
    "byCategory": { "consolidacion_created": 420, "USER_LOGIN": 315 },
    "byPriority": { "normal": 700, "importante": 280, "critico": 62 }
  }
}

Consolidations

Every consolidation create, update, and delete generates a bitácora entry.

Clients

Client creation and updates are tracked in the Gestión de Clientes category.

Logs API

REST endpoint for programmatic access to the audit log.

Security Configuration

JWT authentication and role-based access control settings.

Build docs developers (and LLMs) love