Skip to main content

Introduction

The Budget (Presupuestos) API enables comprehensive budget planning and tracking for your fleet operations. Create and manage budgets organized by:
  • Vehicles: Allocate budgets to specific fleet vehicles
  • Departments: Plan budgets by operational area (area_operacion)
  • Categories: Organize expenses by grupos de rubro (category groups) and rubros (subcategories)
  • Fiscal Year: Track budgets annually with support for multiple years

Key Concepts

Budget Structure

Each budget (Presupuesto) consists of:
  1. Header: Main budget information including vehicle, department, category, and fiscal year
  2. Items: Individual budget line items with concepts, frequencies, and amounts
  3. Status: BORRADOR (draft) or APROBADO (approved)

Budget Hierarchy

Empresa (Company)
  └─ Área de Operación (Department)
      └─ Vehículo (Vehicle) [Optional]
          └─ Grupo Rubro (Category Group)
              └─ Rubro (Subcategory)
                  └─ Items (Budget Line Items)
                      └─ Tipo → Concepto

Budget Items

Each budget item contains:
  • Tipo de Presupuesto: Budget type (e.g., maintenance, fuel, supplies)
  • Concepto: Specific concept within the type (e.g., oil change, tire replacement)
  • Frecuencia: Frequency per month
  • Meses Aplicables: Array of months where this applies (1-12)
  • Valor Unitario: Unit price
  • Valor Total: Automatically calculated (unit price × frequency × months count)

Base URL

All budget endpoints are prefixed with:
/api/presupuestos

Authentication

All endpoints require authentication using JWT Bearer tokens.
Authorization: Bearer YOUR_ACCESS_TOKEN

Available Endpoints

Budget Management

  • GET /api/presupuestos - List all budgets with pagination and filters
  • GET /api/presupuestos/:id - Get budget details with items
  • POST /api/presupuestos - Create new budget with items
  • PUT /api/presupuestos/:id - Update budget header
  • DELETE /api/presupuestos/:id - Delete budget and all items

Budget Items

  • POST /api/presupuestos/:id/items - Add item to budget
  • PUT /api/presupuestos/items/:itemId - Update budget item
  • DELETE /api/presupuestos/items/:itemId - Delete budget item

Catalogs

  • GET /api/presupuestos/rubros - Get category master list
  • GET /api/presupuestos/tipos - Get budget types
  • GET /api/presupuestos/conceptos - Get budget concepts
  • POST /api/presupuestos/tipos - Create new budget type (ADMIN only)
  • POST /api/presupuestos/conceptos - Create new concept (ADMIN only)
  • GET /api/presupuestos/filters - Get filter options

Common Response Codes

CodeDescription
200Success
201Created
204No Content (delete successful)
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing token
403Forbidden - Insufficient permissions
404Not Found
500Internal Server Error

Data Types

Presupuesto

interface Presupuesto {
  id?: number;
  empresa_id: number;
  vehiculo_id: number | null;  // Optional - can be department-wide
  area_operacion_id: number;
  grupo_rubro_id: number;      // Category group
  rubro_id: number;            // Subcategory
  anio: number;                // Fiscal year
  estado: 'BORRADOR' | 'APROBADO';
  empleado_id?: number | null; // Employee responsible
  created_at?: string;
}

PresupuestoItem

interface PresupuestoItem {
  id?: number;
  presupuesto_id: number;
  tipo_presupuesto_id: number;    // Budget type
  concepto_presupuesto_id: number; // Concept
  frecuencia_mes: number;          // Times per month
  meses_aplicables: number[];      // Array of months [1-12]
  valor_unitario: number;          // Unit price
  valor_total: number;             // Calculated: unitario × freq × months.length
}

Filtering and Pagination

Most list endpoints support:
  • Pagination: page, limit
  • Filtering: By empresa, vehiculo_id, placa, area_operacion, anio, grupo_rubro, sub_rubro
  • Sorting: sort_by, sort_order (asc/desc)

Next Steps

List Budgets

Query and filter budgets with pagination

Create Budget

Create new budgets with line items

Manage Items

Add, update, and delete budget items

Build docs developers (and LLMs) love