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.

All consolidation endpoints require a valid JWT token in the Authorization header (Bearer <token>). Consolidations represent monthly double-entry ledger records for a client. Each record is stored in either consolidaciones_generales or consolidaciones_hoteles depending on the value of tipoRubro supplied in the request. Non-admin users can only retrieve their own records; admin users receive records across all users. Every write operation is automatically registered in the system audit log (Audit Logs).

POST /api/consolidaciones

Create a new consolidation record. The tipoRubro field determines which database table is targeted: HOTELES writes to consolidaciones_hoteles; any other value (including omission) defaults to consolidaciones_generales. usuario_id is automatically set from the authenticated JWT — it is not accepted from the request body. Auth: Bearer token required.

Request Body

tipoRubro
string
required
Determines the target table. Accepted values: GENERALES (default) or HOTELES.
cliente_id
integer
required
ID of the client company this consolidation belongs to. Must reference an existing, active client. See Clientes API.
fecha_inicio
string
required
Period start date in YYYY-MM-DD format (e.g. "2024-01-01").
fecha_fin
string
required
Period end date in YYYY-MM-DD format (e.g. "2024-01-31").
observaciones
string
Optional free-text remarks for this consolidation period.

Accounting Fields — 55 Accounts × Debe + Haber

Each of the 55 chart-of-accounts entries has two numeric fields: one suffixed _debe (debit) and one suffixed _haber (credit). All default to 0 if omitted. Values are stored as DECIMAL(18,2).
caja_bancos_debe
number
Cash and bank accounts — debit side.
caja_bancos_haber
number
Cash and bank accounts — credit side.
ventas_gravadas_15_debe
number
Sales taxable at 15% ISV — debit side.
ventas_gravadas_15_haber
number
Sales taxable at 15% ISV — credit side.
isv_15_ventas_debe
number
ISV collected on 15% sales — debit side.
isv_15_ventas_haber
number
ISV collected on 15% sales — credit side.
ventas_gravadas_18_debe
number
Sales taxable at 18% ISV (alcoholic beverages / tobacco) — debit side.
ventas_gravadas_18_haber
number
Sales taxable at 18% ISV — credit side.
isv_18_ventas_debe
number
ISV collected on 18% sales — debit side.
isv_18_ventas_haber
number
ISV collected on 18% sales — credit side.
ventas_exentas_debe
number
Exempt sales — debit side.
ventas_exentas_haber
number
Exempt sales — credit side.
ventas_exoneradas_debe
number
Zero-rated (exonerated) sales — debit side.
ventas_exoneradas_haber
number
Zero-rated sales — credit side.
ingresos_honorarios_debe
number
Fee / professional services income — debit side.
ingresos_honorarios_haber
number
Fee / professional services income — credit side.
compras_gravadas_15_debe
number
Purchases taxable at 15% ISV — debit side.
compras_gravadas_15_haber
number
Purchases taxable at 15% ISV — credit side.
isv_15_compras_debe
number
ISV paid on 15% purchases — debit side.
isv_15_compras_haber
number
ISV paid on 15% purchases — credit side.
compras_gravadas_18_debe
number
Purchases taxable at 18% ISV — debit side.
compras_gravadas_18_haber
number
Purchases taxable at 18% ISV — credit side.
isv_18_compras_debe
number
ISV paid on 18% purchases — debit side.
isv_18_compras_haber
number
ISV paid on 18% purchases — credit side.
compras_exentas_debe
number
Exempt purchases — debit side.
compras_exentas_haber
number
Exempt purchases — credit side.
compras_exoneradas_debe
number
Zero-rated purchases — debit side.
compras_exoneradas_haber
number
Zero-rated purchases — credit side.
retenciones_isv_debe
number
ISV withholdings — debit side.
retenciones_isv_haber
number
ISV withholdings — credit side.
sueldos_salarios_debe
number
Wages and salaries — debit side.
sueldos_salarios_haber
number
Wages and salaries — credit side.
treceavo_mes_debe
number
Thirteenth-month bonus (aguinaldo) — debit side.
treceavo_mes_haber
number
Thirteenth-month bonus — credit side.
catorceavo_mes_debe
number
Fourteenth-month bonus — debit side.
catorceavo_mes_haber
number
Fourteenth-month bonus — credit side.
prestaciones_laborales_debe
number
Severance and labor benefits — debit side.
prestaciones_laborales_haber
number
Severance and labor benefits — credit side.
ihss_debe
number
IHSS (Instituto Hondureño de Seguridad Social) contributions — debit side.
ihss_haber
number
IHSS contributions — credit side.
aportaciones_infop_debe
number
INFOP (vocational training fund) contributions — debit side.
aportaciones_infop_haber
number
INFOP contributions — credit side.
aportaciones_rap_debe
number
RAP (housing pension fund) contributions — debit side.
aportaciones_rap_haber
number
RAP contributions — credit side.
energia_electrica_debe
number
Electricity expense — debit side.
energia_electrica_haber
number
Electricity expense — credit side.
suministro_agua_debe
number
Water supply expense — debit side.
suministro_agua_haber
number
Water supply expense — credit side.
hondutel_debe
number
Hondutel (telephone) expense — debit side.
hondutel_haber
number
Hondutel expense — credit side.
servicio_internet_debe
number
Internet service expense — debit side.
servicio_internet_haber
number
Internet service expense — credit side.
alquileres_debe
number
Rent expense — debit side.
alquileres_haber
number
Rent expense — credit side.
combustibles_lubricantes_debe
number
Fuel and lubricants — debit side.
combustibles_lubricantes_haber
number
Fuel and lubricants — credit side.
seguros_debe
number
Insurance premiums — debit side.
seguros_haber
number
Insurance premiums — credit side.
impuestos_municipales_debe
number
Municipal taxes — debit side.
impuestos_municipales_haber
number
Municipal taxes — credit side.
impuestos_estatales_debe
number
Central government taxes — debit side.
impuestos_estatales_haber
number
Central government taxes — credit side.
honorarios_profesionales_debe
number
Professional service fees — debit side.
honorarios_profesionales_haber
number
Professional service fees — credit side.
honorarios_contables_debe
number
Accounting fees — debit side.
honorarios_contables_haber
number
Accounting fees — credit side.
honorarios_legales_debe
number
Legal fees — debit side.
honorarios_legales_haber
number
Legal fees — credit side.
gastos_varios_debe
number
Miscellaneous expenses — debit side.
gastos_varios_haber
number
Miscellaneous expenses — credit side.
The remaining accounts follow the same _debe / _haber pattern: compra_medicamentos_insumos, equipo_material_laboratorio, equipo_material_odontologico, honorarios_medicos, mobiliario_equipo, pagos_conatel_fitt, papeleria_utiles, viaticos_gastos_viaje, reparaciones_mantenimiento, insumos_aseo, seguridad_vigilancia, materiales_suministros, publicidad_propaganda, obligaciones_bancarias_cooperativas, intereses_financieros, tasa_seguridad_poblacional, adquisicion_vehiculos, mantenimiento_vehiculos, fletes_encomiendas. All 110 fields (55 × 2) are accepted but optional; they default to 0.

Response

message
string
Human-readable confirmation: "Consolidación creada exitosamente".
data
object
The newly created consolidation record as persisted in the database, including the server-assigned id, the calculated total_debe, total_haber, diferencia, balanceado, and an injected tipo field ("GENERALES" or "HOTELES").

Example

curl -X POST https://api.example.com/api/consolidaciones \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "tipoRubro": "GENERALES",
    "cliente_id": 7,
    "fecha_inicio": "2024-01-01",
    "fecha_fin": "2024-01-31",
    "observaciones": "Enero 2024 — primer cierre",
    "ventas_gravadas_15_debe": 150000.00,
    "isv_15_ventas_haber": 22500.00,
    "caja_bancos_haber": 127500.00
  }'
{
  "message": "Consolidación creada exitosamente",
  "data": {
    "id": 42,
    "tipo": "GENERALES",
    "cliente_id": 7,
    "usuario_id": 3,
    "fecha_inicio": "2024-01-01",
    "fecha_fin": "2024-01-31",
    "observaciones": "Enero 2024 — primer cierre",
    "ventas_gravadas_15_debe": 150000.00,
    "isv_15_ventas_haber": 22500.00,
    "caja_bancos_haber": 127500.00,
    "total_debe": 150000.00,
    "total_haber": 150000.00,
    "diferencia": 0.00,
    "balanceado": true
  }
}

GET /api/consolidaciones

List consolidation records from both consolidaciones_generales and consolidaciones_hoteles (or either table when tipo is specified). Results are sorted by fecha_creacion descending. Non-admin users receive only their own records. Auth: Bearer token required.

Query Parameters

cliente_id
integer
Filter records to a specific client ID.
fecha_desde
string
Inclusive lower bound on fecha_inicio (YYYY-MM-DD).
fecha_hasta
string
Inclusive upper bound on fecha_fin (YYYY-MM-DD).
tipo
string
Restrict results to one table. Accepted values: GENERALES or HOTELES. Omit to return records from both tables.

Response

message
string
"Consolidaciones obtenidas exitosamente"
data
array
Array of consolidation objects. Each element contains all 110 account fields plus joined columns cliente_nombre, cliente_rtn, usuario_nombre, computed total_debe, total_haber, and the injected tipo discriminator.
total
integer
Total number of records in the response array.

Example

curl -X GET "https://api.example.com/api/consolidaciones?cliente_id=7&tipo=GENERALES&fecha_desde=2024-01-01&fecha_hasta=2024-12-31" \
  -H "Authorization: Bearer $TOKEN"
{
  "message": "Consolidaciones obtenidas exitosamente",
  "data": [
    {
      "id": 42,
      "tipo": "GENERALES",
      "cliente_id": 7,
      "cliente_nombre": "Farmacia Honduras S.A.",
      "cliente_rtn": "08019999123456",
      "usuario_id": 3,
      "usuario_nombre": "jperez",
      "fecha_inicio": "2024-01-01",
      "fecha_fin": "2024-01-31",
      "total_debe": 150000.00,
      "total_haber": 150000.00,
      "diferencia": 0.00,
      "balanceado": true,
      "fecha_creacion": "2024-02-05T14:22:10.000Z"
    }
  ],
  "total": 1
}

GET /api/consolidaciones/summary

Returns an aggregate summary across both tables, including record counts, total debit/credit sums, total IST collected (hoteles only), and count of balanced entries. Useful for dashboard widgets. Auth: Bearer token required.

Query Parameters

cliente_id
integer
Scope the summary to a single client.
fecha_desde
string
Filter on fecha_inicio ≥ fecha_desde (YYYY-MM-DD).
fecha_hasta
string
Filter on fecha_fin ≤ fecha_hasta (YYYY-MM-DD).

Response

message
string
"Resumen obtenido exitosamente"
data
object
Aggregate summary object.

GET /api/consolidaciones/ist-statistics

Returns I.S.T. (Impuesto Sobre Turismo) statistics derived exclusively from consolidaciones_hoteles. Useful for tourism-tax reporting dashboards. See Features — Consolidations for details on the hotel accounting schema. Auth: Bearer token required.

Query Parameters

cliente_id
integer
Scope statistics to a single hotel client.
fecha_desde
string
Start of date range (YYYY-MM-DD).
fecha_hasta
string
End of date range (YYYY-MM-DD).

Response

message
string
"Estadísticas de I.S.T. obtenidas exitosamente"
data
object
I.S.T. statistics object as returned by ConsolidacionHoteles.getISTStatistics(). Shape varies by implementation but typically includes totals per IST account, period breakdowns, and per-client aggregates.

GET /api/consolidaciones/cliente/:clienteId

Retrieve all consolidations (from both tables, or filtered by tipo) for a specific client. The client record is validated to exist before querying consolidations. Auth: Bearer token required.

Path Parameters

clienteId
integer
required
The numeric ID of the client.

Query Parameters

tipo
string
Restrict to one table: GENERALES or HOTELES. Omit to return records from both.

Response

message
string
"Consolidaciones del cliente obtenidas exitosamente"
data
object

GET /api/consolidaciones/:id

Fetch a single consolidation by its numeric ID. The tipo query parameter is required because the record can exist in either table and there is no cross-table ID lookup. Auth: Bearer token required.

Path Parameters

id
integer
required
Numeric primary key of the consolidation record.

Query Parameters

tipo
string
required
Which table to query. Must be GENERALES or HOTELES.

Response

message
string
"Consolidación obtenida exitosamente"
data
object
Full consolidation record including all 110 account fields, joined cliente_nombre, cliente_rtn, usuario_nombre, computed total_debe, total_haber, diferencia, balanceado, and the echoed tipo discriminator.

PUT /api/consolidaciones/:id

Update an existing consolidation. Both tipoRubro and motivo are required in the request body. The server compares each submitted field against the current database value and rejects the request if no actual changes are detected. Every changed field is individually logged to BitacoraCambios (see Audit Logs). Auth: Bearer token required.
tipoRubro and motivo are required. The update will be rejected with 400 if either is missing, or if the submitted data is identical to the current record.

Path Parameters

id
integer
required
Numeric ID of the consolidation to update.

Request Body

tipoRubro
string
required
Must be GENERALES or HOTELES — identifies the target table.
motivo
string
required
Free-text reason for the edit. Stored verbatim in the audit log entry for each changed field.
fecha_inicio
string
New period start date. Optional — only include fields you want to change.
fecha_fin
string
New period end date.
observaciones
string
Updated remarks.
[account]_debe
number
Updated debit value for any of the 55 account fields. Fields ending in _debe or _haber are coerced to DECIMAL(18,2); empty strings and null are treated as 0.
[account]_haber
number
Updated credit value for any of the 55 account fields.

Response

message
string
"Consolidación actualizada exitosamente"
data
object
Full updated consolidation record as re-fetched from the database after the update.
changesCount
integer
Number of individual fields that were changed. Each changed field generates one BitacoraCambios record.

DELETE /api/consolidaciones/:id

Soft-delete a consolidation record. The row is not removed from the database — instead, activo is set to 0 and fecha_actualizacion is stamped with the current server time (GETDATE()). The record will no longer appear in any GET responses, but all data is preserved for audit purposes. Auth: Bearer token required.
This is a soft delete. Data is preserved in the database with activo = 0. There is no hard-delete endpoint for consolidations. To recover a soft-deleted record, contact your database administrator.

Path Parameters

id
integer
required
Numeric ID of the consolidation to deactivate.

Query Parameters

tipo
string
required
Which table to target: GENERALES or HOTELES. This parameter is required — the endpoint returns 400 if omitted.

Response

message
string
"Consolidación eliminada exitosamente"
data
object
Confirmation object returned by the model’s delete() method: { "message": "Consolidación eliminada exitosamente" }.

Error Responses

All endpoints return a consistent error envelope on failure:
HTTP StatusMeaning
400Missing or invalid request parameters (e.g. missing tipo, no changes detected)
404Consolidation or referenced client not found
500Unhandled server error; details field contains the original error message
{
  "error": "Parámetro tipo requerido (GENERALES o HOTELES)",
}
{
  "error": "Error interno del servidor",
  "details": "Cannot read properties of null"
}

Build docs developers (and LLMs) love