Sales records represent finalized invoices in SCO Autolavados. Each sale captures the USD exchange rate at the moment of transaction, links to an approved payment, and contains one or more line items — either completed service orders or physical products sold from inventory. Creating a sale atomically decrements inventory for any product line items.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.
Endpoints
GET /api/sales
Retrieve the full invoice history ordered by date descending. Each sale includes its nested line items (salesDetails) and the cashier (user) who registered it. If the sale is linked to a payment, the payment and customer details are also included.
Authentication: Public — no token required.
POST /api/sales
Register a finalized sale. This endpoint runs inside a database transaction: it creates theSales record with all SalesDetails in a single operation and then decrements inventory for every product line item. If any product has insufficient stock, the entire transaction is rolled back and an error is returned.
Authentication: Requires a valid JWT token with the ADMIN role.
Request Body
The USD → Bolívares exchange rate at the exact moment of the sale. Fetch this
from
GET /api/autolavado/exchange-rate before calling this endpoint.Total sale amount in USD. Should equal the sum of
cant × UPriceUsd across
all detail lines.ID of the cashier (ADMIN user) registering the sale.
Array of line items. Must contain at least one element. Each item must include
either
serviceOrderId (for a completed wash) or itemId (for a product from
inventory), but not both.Quantity of units for this line item.
Unit price in USD for this line item.
UUID of a
FINALIZADO service order. Mutually exclusive with itemId.UUID of a product from inventory. Mutually exclusive with
serviceOrderId.
The inventory quantity will be decremented by cant inside the transaction.UUID of an approved
Payment record to link to this sale. Optional — walk-in
cash transactions may not have a pre-registered payment.Example — Full sale with a service line and a product line
This is the exact curl taken from the business flow at the point of checkout after María’s wash and store purchase:The POST response includes only the
salesDetails nested array — it does
not include the user or payment relations. Those expanded fields are
only returned by GET /api/sales, which uses a wider include query. To
display cashier or customer details after creating a sale, issue a subsequent
GET request.| Status | Condition |
|---|---|
400 / 500 | Missing required fields (tazaUsd, totalUsd, userId, or empty details) |
500 | Insufficient inventory for a product line item — entire sale is rolled back |
401 | Missing or invalid JWT token |
403 | Caller does not have the ADMIN role |
Sale Object Reference
| Field | Type | Description |
|---|---|---|
id | string | UUID of the sale record |
date | string | ISO 8601 timestamp when the sale was recorded |
tazaUsd | number | Exchange rate (Bs per USD) locked at sale time |
totalUsd | number | Total amount charged in USD |
paymentId | string | null | UUID of the linked Payment, if any |
userId | string | UUID of the cashier who registered the sale |
user | object | Cashier name and lastName |
payment | object | null | Linked payment details including customer info |
salesDetails | array | Line items — see SalesDetails below |
| Field | Type | Description |
|---|---|---|
cant | number | Quantity sold |
UPriceUsd | number | Unit price in USD at time of sale |
serviceOrderId | string | null | Linked service order UUID (for wash lines) |
itemId | string | null | Linked inventory item UUID (for product lines) |