Skip to content

Detalles

Detalles

Prefijo: /api/detalles
Requiere Auth:
Permiso requerido: ventas, crear

Módulo de detalles de venta. Un detalle representa una línea de un documento de facturación (producto, cantidad, precio, medio de pago). Normalmente se crean junto con la venta, pero este endpoint permite insertar líneas adicionales de forma independiente.


POST /api/detalles/

Descripción: Crea un nuevo detalle de venta
Requiere Auth:
Permiso requerido: ventas, crear

Request:

{
"cod_pro": "PROD001",
"nombre": "Café Latte",
"cantidad": 2,
"cliente_id": "1",
"cliente": "Cliente Test",
"precio": 8500,
"medioPago": "efectivo",
"id_producto": 42,
"numeroBill": 1,
"tipo_impuesto": "IVA",
"valor_base": 14285,
"valor_impuesto": 2715,
"codigo_impuesto": "01",
"id_venta": 100,
"fecha": "2026-07-30",
"hora": "10:30:00",
"idempotency_key": "uuid-opcional"
}

Respuesta exitosa: 201 Created

Response:

{
"id": 123,
"tenant_id": "uuid-tenant",
"cod_pro": "PROD001",
"nombre": "Café Latte",
"cantidad": 2,
"cliente_id": "1",
"cliente": "Cliente Test",
"cufe": "",
"precio": 8500,
"medioPago": "efectivo",
"id_venta": 100
}

cURL:

Terminal window
curl -X POST http://localhost/api/detalles/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{"cod_pro":"PROD001","nombre":"Café Latte","cantidad":2,"cliente_id":"1","precio":8500,"medioPago":"efectivo","id_venta":100}'

Python:

import httpx
resp = httpx.post("http://localhost/api/detalles/",
json={"cod_pro": "PROD001", "nombre": "Café Latte", "cantidad": 2, "cliente_id": "1", "precio": 8500, "medioPago": "efectivo", "id_venta": 100},
headers={"Authorization": f"Bearer :token"})
detalle = resp.json()

JavaScript:

const resp = await fetch('http://localhost/api/detalles/', {
method: 'POST',
headers: {'Content-Type': 'application/json', 'Authorization': `Bearer $:token`},
body: JSON.stringify({cod_pro: 'PROD001', nombre: 'Café Latte', cantidad: 2, cliente_id: '1', precio: 8500, medioPago: 'efectivo', id_venta: 100})
});
const detalle = await resp.json();