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

# Presupuesto vs real

> Compara el presupuesto (por defecto el `approved` del año) con lo real de partidas PROCESADAS, por centro y cuenta. `status`: `exceeded` (costo/gasto con ejecución mayor que `expense_threshold`, o real sin presupuesto), `under` (ingreso con ejecución menor que `income_threshold`) u `ok`.

**Permiso requerido:** `accounting.budgets`



## OpenAPI

````yaml /api-reference/openapi.json get /accounting/reports/budget-vs-actual
openapi: 3.0.3
info:
  title: FileXpress API Externa
  version: 1.0.0
  description: >-
    API para integrar sistemas de terceros con FileXpress: facturación, RRHH,
    contabilidad, inventario, proyectos, cuentas por cobrar y pagar, tesorería,
    precios y promociones y caja.
servers:
  - url: https://api.filexpress.app/api/external
    description: Producción
security:
  - ApiKey: []
tags:
  - name: General
  - name: Facturación · Ventas
  - name: Facturación · Compras
  - name: Facturación · Clientes
  - name: Facturación · Proveedores
  - name: Facturación · Productos
  - name: Catálogos
  - name: RRHH · Empleados
  - name: RRHH · Asistencia
  - name: RRHH · Reglas laborales
  - name: RRHH · Horarios
  - name: RRHH · Feriados
  - name: RRHH · Resultados de asistencia
  - name: RRHH · Permisos
  - name: RRHH · Planillas
  - name: Contabilidad
  - name: Inventario
  - name: Proyectos
  - name: Cuentas por cobrar
  - name: Cuentas por pagar
  - name: Tesorería
  - name: Precios y promociones
  - name: Caja
  - name: Puntos de venta
paths:
  /accounting/reports/budget-vs-actual:
    get:
      tags:
        - Contabilidad
      summary: Presupuesto vs real
      description: >-
        Compara el presupuesto (por defecto el `approved` del año) con lo real
        de partidas PROCESADAS, por centro y cuenta. `status`: `exceeded`
        (costo/gasto con ejecución mayor que `expense_threshold`, o real sin
        presupuesto), `under` (ingreso con ejecución menor que
        `income_threshold`) u `ok`.


        **Permiso requerido:** `accounting.budgets`
      parameters:
        - name: fiscal_year
          in: query
          required: false
          description: Año (por defecto el actual).
          schema:
            type: integer
          example: 2026
        - name: budget_id
          in: query
          required: false
          description: Presupuesto a comparar (por defecto el aprobado del año).
          schema:
            type: string
            format: uuid
        - name: month_from
          in: query
          required: false
          description: Mes inicial (1–12).
          schema:
            type: integer
            minimum: 1
            maximum: 12
        - name: month_to
          in: query
          required: false
          description: Mes final (1–12).
          schema:
            type: integer
            minimum: 1
            maximum: 12
        - name: cost_center_ids[]
          in: query
          required: false
          description: Centros a incluir (repetible). Sin él, todo el árbol.
          schema:
            type: array
            items:
              type: string
              format: uuid
        - name: include_children
          in: query
          required: false
          description: Incluye los subcentros (por defecto true).
          schema:
            type: boolean
            default: true
        - name: depth
          in: query
          required: false
          description: Agrupa las cuentas al ancestro de ese nivel.
          schema:
            type: integer
        - name: branch_id
          in: query
          required: false
          description: Limita lo real a una sucursal.
          schema:
            type: string
            format: uuid
        - name: expense_threshold
          in: query
          required: false
          description: Umbral de ejecución de costos y gastos (por defecto 100).
          schema:
            type: number
        - name: income_threshold
          in: query
          required: false
          description: Umbral de ejecución de ingresos (por defecto 100).
          schema:
            type: number
        - name: format
          in: query
          required: false
          description: >-
            `json` (por defecto), `pdf` o `excel` (descarga
            presupuesto-vs-real-AAAA).
          schema:
            type: string
            enum:
              - json
              - pdf
              - excel
            default: json
      responses:
        '200':
          description: Éxito
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - data
                properties:
                  status:
                    type: boolean
                    example: true
                  data:
                    $ref: '#/components/schemas/BudgetVsActual'
              example:
                status: true
                data:
                  title: Presupuesto vs real por centro de costo
                  budget:
                    id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
                    name: Presupuesto 2026
                    fiscal_year: 2026
                    status: approved
                  month_from: 1
                  month_to: 10
                  expense_threshold: 100
                  income_threshold: 100
                  centers:
                    - id: 9d1c5a3e-4b7f-4e2a-9c1d-2f6b8a0e7c11
                      code: '01'
                      name: Ventas
                      level: 1
                      parent_id: null
                      is_leaf: false
                      rows:
                        - account_code: '6102'
                          account_name: Papelería
                          group: expenses
                          budget: 100
                          actual: 120
                          variance: 20
                          execution_pct: 120
                          status: exceeded
                      totals:
                        income:
                          budget: 0
                          actual: 0
                          variance: 0
                          execution_pct: null
                        costs:
                          budget: 0
                          actual: 0
                          variance: 0
                          execution_pct: null
                        expenses:
                          budget: 100
                          actual: 120
                          variance: 20
                          execution_pct: 120
                  totals:
                    income:
                      budget: 0
                      actual: 0
                      variance: 0
                      execution_pct: null
                    costs:
                      budget: 0
                      actual: 0
                      variance: 0
                      execution_pct: null
                    expenses:
                      budget: 100
                      actual: 120
                      variance: 20
                      execution_pct: 120
            application/pdf:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '422':
          description: Sin presupuesto aprobado o formato inválido
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: false
                message: Validation errors
                errors:
                  budget_id:
                    - No hay un presupuesto aprobado para 2026.
        '429':
          $ref: '#/components/responses/E429'
components:
  schemas:
    BudgetVsActual:
      type: object
      properties:
        title:
          type: string
        budget:
          type: object
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            fiscal_year:
              type: integer
            status:
              type: string
          required:
            - id
        month_from:
          type: integer
        month_to:
          type: integer
        expense_threshold:
          type: number
        income_threshold:
          type: number
        centers:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              code:
                type: string
              name:
                type: string
              level:
                type: integer
              parent_id:
                type: string
                format: uuid
                nullable: true
              is_leaf:
                type: boolean
              rows:
                type: array
                items:
                  type: object
                  properties:
                    account_code:
                      type: string
                    account_name:
                      type: string
                    group:
                      type: string
                      description: Grupo.
                      enum:
                        - income
                        - costs
                        - expenses
                    budget:
                      type: number
                    actual:
                      type: number
                    variance:
                      type: number
                    execution_pct:
                      type: number
                      nullable: true
                    status:
                      type: string
                      description: Semáforo.
                      enum:
                        - ok
                        - exceeded
                        - under
                  required:
                    - account_code
                    - group
                    - budget
                    - actual
              totals:
                type: object
                properties:
                  income:
                    type: object
                    properties:
                      budget:
                        type: number
                      actual:
                        type: number
                      variance:
                        type: number
                      execution_pct:
                        type: number
                        nullable: true
                    required:
                      - budget
                      - actual
                      - variance
                  costs:
                    type: object
                    properties:
                      budget:
                        type: number
                      actual:
                        type: number
                      variance:
                        type: number
                      execution_pct:
                        type: number
                        nullable: true
                    required:
                      - budget
                      - actual
                      - variance
                  expenses:
                    type: object
                    properties:
                      budget:
                        type: number
                      actual:
                        type: number
                      variance:
                        type: number
                      execution_pct:
                        type: number
                        nullable: true
                    required:
                      - budget
                      - actual
                      - variance
            required:
              - id
              - rows
              - totals
        totals:
          type: object
          properties:
            income:
              type: object
              properties:
                budget:
                  type: number
                actual:
                  type: number
                variance:
                  type: number
                execution_pct:
                  type: number
                  nullable: true
              required:
                - budget
                - actual
                - variance
            costs:
              type: object
              properties:
                budget:
                  type: number
                actual:
                  type: number
                variance:
                  type: number
                execution_pct:
                  type: number
                  nullable: true
              required:
                - budget
                - actual
                - variance
            expenses:
              type: object
              properties:
                budget:
                  type: number
                actual:
                  type: number
                variance:
                  type: number
                execution_pct:
                  type: number
                  nullable: true
              required:
                - budget
                - actual
                - variance
      required:
        - budget
        - centers
        - totals
    Error:
      type: object
      properties:
        status:
          type: boolean
          example: false
        message:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Errores por campo (solo en validación).
      required:
        - status
        - message
  responses:
    E401:
      description: API Key ausente o inválida
      content:
        application/json:
          example:
            status: false
            message: Invalid API Key.
    E403:
      description: Integración sin el permiso requerido o desactivada
      content:
        application/json:
          example:
            status: false
            message: This integration does not have the 'hr.employees' permission.
            required_scope: hr.employees
    E429:
      description: Límite de peticiones excedido
      content:
        application/json:
          example:
            status: false
            message: Rate limit exceeded. Please try again later.
            rate_limit: 100
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: API Key de la integración (Integraciones → Nueva Integración).

````

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