Skip to main content
POST
/
pedido
curl -X POST https://api.example.com/pedido \
  -H "Content-Type: application/json" \
  -d '{
    "codigo": "PED-2024-001",
    "serie": "A001",
    "descripcion": "Customer bulk order",
    "clienteId": 5,
    "formapagoId": 1,
    "detalle": [
      {
        "productoId": 20,
        "cantidad": 100,
        "precio": 15.50
      },
      {
        "productoId": 25,
        "cantidad": 50,
        "precio": 32.00
      }
    ],
    "baseImponible": 2869.49,
    "igv": 516.51,
    "total": 3386.00
  }'
{
  "id": 1,
  "codigo": "PED-2024-001",
  "serie": "A001",
  "descripcion": "Customer bulk order",
  "estado": "PENDIENTE",
  "clienteId": 5,
  "cliente": {
    "id": 5,
    "dni": "12345678",
    "nombre": "Juan",
    "apellido": "Perez"
  },
  "detalle": [
    {
      "id": 1,
      "productoId": 20,
      "cantidad": 100.0,
      "precio": 15.50
    },
    {
      "id": 2,
      "productoId": 25,
      "cantidad": 50.0,
      "precio": 32.00
    }
  ],
  "fechaPedido": "2024-01-15T14:30:00",
  "fechaEntrega": "2024-01-22",
  "baseImponible": 2869.49,
  "igv": 516.51,
  "total": 3386.00,
  "formapagoId": 1,
  "formaPago": {
    "id": 1,
    "nombre": "Cash"
  }
}
Creates a new customer order with automatic state management and delivery date calculation.

Request Body

codigo
string
required
Unique order code/identifier
serie
string
required
Unique series code for the order
descripcion
string
Description of the order
clienteId
long
required
ID of the customer placing the order
formapagoId
long
ID of the payment method
fechaPedido
string
Order date in ISO 8601 format. Defaults to current timestamp if not provided.
fechaEntrega
string
Expected delivery date. Defaults to 1 week after order date if not provided.
estado
string
Order state. Defaults to “PENDIENTE” if not provided.
detalle
array
required
Array of order detail items
baseImponible
double
Taxable base amount (can be provided or calculated)
igv
double
IGV tax amount (can be provided or calculated)
total
double
Total order amount (can be provided or calculated)

Response

id
integer
Unique identifier for the order
codigo
string
Unique order code
serie
string
Unique series code
descripcion
string
Description of the order
estado
string
Current state of the order (e.g., “PENDIENTE”, “PROCESANDO”, “COMPLETADO”)
clienteId
long
ID of the customer
cliente
object
Customer details (populated from customer service)
detalle
array
Array of order detail items
fechaPedido
string
Order date in ISO 8601 format
fechaEntrega
string
Expected delivery date in ISO 8601 date format
baseImponible
double
Total taxable base amount
igv
double
Total IGV tax
total
double
Total order amount
formapagoId
long
Payment method ID
formaPago
object
Payment method details
curl -X POST https://api.example.com/pedido \
  -H "Content-Type: application/json" \
  -d '{
    "codigo": "PED-2024-001",
    "serie": "A001",
    "descripcion": "Customer bulk order",
    "clienteId": 5,
    "formapagoId": 1,
    "detalle": [
      {
        "productoId": 20,
        "cantidad": 100,
        "precio": 15.50
      },
      {
        "productoId": 25,
        "cantidad": 50,
        "precio": 32.00
      }
    ],
    "baseImponible": 2869.49,
    "igv": 516.51,
    "total": 3386.00
  }'
{
  "id": 1,
  "codigo": "PED-2024-001",
  "serie": "A001",
  "descripcion": "Customer bulk order",
  "estado": "PENDIENTE",
  "clienteId": 5,
  "cliente": {
    "id": 5,
    "dni": "12345678",
    "nombre": "Juan",
    "apellido": "Perez"
  },
  "detalle": [
    {
      "id": 1,
      "productoId": 20,
      "cantidad": 100.0,
      "precio": 15.50
    },
    {
      "id": 2,
      "productoId": 25,
      "cantidad": 50.0,
      "precio": 32.00
    }
  ],
  "fechaPedido": "2024-01-15T14:30:00",
  "fechaEntrega": "2024-01-22",
  "baseImponible": 2869.49,
  "igv": 516.51,
  "total": 3386.00,
  "formapagoId": 1,
  "formaPago": {
    "id": 1,
    "nombre": "Cash"
  }
}

Business Logic

Default Values

When creating a new order, the following defaults are applied:
  1. fechaPedido: Current timestamp if not provided
  2. fechaEntrega: One week after order date if not provided
  3. estado: “PENDIENTE” (pending) if not provided

Constraints

  • codigo: Must be unique across all orders
  • serie: Must be unique across all orders

Workflow

  1. Submit order with customer ID, unique identifiers, and detail items
  2. System applies default values for dates and state
  3. Order is persisted with all detail items
  4. Response includes full order details with related entities
Unlike purchases, orders do not automatically calculate totals. The client must provide baseImponible, igv, and total values, or handle calculation logic separately.

Build docs developers (and LLMs) love