> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ugps.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Obtener clientes con deuda agrupada por meses pendientes

> Agrupa facturas cobrables pendientes por cliente y periodo para priorizar cobranza.



## OpenAPI

````yaml /generated/specs/finance.json get /api/v1/billing/invoices/debt-aging
openapi: 3.0.0
info:
  title: Raul API - Finanzas
  description: >-
    Facturas, boletas, ejecuciones de billing, cuentas por pagar y medios de
    pago.
  version: 2.0.0
  contact: {}
servers:
  - url: https://api.raul.ugps.io
    description: Production
security: []
tags: []
paths:
  /api/v1/billing/invoices/debt-aging:
    get:
      tags:
        - Invoices
      summary: Obtener clientes con deuda agrupada por meses pendientes
      description: >-
        Agrupa facturas cobrables pendientes por cliente y periodo para
        priorizar cobranza.
      operationId: InvoiceQueryController_getDebtAging
      parameters:
        - name: payment_status
          required: false
          in: query
          description: >-
            Pago de facturas emitidas con total mayor que cero. Excluye
            borradores, pendientes de emisión, rechazadas, anuladas y notas de
            crédito; se intersecta con el estado comercial seleccionado.
          schema:
            type: string
            enum:
              - paid
              - partial
              - unpaid
        - name: dte_type
          required: false
          in: query
          description: >-
            Tipo guardado en la factura. UNDEFINED selecciona NULL: la emisión
            resuelve la preferencia del receptor legal o infiere el tipo por
            RUT.
          schema:
            type: string
            enum:
              - FACTURA
              - BOLETA
              - UNDEFINED
        - name: type
          required: false
          in: query
          description: Tipo de factura
          schema:
            type: string
            enum:
              - MANUAL
              - MENSUAL
        - name: invoice_type
          required: false
          in: query
          description: Tipo de facturación (regular, consolidada o filial)
          schema:
            type: string
            enum:
              - regular
              - consolidated
              - filial
        - name: client_id
          required: false
          in: query
          description: UUID del cliente
          schema:
            type: string
        - name: search
          required: false
          in: query
          description: Búsqueda por nombre, RUT, email o concepto
          schema:
            type: string
      responses:
        '200':
          description: Clientes con facturas pendientes agrupados por 1, 2, 3 y 4+ meses
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceDebtAgingResponseDto'
      security:
        - bearerAuth: []
components:
  schemas:
    InvoiceDebtAgingResponseDto:
      type: object
      properties:
        generated_at:
          type: string
          format: date-time
        total_clients:
          type: number
        total_invoices:
          type: number
        total_amount_due:
          type: number
        buckets:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceDebtAgingBucketDto'
      required:
        - generated_at
        - total_clients
        - total_invoices
        - total_amount_due
        - buckets
    InvoiceDebtAgingBucketDto:
      type: object
      properties:
        bucket:
          type: string
          enum:
            - one_month
            - two_months
            - three_months
            - four_plus_months
        label:
          type: string
        client_count:
          type: number
        invoice_count:
          type: number
        amount_due:
          type: number
        clients:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceDebtAgingClientDto'
      required:
        - bucket
        - label
        - client_count
        - invoice_count
        - amount_due
        - clients
    InvoiceDebtAgingClientDto:
      type: object
      properties:
        client_id:
          type: object
        receiver_rut:
          type: object
        receiver_name:
          type: string
        receiver_email:
          type: object
        month_count:
          type: number
        invoice_count:
          type: number
        amount_due:
          type: number
        oldest_due_date:
          type: string
          format: date-time
        periods:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceDebtAgingPeriodDto'
      required:
        - receiver_name
        - month_count
        - invoice_count
        - amount_due
        - oldest_due_date
        - periods
    InvoiceDebtAgingPeriodDto:
      type: object
      properties:
        periodo:
          type: string
        invoice_count:
          type: number
        amount_due:
          type: number
        invoices:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceDebtAgingInvoiceDto'
      required:
        - periodo
        - invoice_count
        - amount_due
        - invoices
    InvoiceDebtAgingInvoiceDto:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
        type:
          type: string
        invoice_type:
          type: string
        issue_date:
          type: string
          format: date-time
        due_date:
          type: string
          format: date-time
        periodo:
          type: object
        folio_prefix:
          type: object
        folio_number:
          type: object
        total_amount:
          type: number
        amount_paid:
          type: number
        amount_due:
          type: number
      required:
        - id
        - status
        - type
        - invoice_type
        - issue_date
        - due_date
        - total_amount
        - amount_paid
        - amount_due
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Token de sesión Better Auth para rutas de backoffice; las rutas de
        portal usan su token propio.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.