Skip to main content

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.

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 (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 shared JsonResponse wrapper:
{
  "Success": true,
  "Warning": false,
  "Message": "...",
  "Data": { ... }
}
FieldTypeDescription
Successbooleantrue unless an unhandled exception occurred.
Warningbooleantrue when the operation was blocked by a business rule.
MessagestringHuman-readable result message in Spanish.
DataanyList 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 bodyFAC_DOCUMENTO_PAGORequest
c_dato
string
required
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.
Example request
curl -X POST https://{host}/api/FAC_DOCUMENTO_PAGO/GetAllDocumentoPagoFilters \
  -H "Content-Type: application/json" \
  -d '{ "c_dato": "BOLETA" }'
Example response
{
  "Success": true,
  "Warning": false,
  "Message": null,
  "Data": [
    {
      "id_documento_pago": 1,
      "c_codigo": "BV",
      "t_descripcion": "Boleta de Venta"
    },
    {
      "id_documento_pago": 2,
      "c_codigo": "FA",
      "t_descripcion": "Factura Electrónica"
    }
  ]
}
Response fieldsFAC_DOCUMENTO_PAGODTO
id_documento_pago
integer
Auto-generated primary key of the payment document type.
c_codigo
string
Short alphanumeric code for the document type (e.g., "BV" for Boleta de Venta, "FA" for Factura).
t_descripcion
string
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.
Request bodyFAC_COMPROBANTEReqDTO Full example request
curl -X POST https://{host}/api/FAC_DOCUMENTO_PAGO/addComprobante \
  -H "Content-Type: application/json" \
  -d '{
    "id_documento_pago": 1,
    "id_atencion": 1042,
    "id_tipo_documento": 1,
    "c_numero_de_documento": "45678901",
    "t_direccion": "Av. La Marina 2000, San Miguel, Lima",
    "t_paciente": "García López, María Elena",
    "d_fecha_emis": "2024-06-15T10:30:00",
    "id_condicion_pago": 1,
    "id_moneda": 1,
    "n_porcen_igv": 18,
    "n_porcen_descu": 0,
    "n_total_bruto": 169.49,
    "n_total_descuento": 0.00,
    "n_total_anticipo": 0.00,
    "n_total_gravada": 169.49,
    "n_total_no_gravada": 0.00,
    "n_total_icbper": 0.00,
    "n_total_impuesto": 30.51,
    "n_total_neto": 200.00,
    "t_observacion": "Pago al contado",
    "id_user_registro": 7,
    "DetalleComprobante": [
      {
        "id_tarifario_segus": 10,
        "t_tarifario_segus": "Consulta Médica General",
        "c_codigo_segus": "TAR-CONS-001",
        "id_clasificacion_segus": 2,
        "t_clasificacion_segus": "Consultas",
        "n_precio": 85.00,
        "n_cantidad": 1.00,
        "n_subtotal": 85.00,
        "n_descuento": 0.00,
        "n_total": 85.00
      },
      {
        "id_tarifario_segus": 45,
        "t_tarifario_segus": "Ecografía Abdominal",
        "c_codigo_segus": "TAR-ECOG-001",
        "id_clasificacion_segus": 3,
        "t_clasificacion_segus": "Procedimientos de Diagnóstico",
        "n_precio": 84.49,
        "n_cantidad": 1.00,
        "n_subtotal": 84.49,
        "n_descuento": 0.00,
        "n_total": 84.49
      }
    ]
  }'
Example response (success)
{
  "Success": true,
  "Warning": false,
  "Message": "Registro Satisfactorio",
  "Data": null
}
Example response (business rule block)
{
  "Success": true,
  "Warning": true,
  "Message": "Ya existe el registro",
  "Data": null
}
Example response (business logic failure from Add2)
{
  "Success": true,
  "Warning": true,
  "Message": "No se pudo registrar el comprobante. Verifique los datos e intente nuevamente.",
  "Data": null
}
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:
FAC_COMPROBANTEReqDTO  ←  document header (1 record)
  └── DetalleComprobante[]  ←  line items (1..N records)
The entire structure is submitted in a single POST call and persisted atomically by the 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_segus from the tariff catalog.
Mismatches between the header totals and the sum of DetalleComprobante[].n_total values will not cause a validation error at the API layer, but may produce incorrect comprobantes and reporting discrepancies. Always calculate and verify totals before submitting.

Complete Field Reference

FAC_DOCUMENTO_PAGODTO (search result)

id_documento_pago
integer
Primary key of the payment document type record.
c_codigo
string
Document type code (e.g., "BV", "FA", "RH").
t_descripcion
string
Full name of the document type.

FAC_COMPROBANTEReqDTO — Header summary

FieldTypeRequiredDescription
id_documento_pagointegerDocument type ID.
id_atencionintegerAttendance ID to bill.
id_tipo_documentointegerPayer’s document type (DNI, RUC, etc.).
c_numero_de_documentostringPayer’s document number.
t_pacientestringPayer / patient name for the comprobante header.
d_fecha_emisdatetimeEmission date/time.
id_condicion_pagointegerPayment condition (cash / credit).
id_monedaintegerCurrency (CVN_MONEDA).
n_porcen_igvintegerIGV percentage (standard: 18).
n_total_brutodecimalGross total before discounts and taxes.
n_total_gravadadecimalTaxable base amount.
n_total_impuestodecimalTotal IGV amount.
n_total_netodecimalFinal net payable amount.
id_user_registrointegerRegistering user ID (audit).
DetalleComprobantearrayArray of line item objects (see below).
t_direccionstringPayer address.
t_observacionstringFree-text note for the comprobante.
n_porcen_descuintegerGlobal discount percentage.
n_total_descuentodecimalTotal discount monetary amount.
n_total_anticipodecimalAdvance payment already received.
n_total_no_gravadadecimalNon-taxable amount.
n_total_icbperdecimalICBPER tax amount (plastic bag tax).

FAC_COMPROBANTE_DetalleDTO — Line item summary

FieldTypeRequiredDescription
id_tarifario_segusintegerTariff item ID from CVN_TARIFARIO_SEGUS.
n_preciodecimalUnit price.
n_cantidaddecimalQuantity rendered.
n_subtotaldecimalSubtotal before discount (precio × cantidad).
n_totaldecimalNet line total after discount.
t_tarifario_segusstringTariff item display name.
c_codigo_segusstringSEGUS code of the tariff item.
id_clasificacion_segusintegerSEGUS classification ID.
t_clasificacion_segusstringSEGUS classification name (denormalized).
n_descuentodecimalLine-level monetary discount.
The Response and Response_t fields on FAC_COMPROBANTEReqDTO are output-only fields populated by the business layer after processing. When submitting a new comprobante, you can include them with default values (0 / "") or omit them entirely.

Build docs developers (and LLMs) love