Create a stock order
Allows to create a stock order with its lines in a single API call.
POST https://eu.golfmanager.com/api/stock/createOrder.json
Parameters
{
"supplier": "int?",
"date": "date?",
"estimatedDeliveryDate": "date?",
"globalDiscount": "float?",
"comments": "string?",
"lines": "array"
}
Example request with numeric product IDs:
{
"supplier": 1,
"date": "2025-01-20",
"estimatedDeliveryDate": "2025-01-25",
"globalDiscount": 5,
"comments": "Pedido de emergencia",
"lines": [
{
"product": 123,
"amount": 10,
"grossUnitCost": 15.50,
"discount": 2
},
{
"product": 456,
"amount": 5,
"grossUnitCost": 20.00
}
]
}
Example request with product object (creates or finds by barcode):
{
"supplier": 1,
"date": "2025-01-20",
"comments": "Pedido con productos nuevos",
"lines": [
{
"product": {
"barcode": "7501234567890",
"name": "Producto Nuevo",
"price": 25.00,
"useStock": true
},
"amount": 5,
"grossUnitCost": 20.00
}
]
}
Response
Returns the complete order with all lines loaded from the database:
{
"id": 42,
"number": "PED-001",
"supplier": 1,
"date": "2025-01-20T00:00:00Z",
"estimatedDeliveryDate": "2025-01-25T00:00:00Z",
"globalDiscount": 5,
"comments": "Pedido de emergencia",
"status": 0,
"amount": 15,
"total": 229.25,
"lines": [
{
"id": 100,
"stockOrder": 42,
"product": 123,
"productName": "Producto A",
"grossUnitCost": 15.50,
"amount": 10,
"discount": 2,
"total": 147.00
},
{
"id": 101,
"stockOrder": 42,
"product": 456,
"productName": "Producto B",
"grossUnitCost": 20.00,
"amount": 5,
"discount": 0,
"total": 95.00
}
]
}
Notes
- The
productfield in each line can be either:- A numeric ID of an existing product
- An object with product data (must include
barcodefield)
- When a product object is provided:
- If a product with that barcode exists, it will be used
- If it doesn’t exist, a new product will be created with the provided fields
- Only the fields you provide will be set on the new product
- The response includes the complete order with all calculated fields
- All lines are saved in a single transaction