Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Luisangelebp/SCO_Autolavados/llms.txt

Use this file to discover all available pages before exploring further.

SCO Autolavados uses a commission pool (pozo) model for laundrer payroll. At the end of each day, the system calculates the total commission earned from all finalized service orders, then divides it equally among every laundrer who started a shift that day (isWorkingToday was true at some point during the day). The commission basis — either the full service price or the base service price for that vehicle type — is configurable via the commissionType field on the AutoLavado record.
End-of-day reporting: Call GET /api/payroll/daily with no query params to get today’s running total — useful for a live dashboard tile during business hours. For historical reporting, pass ?date=YYYY-MM-DD to query any past date. Combine with GET /api/dashboard/kpis for a full administrative end-of-day overview.

Endpoints

GET /api/payroll/daily

Calculate the commission pool and per-laundrer payout for a given day. The date range is adjusted for Venezuela Time (VET, UTC-4) so that “today” always maps correctly regardless of the server’s UTC clock. Authentication: Requires a valid JWT token with the ADMIN role.

Query Parameters

date
string (YYYY-MM-DD)
The calendar date to calculate payroll for, in Venezuela Time. Defaults to today (VET) if omitted. Example: 2026-06-26.
curl "http://localhost:3000/api/payroll/daily?date=2026-06-26" \
  -H "Authorization: Bearer <ADMIN_TOKEN>"
# Default — today's running payroll
curl http://localhost:3000/api/payroll/daily \
  -H "Authorization: Bearer <ADMIN_TOKEN>"
Response 200 — Payroll summary:
{
  "date": "2026-06-26T04:00:00.000Z",
  "totalOrdersFinished": 12,
  "totalPozoUsd": 48.0,
  "laundrersCount": 4,
  "payoutPerLaundrer": 12.0,
  "commissionType": "BASE_SERVICE",
  "activeLaundrers": [
    {
      "id": "u1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Pedro",
      "lastName": "Lavador",
      "cedula": "V12345678"
    }
  ]
}
Response when no laundrers were active:
{
  "message": "No hay lavadores activos hoy",
  "totalPozoUsd": 0,
  "laundrersCount": 0,
  "payoutPerLaundrer": 0,
  "activeLaundrers": []
}
Error responses:
StatusCondition
500AutoLavado configuration not found in the database
500Internal calculation error
401Missing or invalid JWT token
403Caller does not have the ADMIN role

Response Field Reference

FieldTypeDescription
datestringISO 8601 start-of-day timestamp (04:00 UTC = 00:00 VET) for the requested date
totalOrdersFinishednumberCount of service orders with state FINALIZADO whose timeEnd falls on the requested date
totalPozoUsdnumberTotal USD flowing into the commission pool — calculated as service.priceUsd × commissionPercent / 100 summed across all finished orders
laundrersCountnumberNumber of laundrers who started a shift on this date (lastShiftStart within the day range, or isWorkingToday was true)
payoutPerLaundrernumbertotalPozoUsd ÷ laundrersCount — each laundrer’s equal share
commissionTypestringEither FULL_PRICE or BASE_SERVICE — mirrors the AutoLavado configuration at query time
activeLaundrersarrayList of laundrer objects (id, name, lastName, cedula) who worked that day

Commission Type Calculation

The commissionType setting on the AutoLavado record controls which price is used as the basis for each finished order’s contribution to the pool:
commissionTypeBasis per order
FULL_PRICEThe actual service.priceUsd of the service that was performed
BASE_SERVICEThe priceUsd of the base service (isBaseService: true) configured for the vehicle’s TypeCar — ignores the actual service performed
In both cases the contribution is multiplied by commissionPercent / 100 (configured on AutoLavado, default 40%). Example: 1 finished order, service price $5.00, commissionPercent = 40, mode = FULL_PRICE:
  • Contribution to pool = 5.00×0.40=5.00 × 0.40 = **2.00**

POST /api/payroll/pay

Register a payroll payment as a company expense. This records the full pool amount as an Expense entry (debited from the AutoLavado balance) so the disbursement appears in financial reports. Authentication: Requires a valid JWT token with the ADMIN role.

Request Body

date
string (YYYY-MM-DD)
The payroll date to pay. Defaults to today if omitted.
curl -X POST http://localhost:3000/api/payroll/pay \
  -H "Authorization: Bearer <ADMIN_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{ "date": "2026-06-26" }'
Response 200:
{
  "message": "Pago de nómina registrado con éxito",
  "expense": {
    "id": "exp-uuid",
    "description": "Pago de Nómina (4 lavadores) - Fecha: 6/26/2026",
    "amountUSD": 48.0,
    "amountBS": 29865.68,
    "date": "2026-06-26T15:30:00.000Z"
  }
}

Payroll Concepts

Read the conceptual guide for a full explanation of the commission pool model, shift management, and how FULL_PRICE vs BASE_SERVICE affects daily payouts.

Build docs developers (and LLMs) love