Create Service Record
Create a new lubrication service record.
Request Body
Service date in YYYY-MM-DD format
ID of the driver from areas_conductores table
ID of the vehicle plate from areas_placas table
ID of the operational area from areas_operacion table
Washing service cost (can be 0)
Lubrication service cost (can be 0)
Other services cost (can be 0)
Additional notes or comments about the service
The suma field is automatically calculated as lavado + engrase + otros.
Response
ID of the newly created service record
User ID who created the record
Example Request
curl -X POST "https://api.example.com/api/engrases" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fecha": "2024-03-04",
"conductor_id": 5,
"placa_id": 23,
"area_operacion_id": 2,
"lavado": 25000,
"engrase": 45000,
"otros": 10000,
"observaciones": "Servicio completo con cambio de aceite"
}'
Example Response
{
"id": 102,
"fecha": "2024-03-04",
"conductor_id": 5,
"placa_id": 23,
"area_operacion_id": 2,
"lavado": 25000,
"engrase": 45000,
"otros": 10000,
"suma": 80000,
"observaciones": "Servicio completo con cambio de aceite",
"creado_por": "user-uuid-here"
}
Validation Rules
All cost fields (lavado, engrase, otros) must be non-negative numbers.
fecha must be a valid date in YYYY-MM-DD format
conductor_id must reference an existing driver
placa_id must reference an existing vehicle plate
area_operacion_id must reference an existing operational area
- Cost fields cannot be negative
- At least one cost field should be greater than 0
Common Use Cases
Complete Service
Record all three service types:
{
"fecha": "2024-03-04",
"conductor_id": 5,
"placa_id": 23,
"area_operacion_id": 2,
"lavado": 25000,
"engrase": 45000,
"otros": 10000,
"observaciones": "Servicio completo"
}
Washing Only
Record only washing service:
{
"fecha": "2024-03-04",
"conductor_id": 5,
"placa_id": 23,
"area_operacion_id": 2,
"lavado": 25000,
"engrase": 0,
"otros": 0,
"observaciones": "Solo lavado"
}
Lubrication Only
Record only lubrication service:
{
"fecha": "2024-03-04",
"conductor_id": 5,
"placa_id": 23,
"area_operacion_id": 2,
"lavado": 0,
"engrase": 45000,
"otros": 0,
"observaciones": "Cambio de aceite"
}
Error Responses
Missing Required Fields
{
"error": "Missing required fields"
}
Invalid Foreign Key
{
"error": "conductor_id does not exist"
}
{
"error": "Invalid date format. Use YYYY-MM-DD"
}