Ajustar stock de varios insumos
POST /api/inventory/create-adjustments
Descripción
Registra hasta 100 ajustes de inventario en una sola llamada, ideal para un conteo físico.
Detalles
Valida todo el lote antes de guardar: si una sola línea tiene un problema no se ajusta ningún insumo y la respuesta indica la posición y el campo de cada error. Cada insumo puede aparecer una sola vez por bodega. Permite una prueba previa que valida sin mover el stock.
Permisos requeridos
inventory.module
Request
| Nombre | Tipo | Requerido | Reglas |
|---|---|---|---|
| dryRun | bool | No |
default:0
|
| items | array | Sí | — |
| items[].ref | string | No |
max:60
|
| items[].inventoryItemId | int | Sí |
min_value:1
|
| items[].storageLocationId | int | Sí |
min_value:1
|
| items[].mode | string | Sí |
enum:add,remove,set
|
| items[].quantity | string | Sí |
decimal
min_value:0
|
| items[].unitId | int | Sí |
min_value:1
|
| items[].note | string | Sí |
min:1
max:255
|
Ejemplo de request
curl -X POST https://restofy.pro/api/inventory/create-adjustments \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <accessToken>" \
-d '{
"items": [
{
"inventoryItemId": 1,
"storageLocationId": 1,
"mode": "string",
"quantity": "string",
"unitId": 1,
"note": "string"
}
]
}'
Los valores son demo: reemplázalos por datos reales del negocio.
Ejemplo de respuesta
Actualizado: 2026-10-09T02:12:12Z
HTTP 200
Request
{
"items": [
{
"inventoryItemId": 27,
"storageLocationId": 4,
"mode": "set",
"quantity": 1200,
"unitId": 2,
"note": "Conteo físico de cierre de semana",
"ref": "arroz"
},
{
"inventoryItemId": 28,
"storageLocationId": 4,
"mode": "set",
"quantity": 350,
"unitId": 2,
"note": "Conteo físico de cierre de semana",
"ref": "frijol"
}
]
}
Response
{
"success": true,
"message": "Ajustes guardados",
"data": {
"dryRun": false,
"items": [
{
"index": 0,
"ref": "arroz",
"inventoryItemId": 27,
"storageLocationId": 4,
"movementId": "2",
"balanceAfter": 1200
},
{
"index": 1,
"ref": "frijol",
"inventoryItemId": 28,
"storageLocationId": 4,
"movementId": "3",
"balanceAfter": 350
}
]
}
}