Crear órdenes de compra
El punto final POST /pic/link/purchase-orders/create
le permite crear órdenes de compra (PO) generadas desde un sistema externo. 👔💼🤝
Authorización
Este endpoint requiere autenticación a través de Basic Auth
con el nombre de usuario y contraseña del backend que lo consumirá. Para crear y configurar un backend, siga el tutorial de backends
Parámetros requeridos
- 👣 Path
- 🔍 Query
- 💪 Body
Esta solicitud no contiene parámetros de tipo Path
Esta solicitud no contiene parámetros de tipo Query
Cuerpo de la solicitud
{
"inputs": [
PurchaseOrder
]
}
Nombre | Tipo | Por defecto | Descripción |
---|---|---|---|
inputs | Array[ PurchaseOrder ] | Required | Lista de órdenes de compra a crear |
PurchaseOrder
{
"header": PurchaseOrderHeader,
"items": [
PurchaseOrderItem
]
}
Nombre | Tipo | Por defecto | Descripción |
---|---|---|---|
header | PurchaseOrderHeader | Required | Datos del encabezado de la orden de compra |
items | Array[ PurchaseOrderItem ] | Required | Lista de puestos de orden de compra |
PurchaseOrderHeader
{
"purchaseOrderId": string,
"purchaseOrderType": PurchaseOrderType,
"accountingEntityId": string,
"vendorBusinessPartnerId": string,
"currencyId": string,
}
Nombre | Tipo | Por defecto | Descripción |
---|---|---|---|
purchaseOrderId | string | Required | Identificador de la orden de compra |
purchaseOrderType | PurchaseOrderType | Required | Tipo de la orden de compra |
accountingEntityId | string | Required | Identificador de la entidad tributaria que procesa la orden de compra |
vendorBusinessPartnerId | string | Required | Identificador del socio comercial que proporciona la orden de compra |
currencyId | string | Required | Moneda de la orden de compra |
El accountingEntityId
y el vendorBusinessPartnerId
deben corresponder a la asignación externa de una entidad contable de AppliQloud y un socio comercial.
PurchaseOrderType
Posibles valores: [LOCAL, IMPORT]
PurchaseOrderItem
{
"itemId": string,
"itemType": PurchaseOrderItemType,
"ascriptionType": PurchaseOrderAscriptionType,
"productGroupId": string,
"productId": string,
"locationId": string | null,
"storageId": string | null,
"requiredDeliveryDate": string | null,
"quantity": int,
"unitId": string,
"netUnitPrice": float
}
Nombre | Tipo | Por defecto | Descripción |
---|---|---|---|
itemId | string | Required | Identificador de artículo |
itemType | PurchaseOrderItemType | Required | Tipo del artículo |
ascriptionType | PurchaseOrderAscriptionType | Required | Tipo de adscripción del artículo |
productGroupId | string | Required | Identificador externo del grupo de productos. |
productId | string | Required | Identificador externo del producto. |
locationId | string | null | null | Identificador externo del lugar de entrega |
storageId | string | null | null | Almacenamiento donde se almacenará el producto. |
requiredDeliveryDate | string | null | null | Fecha de entrega requerida del artículo. |
quantity | int | Required | Cantidad a comprar |
unitId | string | false | Unidad de medida de la cantidad |
netUnitPrice | float | Required | Precio unitario del producto. |
El valor ascriptionType
INVENTORY
solo se permite cuando el valor itemType
es GOODS
. itemTypes
con valor SERVICE
debe tener un valor ascriptionType
de EXPENSE
.
Los campos productGroupId
, productId
y locationId
deben corresponder a valores de mapeo externos de un grupo de productos, producto y ubicación de AppliQloud. El campo LocationId es opcional a menos que el campo itemType
sea INVENTORY
, entonces es obligatorio. Además, el producto al que corresponde el campo productId
debe ser parte del grupo de productos al que corresponde el campo productGroupId
.
PurchaseOrderItemType
Posibles valores: [GOODS, SERVICE]
PurchaseOrderAscriptionType
Posibles valores: [INVENTORY, EXPENSE]
Ejemplos
- cURL
curl --location 'https://<identifier>.api.appliqloud.com/pic/link/purchase-orders/create' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <token>' \
--data '{
"inputs": [
{
"header": {
"purchaseOrderId": "450000001",
"purchaseOrderType": "IMPORT",
"accountingEntityId": "AE1",
"vendorBusinessPartnerId": "9715",
"currencyId": "MXN"
},
"items": [
{
"itemId": "10",
"itemType": "GOODS",
"ascriptionType": "INVENTORY",
"productGroupId": "1",
"productId": "101",
"locationId": "MX-LOC",
"storageId": "123123",
"requiredDeliveryDate": "2024-07-22",
"quantity": 5,
"unitId": "EA",
"netUnitPrice": 6000
}
]
}
]
}'
Respuestas
- ✅ 201
- ⚠️ 201 (with errors)
- 🔒 401
- 🚧 500
Las órdenes de compra fueron creadas exitosamente.
{
"success": [
{
"header": {
"purchaseOrderId": "450000001",
"purchaseOrderStatus": "OPEN",
"purchaseOrderType": "IMPORT",
"accountingEntityId": "AE1",
"vendorBusinessPartnerId": "9715",
"currencyId": "MXN",
"netTotalPrice": 6000.0
},
"items": [
{
"itemId": "10",
"itemType": "GOODS",
"ascriptionType": "EXPENSE",
"productGroupId": "1",
"productId": "101",
"locationId": "MX-LOC",
"storageId": "123123",
"requiredDeliveryDate": "2024-07-22",
"quantity": 5,
"unitId": "EA",
"netUnitPrice": 6000.0,
"netTotalPrice": 30000.0
}
]
}
],
"errors": []
}
Hay un error en la solicitud.
{
"success": [],
"errors": [
{
"traceId": "3095a0a77f80436ba104eb2fc24ba343"
"cause": "InvalidProductException",
"message": "Product with external id 102 for backend SAP_APQ does not exist",
"context": {
"backendId": "SAP_APQ",
"productId": "102"
}
}
]
}
Se requiere autorización o las credenciales no son correctas
{
"traceId": "3095a0a77f80436ba104eb2fc24ba343"
"cause": "UnauthorizedException",
"message": "Authorization required"
}
Error interno de la aplicación (comuníquese con support@appliqloud.com o abra un ticket de soporte)
{
"traceId": "3095a0a77f80436ba104eb2fc24ba343"
"cause": "InternalServerError",
"message": "Internal server error"
}