Skip to main content
Retrieve, search, and filter purchase orders.

List All Purchases

Retrieve all purchases in the system.

Response

Returns an array of purchase objects. See Create Purchase for the full purchase object schema.
curl https://api.example.com/compra
[
  {
    "id": 1,
    "serie": "XYZ",
    "numero": "000123",
    "descripcion": "Monthly office supplies purchase",
    "proveedorId": 1,
    "fechaCompra": "2024-01-15T10:30:00",
    "baseImponible": 2000.0,
    "igv": 360.0,
    "total": 2360.0,
    "detalle": [...]
  }
]

Get Purchase by ID

Retrieve a specific purchase by its ID.

Path Parameters

id
long
required
The unique identifier of the purchase

Response

Returns a single purchase object or 404 if not found.
curl https://api.example.com/compra/1

Search by Date Range

Search purchases within a specific date range.

Query Parameters

inicio
string
required
Start date in ISO 8601 format (e.g., “2024-01-01T00:00:00”)
fin
string
required
End date in ISO 8601 format (e.g., “2024-01-31T23:59:59”)

Response

Returns an array of purchases within the specified date range.
curl "https://api.example.com/compra/buscar-por-fechas?inicio=2024-01-01T00:00:00&fin=2024-01-31T23:59:59"
[
  {
    "id": 1,
    "serie": "XYZ",
    "numero": "000123",
    "fechaCompra": "2024-01-15T10:30:00",
    "total": 2360.0
  }
]

Search by Series

Find all purchases with a specific series code.

Query Parameters

serie
string
required
The 3-letter series code (e.g., “XYZ”)

Response

Returns an array of purchases matching the series.
curl "https://api.example.com/compra/buscar/serie?serie=XYZ"

Search by Number

Find all purchases with a specific number.

Query Parameters

numero
string
required
The 6-digit purchase number (e.g., “000123”)

Response

Returns an array of purchases matching the number.
curl "https://api.example.com/compra/buscar/numero?numero=000123"

Search by Series and Number

Find a specific purchase by its unique series and number combination.

Query Parameters

serie
string
required
The 3-letter series code
numero
string
required
The 6-digit purchase number

Response

Returns a single purchase object or 404 if not found. Since series and number are unique constraints, this returns at most one result.
curl "https://api.example.com/compra/buscar/serie-numero?serie=XYZ&numero=000123"
{
  "id": 1,
  "serie": "XYZ",
  "numero": "000123",
  "descripcion": "Monthly office supplies purchase",
  "total": 2360.0
}

Update Purchase

Update an existing purchase. Totals are automatically recalculated.

Path Parameters

id
long
required
The unique identifier of the purchase to update

Request Body

Provide the complete purchase object with updated fields. See Create Purchase for the full schema.

Response

Returns the updated purchase object with recalculated totals.
curl -X PUT https://api.example.com/compra/1 \
  -H "Content-Type: application/json" \
  -d '{
    "descripcion": "Updated purchase description",
    "proveedorId": 1,
    "formapagoId": 2,
    "detalle": [
      {
        "productoId": 10,
        "cantidad": 150,
        "precio": 11.80
      }
    ]
  }'

Delete Purchase

Delete a purchase and all associated detail items.

Path Parameters

id
long
required
The unique identifier of the purchase to delete

Response

Returns 204 No Content on successful deletion.
curl -X DELETE https://api.example.com/compra/1

Build docs developers (and LLMs) love