ContabilidadISV stores all accounting data — consolidations, clients, users, audit logs, and uploaded files — in a single SQL Server database namedDocumentation 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.
ContabilidadISV. The backend uses the mssql Node.js driver with a shared connection pool managed by the Database class in backend/src/models/Database.js.
Prerequisites
- SQL Server 2017 or later (any edition), or SQL Server Express (free tier). The default instance name expected by
Database.jsisSQLEXPRESS. - The database must be named
ContabilidadISV(or match whateverDB_NAMEis set to inbackend/.env). - The SQL Server service must be reachable from the host where the backend runs. See Environment Variables for connection settings.
Setup Steps
If you are using SQL Server Express with a named instance make sure the SQL Server Browser service is running so that the
mssql driver can resolve localhost\SQLEXPRESS.From the project root, run the
init-db script. This executes backend/scripts/initDatabase.js, which creates all required tables, stored procedures, and default data:You should see progress output followed by a success message in the terminal. If the connection fails, verify your
backend/.env values and that SQL Server is accepting TCP/IP connections on the configured port.If you are upgrading an existing installation to include the expanded chart of accounts (55 accounts for HOTELES, 54 for GENERALES), run the migration script directly in SSMS or Azure Data Studio:
This script adds 60 new
_debe / _haber column pairs to the consolidation tables and is safe to run against a database that already contains data — all new columns default to 0.00.Conectando a SQL Server...
Servidor: localhost
Base de datos: ContabilidadISV
✅ Conectado a SQL Server correctamente
Table Overview
| Table | Purpose |
|---|---|
users | Application accounts with id, username, email, password (bcrypt hash), role, created_at, updated_at |
consolidaciones_generales | ISV consolidation records for general-sector clients. Contains 54 accounting accounts × 2 columns (_debe / _haber) = 108 numeric data columns |
consolidaciones_hoteles | ISV/IST consolidation records for hotel-sector clients. Contains 55 accounting accounts (including ist_4 for the 4 % IST rate) × 2 columns = 110 numeric data columns |
clientes | Client company registry: nombre_empresa, rtn, rubro, representante, telefono, email, direccion, logo_url, activo |
system_logs | Immutable audit trail of every significant action, keyed to user_id, with action, description, ip_address, and user_agent columns |
uploaded_files | Metadata for Excel files uploaded for processing: original_name, filename, filepath, filesize, user_id, upload_date |
The two consolidation tables (
consolidaciones_generales and consolidaciones_hoteles) share the same period / client / user metadata columns but differ in the set of account columns present. Always pass tipo: 'GENERALES' | 'HOTELES' when calling consolidation API endpoints so the backend queries the correct table. See Consolidations for details.Connection Pooling
Database.js creates a single shared mssql connection pool via sql.connect():
init() is called lazily — every public method checks if (!this.pool || !this.isConnected) before running its query and calls init() automatically if needed. This means the pool is established on the first request rather than at server startup, and it is shared for the lifetime of the process.
The connection configuration is built from environment variables in the constructor:
Windows Authentication
IfDB_USER is not set in backend/.env, the driver authenticates using the Windows identity of the process running the backend. The constructor detects the missing credential and sets authentication.type = 'default' automatically: