Skip to main content

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:
StateMeaning
PendienteDefault on creation; payment has not been received
RegistradoPayment has been recorded by an advisor or admin
AprobadoPayment has been approved; fecha_pago is set to NOW() automatically

estado_factura

Tracks invoice emission (managed separately from payment receipt):
StateMeaning
PendienteInvoice has not yet been issued
EmitidaInvoice has been issued to the client
The linked accounting service record also has its own state that reflects the work deliverable:
StateMeaning
PendienteService not yet started
En procesoWork is underway
CompletadoDeliverable has been finished

Payment Record Fields

ColumnTypeDescription
id_pagointAuto-increment primary key
id_clienteint (FK)Client the payment belongs to
id_servicioint (FK, optional)References servicios_contables
montodecimal(10,2)Amount in local currency
estado_pagoenumPendiente / Registrado / Aprobado
estado_facturaenumPendiente / Emitida
fecha_pagodatetimeSet 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:
FieldTypeValidation
id_clienteintMust be provided
id_serviciointMust exist in servicios_contables
montodecimalMust be numeric and > 0
{
  "id_cliente": 12,
  "id_servicio": 7,
  "monto": 3500.00
}

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.
RoleFilter 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_pagoSide Effect
PendienteNo additional change
RegistradoNo additional change
Aprobadofecha_pago set to current timestamp
{
  "id_pago": 55,
  "estado_pago": "Aprobado"
}
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.

Build docs developers (and LLMs) love