Skip to main content

List All Budgets

Returns paginated budgets with summary statistics including total approved, draft amounts, and categories used.

Endpoint

GET /api/presupuestos

Authentication

Requires valid JWT Bearer token.
Authorization: Bearer YOUR_ACCESS_TOKEN

Query Parameters

page
number
default:"1"
Page number for pagination
limit
number
default:"20"
Number of records per page
empresa
string
Filter by company name (e.g., “SERVIASEO”)
vehiculo_id
number
Filter by vehicle ID
placa
string
Filter by vehicle license plate (e.g., “ABC123”)
area_operacion
string
Filter by operational area/department name
anio
number
Filter by fiscal year (e.g., 2024)
grupo_rubro
string
Filter by category group name
sub_rubro
string
Filter by subcategory name
sort_by
string
default:"id"
Field to sort by (e.g., “id”, “anio”, “created_at”)
sort_order
string
default:"desc"
Sort order: “asc” or “desc”

Response

data
array
Array of budget objects with relations
id
number
Budget ID
empresa_id
number
Company ID
vehiculo_id
number | null
Vehicle ID (null for department-wide budgets)
area_operacion_id
number
Operational area ID
grupo_rubro_id
number
Category group ID
rubro_id
number
Subcategory ID
anio
number
Fiscal year
estado
string
Status: “BORRADOR” or “APROBADO”
empleado_id
number | null
Responsible employee ID
created_at
string
Creation timestamp
control_flota
object
Vehicle information
id
number
Vehicle ID
placa_id
number
License plate ID
clase_vehiculo
string
Vehicle class
areas_placas
object
placa
string
License plate number
areas_operacion
object
Operational area details
nombre
string
Area name
empresas
object
Company details
empresa
string
Company name
grupo
object
Category group
codigo
string
Group code
nombre
string
Group name
rubro
object
Subcategory
codigo
string
Subcategory code
nombre
string
Subcategory name
personal
object
Employee information
tipo
string
Employee type
pagination
object
Pagination metadata
page
number
Current page number
limit
number
Records per page
total
number
Total number of records
totalPages
number
Total number of pages
summary
object
Summary statistics for filtered results
totalAprobado
number
Total amount of approved budgets
totalBorrador
number
Total amount of draft budgets
rubrosUtilizados
number
Number of unique subcategories used
anioVigencia
number
Fiscal year in effect (from filter or current year)

Example Request

curl -X GET "https://api.example.com/api/presupuestos?anio=2024&area_operacion=Recolección&page=1&limit=10" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "data": [
    {
      "id": 1,
      "empresa_id": 1,
      "vehiculo_id": 42,
      "area_operacion_id": 5,
      "grupo_rubro_id": 10,
      "rubro_id": 25,
      "anio": 2024,
      "estado": "APROBADO",
      "empleado_id": 100,
      "created_at": "2024-01-15T10:30:00Z",
      "control_flota": {
        "id": 42,
        "placa_id": 101,
        "clase_vehiculo": "Recolector",
        "areas_placas": {
          "placa": "ABC123"
        }
      },
      "areas_operacion": {
        "id": 5,
        "nombre": "Recolección Norte"
      },
      "empresas": {
        "id": 1,
        "empresa": "SERVIASEO"
      },
      "grupo": {
        "id": 10,
        "codigo": "MANT",
        "nombre": "Mantenimiento"
      },
      "rubro": {
        "id": 25,
        "codigo": "PREV",
        "nombre": "Preventivo"
      },
      "personal": {
        "id": 100,
        "tipo": "Supervisor"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 156,
    "totalPages": 16
  },
  "summary": {
    "totalAprobado": 45000000,
    "totalBorrador": 12500000,
    "rubrosUtilizados": 8,
    "anioVigencia": 2024
  }
}

Get Budget by ID

Retrieve a single budget with all its items and complete relationship details.

Endpoint

GET /api/presupuestos/:id

Authentication

Requires valid JWT Bearer token.

Path Parameters

id
number
required
Budget ID

Response

id
number
Budget ID
empresa_id
number
Company ID
vehiculo_id
number | null
Vehicle ID
area_operacion_id
number
Operational area ID
grupo_rubro_id
number
Category group ID
rubro_id
number
Subcategory ID
anio
number
Fiscal year
estado
string
Status: “BORRADOR” or “APROBADO”
items
array
Budget line items
id
number
Item ID
presupuesto_id
number
Parent budget ID
tipo_presupuesto_id
number
Budget type ID
concepto_presupuesto_id
number
Concept ID
frecuencia_mes
number
Frequency per month
meses_aplicables
array
Array of applicable months (1-12)
valor_unitario
number
Unit price
valor_total
number
Total value (calculated)
tipo
object
Budget type details
nombre
string
Type name
concepto
object
Concept details
nombre
string
Concept name
unidad
string
Unit of measurement

Example Request

curl -X GET "https://api.example.com/api/presupuestos/1" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "id": 1,
  "empresa_id": 1,
  "vehiculo_id": 42,
  "area_operacion_id": 5,
  "grupo_rubro_id": 10,
  "rubro_id": 25,
  "anio": 2024,
  "estado": "APROBADO",
  "empleado_id": 100,
  "created_at": "2024-01-15T10:30:00Z",
  "vehiculo": {
    "id": 42,
    "placa_id": 101,
    "clase_vehiculo": "Recolector",
    "areas_placas": {
      "placa": "ABC123"
    }
  },
  "area": {
    "id": 5,
    "nombre": "Recolección Norte"
  },
  "grupo": {
    "id": 10,
    "codigo": "MANT",
    "nombre": "Mantenimiento",
    "rubro_padre_id": null
  },
  "rubro": {
    "id": 25,
    "codigo": "PREV",
    "nombre": "Preventivo"
  },
  "items": [
    {
      "id": 1,
      "presupuesto_id": 1,
      "tipo_presupuesto_id": 3,
      "concepto_presupuesto_id": 15,
      "frecuencia_mes": 1,
      "meses_aplicables": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
      "valor_unitario": 250000,
      "valor_total": 3000000,
      "tipo": {
        "id": 3,
        "nombre": "Mantenimiento Preventivo"
      },
      "concepto": {
        "id": 15,
        "nombre": "Cambio de Aceite",
        "unidad": "Servicio"
      }
    },
    {
      "id": 2,
      "presupuesto_id": 1,
      "tipo_presupuesto_id": 3,
      "concepto_presupuesto_id": 16,
      "frecuencia_mes": 2,
      "meses_aplicables": [3, 6, 9, 12],
      "valor_unitario": 180000,
      "valor_total": 1440000,
      "tipo": {
        "id": 3,
        "nombre": "Mantenimiento Preventivo"
      },
      "concepto": {
        "id": 16,
        "nombre": "Revisión de Frenos",
        "unidad": "Servicio"
      }
    }
  ]
}

Get Filter Options

Retrieve all available filter options for budgets including years, areas, companies, vehicles, categories, and staff.

Endpoint

GET /api/presupuestos/filters

Authentication

Requires valid JWT Bearer token.

Response

anios
array
Available fiscal years (numbers)
areas
array
Operational areas
id
number
Area ID
nombre
string
Area name
empresas
array
Companies
id
number
Company ID
empresa
string
Company name
vehiculos
array
Vehicles with plates
id
number
Vehicle ID
placa
string
License plate
clase_vehiculo
string
Vehicle class
grupos_rubro
array
Category groups (top-level)
id
number
Group ID
nombre
string
Group name
sub_rubros
array
Subcategories
id
number
Subcategory ID
nombre
string
Subcategory name
personal
array
Staff members
id
number
Employee ID
tipo
string
Employee type

Example Request

curl -X GET "https://api.example.com/api/presupuestos/filters" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "anios": [2024, 2023, 2022],
  "areas": [
    { "id": 5, "nombre": "Recolección Norte" },
    { "id": 6, "nombre": "Recolección Sur" }
  ],
  "empresas": [
    { "id": 1, "empresa": "SERVIASEO" },
    { "id": 2, "empresa": "TRANSPORTES LTDA" }
  ],
  "vehiculos": [
    { "id": 42, "placa": "ABC123", "clase_vehiculo": "Recolector" },
    { "id": 43, "placa": "DEF456", "clase_vehiculo": "Compactador" }
  ],
  "grupos_rubro": [
    { "id": 10, "nombre": "Mantenimiento" },
    { "id": 11, "nombre": "Combustible" }
  ],
  "sub_rubros": [
    { "id": 25, "nombre": "Preventivo" },
    { "id": 26, "nombre": "Correctivo" }
  ],
  "personal": [
    { "id": 100, "tipo": "Supervisor" },
    { "id": 101, "tipo": "Coordinador" }
  ]
}

Error Responses

400 Bad Request

{
  "error": "Invalid parameter: anio must be a number"
}

401 Unauthorized

{
  "error": "Invalid or expired token"
}

404 Not Found

{
  "error": "Presupuesto no encontrado"
}

500 Internal Server Error

{
  "error": "Error en el servidor"
}

Build docs developers (and LLMs) love