Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Nieto2020/portalhub/llms.txt
Use this file to discover all available pages before exploring further.
The payments module (modules/pagos/) tracks every financial transaction between clients and the consultancy. Each record in the pagos_facturacion table links a client to an accounting service (servicios_contables), records the amount due, and independently tracks the payment state and invoice emission state. Advisors and admins control status transitions; clients have read-only visibility into their own records.
Payment Lifecycle
Two independent state fields govern each payment record:
estado_pago
Tracks whether the money has been received:
| State | Meaning |
|---|
Pendiente | Default on creation; payment has not been received |
Registrado | Payment has been recorded by an advisor or admin |
Aprobado | Payment has been approved; fecha_pago is set to NOW() automatically |
estado_factura
Tracks invoice emission (managed separately from payment receipt):
| State | Meaning |
|---|
Pendiente | Invoice has not yet been issued |
Emitida | Invoice has been issued to the client |
The linked accounting service record also has its own state that reflects the work deliverable:
| State | Meaning |
|---|
Pendiente | Service not yet started |
En proceso | Work is underway |
Completado | Deliverable has been finished |
Payment Record Fields
| Column | Type | Description |
|---|
id_pago | int | Auto-increment primary key |
id_cliente | int (FK) | Client the payment belongs to |
id_servicio | int (FK, optional) | References servicios_contables |
monto | decimal(10,2) | Amount in local currency |
estado_pago | enum | Pendiente / Registrado / Aprobado |
estado_factura | enum | Pendiente / Emitida |
fecha_pago | datetime | Set when estado_pago transitions to Pagado |
Registering a Payment
Endpoint: POST modules/pagos/registrar.php
Before inserting, the endpoint verifies that the referenced id_servicio exists in servicios_contables. monto must be numeric and greater than zero.
Required fields:
| Field | Type | Validation |
|---|
id_cliente | int | Must be provided |
id_servicio | int | Must exist in servicios_contables |
monto | decimal | Must be numeric and > 0 |
Request
Success Response (201)
Invalid Amount (400)
Service Not Found (404)
{
"id_cliente": 12,
"id_servicio": 7,
"monto": 3500.00
}
{
"status": 201,
"message": "Pago registrado correctamente",
"data": {
"id_pago": 55
}
}
{
"status": 400,
"message": "Monto no válido"
}
{
"status": 404,
"message": "Servicio no encontrado"
}
Listing Payments
Endpoint: GET modules/pagos/listar.php
Returns payment records joined with servicios_contables (for estado of the service) and cat_servicios (for nombre_servicio), ordered by id_pago DESC.
| Role | Filter Applied |
|---|
ROL_CLIENTE (3) | Only payments where pf.id_cliente = id_usuario |
ROL_ADMIN (1) / ROL_ASESOR (2) | All payment records |
Response item shape:
{
"id_pago": 55,
"id_cliente": 12,
"id_servicio": 7,
"monto": "3500.00",
"estado_pago": "Pendiente",
"estado_factura": "Pendiente",
"fecha_pago": null,
"estado_servicio": "En proceso",
"nombre_servicio": "Declaración Anual ISR"
}
Updating Payment Status
Endpoint: POST modules/pagos/actualizar_estado.php
Restricted to ROL_ADMIN and ROL_ASESOR. Accepts the id_pago and one of the three valid estado_pago values. When the new state is "Aprobado", the fecha_pago column is automatically set to NOW() in the same UPDATE statement:
$fecha_pago_sql = $estado_pago === "Aprobado" ? ", fecha_pago = NOW()" : "";
$sql = "UPDATE pagos_facturacion
SET estado_pago = :estado_pago
$fecha_pago_sql
WHERE id_pago = :id_pago";
Valid state transitions:
New estado_pago | Side Effect |
|---|
Pendiente | No additional change |
Registrado | No additional change |
Aprobado | fecha_pago set to current timestamp |
Request
Success Response (200)
Invalid State (400)
Access Denied (403)
{
"id_pago": 55,
"estado_pago": "Aprobado"
}
{
"status": 200,
"message": "Estado de pago actualizado correctamente"
}
{
"status": 400,
"message": "Estado de pago no válido"
}
{
"status": 403,
"message": "Acceso denegado. Permisos insuficientes."
}
Only ROL_ADMIN and ROL_ASESOR may call actualizar_estado.php. Clients cannot modify payment states — they will receive a 403 response regardless of the payload.
Payment Detail
Endpoint: GET modules/pagos/detalle.php?id={id_pago}
Returns the full record for a single payment, including the joined service and catalogue information. Access is subject to the same role-based scoping as the list endpoint.
Use the estado_servicio field from the list or detail response to display an end-to-end progress indicator: a client can see whether their service is Pendiente, En proceso, or Completado alongside whether their payment has been acknowledged.