Payment documents (comprobantes de pago) are the official billing artifacts — invoices, boletas, or receipts — generated by the clinic when a patient’s medical attendance is fully settled. Each comprobante is anchored to a specific patient attendance (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ttpullima/RomsoftBackEnd2021_v2/llms.txt
Use this file to discover all available pages before exploring further.
id_atencion), carries a header that records the billing party details, applicable taxes, currency, and totals, and contains one or more line items (FAC_COMPROBANTE_DetalleDTO) that itemize every service or procedure rendered, each cross-referenced to the insurance tariff catalog (CVN_TARIFARIO_SEGUS). The FAC_DOCUMENTO_PAGO controller exposes two operations: a filtered search for existing comprobantes, and a compound insert that saves the header and all line items in a single atomic call (Add2 at the business layer).
Common Response Envelope
Every endpoint returns the sharedJsonResponse wrapper:
| Field | Type | Description |
|---|---|---|
Success | boolean | true unless an unhandled exception occurred. |
Warning | boolean | true when the operation was blocked by a business rule. |
Message | string | Human-readable result message in Spanish. |
Data | any | List of FAC_DOCUMENTO_PAGODTO objects on search; null on insert. |
Endpoints
POST /api/FAC_DOCUMENTO_PAGO/GetAllDocumentoPagoFilters
Searches for existing payment documents using a single free-text search parameter. The business layer (FAC_DOCUMENTO_PAGOBL.Instancia.GetAllFacDocumentoPagoFilters) applies the value in c_dato against searchable columns such as document code and description.
Request body — FAC_DOCUMENTO_PAGORequest
Free-text search string. The business layer queries this value against the document code (
c_codigo) and description (t_descripcion) columns. Pass an empty string "" to retrieve all records without filtering.FAC_DOCUMENTO_PAGODTO
Auto-generated primary key of the payment document type.
Short alphanumeric code for the document type (e.g.,
"BV" for Boleta de Venta, "FA" for Factura).Full descriptive name of the payment document type.
POST /api/FAC_DOCUMENTO_PAGO/addComprobante
Creates a new comprobante de pago (billing document) together with all its line items in a single transactional operation. The request body consists of a document header (FAC_COMPROBANTEReqDTO) with an embedded list of detail lines (DetalleComprobante). The business layer calls FAC_DOCUMENTO_PAGOBL.Instancia.Add2, which persists the header and all detail rows atomically.
Before inserting, the controller calls
PruebaBL.Instancia.Exists("0") as a system-level guard check. Under normal operating conditions this check returns false and the insert proceeds. If it returns true the comprobante is not saved and the response contains Warning: true with Message: "Ya existe el registro". Contact your system administrator if you encounter this response unexpectedly.FAC_COMPROBANTEReqDTO
Full example request
When
Add2 returns a non-positive result, the Message is taken directly from resultado.Item2 — the second element of the tuple returned by the business layer. This message may contain a descriptive error from the stored procedure or business rule violated.Header + Detail Pattern
The comprobante follows a classic header / detail (cabecera / detalle) pattern common in Peruvian billing systems:Add2 business method. This means:
- If any line item fails validation, no part of the comprobante is saved.
- The header totals (
n_total_bruto,n_total_neto, etc.) must be pre-calculated by the client and match the sum of line item totals — the API does not recalculate totals server-side. - Each line item must reference a valid
id_tarifario_segusfrom the tariff catalog.
Complete Field Reference
FAC_DOCUMENTO_PAGODTO (search result)
Primary key of the payment document type record.
Document type code (e.g.,
"BV", "FA", "RH").Full name of the document type.
FAC_COMPROBANTEReqDTO — Header summary
| Field | Type | Required | Description |
|---|---|---|---|
id_documento_pago | integer | ✅ | Document type ID. |
id_atencion | integer | ✅ | Attendance ID to bill. |
id_tipo_documento | integer | ✅ | Payer’s document type (DNI, RUC, etc.). |
c_numero_de_documento | string | ✅ | Payer’s document number. |
t_paciente | string | ✅ | Payer / patient name for the comprobante header. |
d_fecha_emis | datetime | ✅ | Emission date/time. |
id_condicion_pago | integer | ✅ | Payment condition (cash / credit). |
id_moneda | integer | ✅ | Currency (CVN_MONEDA). |
n_porcen_igv | integer | ✅ | IGV percentage (standard: 18). |
n_total_bruto | decimal | ✅ | Gross total before discounts and taxes. |
n_total_gravada | decimal | ✅ | Taxable base amount. |
n_total_impuesto | decimal | ✅ | Total IGV amount. |
n_total_neto | decimal | ✅ | Final net payable amount. |
id_user_registro | integer | ✅ | Registering user ID (audit). |
DetalleComprobante | array | ✅ | Array of line item objects (see below). |
t_direccion | string | Payer address. | |
t_observacion | string | Free-text note for the comprobante. | |
n_porcen_descu | integer | Global discount percentage. | |
n_total_descuento | decimal | Total discount monetary amount. | |
n_total_anticipo | decimal | Advance payment already received. | |
n_total_no_gravada | decimal | Non-taxable amount. | |
n_total_icbper | decimal | ICBPER tax amount (plastic bag tax). |
FAC_COMPROBANTE_DetalleDTO — Line item summary
| Field | Type | Required | Description |
|---|---|---|---|
id_tarifario_segus | integer | ✅ | Tariff item ID from CVN_TARIFARIO_SEGUS. |
n_precio | decimal | ✅ | Unit price. |
n_cantidad | decimal | ✅ | Quantity rendered. |
n_subtotal | decimal | ✅ | Subtotal before discount (precio × cantidad). |
n_total | decimal | ✅ | Net line total after discount. |
t_tarifario_segus | string | Tariff item display name. | |
c_codigo_segus | string | SEGUS code of the tariff item. | |
id_clasificacion_segus | integer | SEGUS classification ID. | |
t_clasificacion_segus | string | SEGUS classification name (denormalized). | |
n_descuento | decimal | Line-level monetary discount. |