Costos
POST
Historial de costo de un insumo
POST /api/costing/list-item-cost-history
Descripción
Listado paginado de los cambios del costo de un insumo.
Detalles
Cada cambio trae el costo anterior, el nuevo y por qué cambió: compra, ajuste o exclusión. Incluye quién hizo el cambio, su motivo y la factura que lo originó cuando aplica. Viene del cambio más reciente al más antiguo.
Permisos requeridos
costs.module
Request
| Nombre | Tipo | Requerido | Reglas |
|---|---|---|---|
| inventoryItemId | int | Sí |
min_value:1
|
Paginación
| defaultLimit | 30 |
| maxLimit | 100 |
| defaultDir | desc |
| withTotal | true |
| allowedSorts | [createdAt, historyId] |
| tieBreak | historyId desc |
Ejemplo de request
curl -X POST https://restofy.pro/api/costing/list-item-cost-history \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <accessToken>" \
-d '{
"inventoryItemId": 1
}'
Los valores son demo: reemplázalos por datos reales del negocio.
Ejemplo de respuesta
Actualizado: 2026-11-02T19:00:57Z
HTTP 200
Request
{
"inventoryItemId": 27
}
Response
{
"success": true,
"message": "Operación realizada correctamente",
"data": {
"history": [
{
"historyId": 4,
"createdAt": "2026-11-02T18:32:17.000Z",
"sourceCode": "purchase",
"previousCostCents": 30,
"costCents": 40,
"reason": null,
"actorName": "App Testing",
"referenceLabel": "FC-6ae8d73160275"
},
{
"historyId": 3,
"createdAt": "2026-11-02T18:32:16.000Z",
"sourceCode": "reset",
"previousCostCents": 100,
"costCents": 30,
"reason": "Factura con precio errado",
"actorName": "App Testing",
"referenceLabel": null
},
{
"historyId": 2,
"createdAt": "2026-11-02T18:32:16.000Z",
"sourceCode": "purchase",
"previousCostCents": 10,
"costCents": 100,
"reason": null,
"actorName": "App Testing",
"referenceLabel": "FC-6ae8d7300ccb3"
},
{
"historyId": 1,
"createdAt": "2026-11-02T18:32:15.000Z",
"sourceCode": "initial",
"previousCostCents": 10,
"costCents": 10,
"reason": null,
"actorName": "App Testing",
"referenceLabel": null
}
],
"pagination": {
"page": 1,
"limit": 30,
"total": 4,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}