Skip to main content
All endpoints in this group return responses wrapped in ApiResponse<T>. See the API Overview for the envelope schema.

GET /api/ordenes-compra/list

Returns all purchase orders with their product details.

Example request

curl -X GET http://localhost:8080/api/ordenes-compra/list

Example response

{
  "total": 1,
  "fecha": "2026-04-07T14:00:00.000000",
  "data": [
    {
      "idOrden": 1,
      "fechaEmision": "2026-04-01",
      "vigenciaDias": 30,
      "cantidadSolicitada": 200,
      "estado": "VIGENTE",
      "division": "PERECEDEROS",
      "departamento": "LACTEOS",
      "productos": [
        {
          "idDetalle": 1,
          "producto": {
            "idProducto": 2,
            "nombre": "Leche entera 1L",
            "codigoBarras": "7501055300418",
            "departamento": "LACTEOS",
            "division": "PERECEDEROS",
            "Descripcion": "Leche entera en presentación de 1 litro"
          },
          "cantidadEsperada": 200
        }
      ]
    }
  ]
}

GET /api/ordenes-compra/{id}

Returns a single purchase order by its ID.

Path parameters

id
number
required
Numeric ID of the purchase order (idOrden).

Example request

curl -X GET http://localhost:8080/api/ordenes-compra/1

Example response

{
  "total": 1,
  "fecha": "2026-04-07T14:00:00.000000",
  "data": {
    "idOrden": 1,
    "fechaEmision": "2026-04-01",
    "vigenciaDias": 30,
    "cantidadSolicitada": 200,
    "estado": "VIGENTE",
    "division": "PERECEDEROS",
    "departamento": "LACTEOS",
    "productos": [
      {
        "idDetalle": 1,
        "producto": {
          "idProducto": 2,
          "nombre": "Leche entera 1L",
          "codigoBarras": "7501055300418",
          "departamento": "LACTEOS",
          "division": "PERECEDEROS",
          "Descripcion": "Leche entera en presentación de 1 litro"
        },
        "cantidadEsperada": 200
      }
    ]
  }
}

GET /api/ordenes-compra/{id}/vigente

Checks whether a purchase order is still within its validity window. Returns a plain string message inside the ApiResponse<T> data field. Validity is determined by fechaEmision + vigenciaDias. If today is before that expiry date the order is considered active.

Path parameters

id
number
required
Numeric ID of the purchase order (idOrden).

Example request

curl -X GET http://localhost:8080/api/ordenes-compra/1/vigente

Example response (order is active)

{
  "total": 1,
  "fecha": "2026-04-07T14:00:00.000000",
  "data": "La orden está vigente"
}

Example response (order is expired)

{
  "total": 1,
  "fecha": "2026-04-07T14:00:00.000000",
  "data": "La orden está expirada"
}

POST /api/ordenes-compra

Creates a new purchase order.

Request body

fechaEmision
string
required
Issue date of the order in yyyy-MM-dd format.
vigenciaDias
number
required
Number of days the order remains valid after fechaEmision.
cantidadSolicitada
number
required
Total quantity requested across all line items.
estado
string
Ignored on creation. The server always sets the initial status to VIGENTE regardless of this field.
division
string
required
Division. Must be one of: PERECEDEROS, NO_PERECEDEROS.
departamento
string
required
Department. Must be one of: FRUTAS, VERDURAS, LACTEOS, CARNES, EMBUTIDOS, MULTIPLE, FARMACIA.
productos
object[]
Line items for this order.

Example request

curl -X POST http://localhost:8080/api/ordenes-compra \
  -H "Content-Type: application/json" \
  -d '{
    "fechaEmision": "2026-04-07",
    "vigenciaDias": 30,
    "cantidadSolicitada": 200,
    "estado": "VIGENTE",
    "division": "PERECEDEROS",
    "departamento": "LACTEOS",
    "productos": [
      {
        "producto": { "idProducto": 2 },
        "cantidadEsperada": 200
      }
    ]
  }'

Example response

{
  "total": 1,
  "fecha": "2026-04-07T14:00:00.000000",
  "data": {
    "idOrden": 5,
    "fechaEmision": "2026-04-07",
    "vigenciaDias": 30,
    "cantidadSolicitada": 200,
    "estado": "VIGENTE",
    "division": "PERECEDEROS",
    "departamento": "LACTEOS",
    "productos": [
      {
        "idDetalle": 8,
        "producto": {
          "idProducto": 2,
          "nombre": "Leche entera 1L",
          "codigoBarras": "7501055300418",
          "departamento": "LACTEOS",
          "division": "PERECEDEROS",
          "Descripcion": "Leche entera en presentación de 1 litro"
        },
        "cantidadEsperada": 200
      }
    ]
  }
}

PUT /api/ordenes-compra/{id}/estado

Updates the status of an existing purchase order.

Path parameters

id
number
required
Numeric ID of the purchase order (idOrden).

Request body

nuevoEstado
string
required
New status value. Case-insensitive; converted to uppercase before matching. Must be one of: VIGENTE, EXPIRADA, CERRADA.

Example request

curl -X PUT http://localhost:8080/api/ordenes-compra/5/estado \
  -H "Content-Type: application/json" \
  -d '{ "nuevoEstado": "CERRADA" }'

Example response

{
  "total": 1,
  "fecha": "2026-04-07T14:00:00.000000",
  "data": {
    "idOrden": 5,
    "fechaEmision": "2026-04-07",
    "vigenciaDias": 30,
    "cantidadSolicitada": 200,
    "estado": "CERRADA",
    "division": "PERECEDEROS",
    "departamento": "LACTEOS",
    "productos": []
  }
}

OrdenCompra object schema

idOrden
number
Auto-generated primary key.
fechaEmision
string
Issue date in yyyy-MM-dd format.
vigenciaDias
number
Number of days the order is valid after fechaEmision.
cantidadSolicitada
number
Total quantity requested.
estado
string
Order status enum: VIGENTE, EXPIRADA, or CERRADA.
division
string
Division enum: PERECEDEROS or NO_PERECEDEROS.
departamento
string
Department enum: FRUTAS, VERDURAS, LACTEOS, CARNES, EMBUTIDOS, MULTIPLE, or FARMACIA.
productos
object[]
Line items for this order.