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.

All protected endpoints require a valid JWT token obtained from POST /api/users/login. Include it in the Authorization header:
Authorization: Bearer <your_jwt_token>

Products (Items)

Products (referred to as Item in the database) represent physical goods sold at the autolavado — air fresheners, wax, polish, etc. Every item automatically gets an Inventory record that tracks its current stock quantity.

Get All Products

Public endpoint — no authentication required. Returns the full product catalog, with each item’s current inventory stock nested inside.
curl http://localhost:3000/api/items
Response 200 — Array of Item objects with nested inventory:
id
string
UUID of the product.
name
string
Product name (unique across all items).
priceUsd
number
Unit sale price in USD.
photo
string | null
Filename of the product photo. null if no image has been uploaded.
inventory
object
Nested inventory record containing id, itemId, and quantity (current stock).
[
  {
    "id": "uuid",
    "name": "Ambientador Pino",
    "priceUsd": 2.5,
    "photo": null,
    "inventory": {
      "id": "uuid",
      "itemId": "uuid",
      "quantity": 10
    }
  }
]

Create a Product

🔒 Requires: ADMIN role Creates a new product and atomically creates its linked Inventory record in a single database transaction. The initialQuantity sets the opening stock.
name
string
required
Unique name for the product (e.g. "Ambientador Pino"). Names must be unique across all items.
priceUsd
number
required
Unit sale price in USD.
photo
string
Optional filename of the product image. Can also be uploaded as multipart/form-data with a photo file field.
initialQuantity
number
Starting stock count. Defaults to 0 if not provided.
curl -X POST http://localhost:3000/api/items \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ambientador Pino",
    "priceUsd": 2.5,
    "initialQuantity": 10
  }'
Response 201 — The newly created Item object (the linked Inventory record is created in the same transaction but is not included in this response; fetch it via GET /api/items):
{
  "id": "uuid",
  "name": "Ambientador Pino",
  "priceUsd": 2.5,
  "photo": null
}
Photo uploads are supported via multipart/form-data. When uploading a file, send the image as a photo field alongside the other text fields. The stored filename is returned in the photo field on subsequent reads.

Update a Product

🔒 Requires: ADMIN role Updates one or more metadata fields of an existing product. All fields are optional — only the fields you include are updated.
id
string
required
UUID of the item to update. Use the id returned by GET /api/items.
name
string
New product name. Must be unique across all items.
priceUsd
number
New unit sale price in USD.
photo
string
New photo filename or URL. Can also be uploaded as multipart/form-data with a photo file field.
This endpoint updates product metadata only (name, priceUsd, photo). To adjust the current stock level, use PUT /api/inventory/:itemId.
curl -X PUT http://localhost:3000/api/items/<item-uuid> \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ambientador Pino Nuevo",
    "priceUsd": 3.0
  }'
Response 200 — The updated Item object:
{
  "id": "uuid",
  "name": "Ambientador Pino Nuevo",
  "priceUsd": 3.0,
  "photo": null
}

Inventory Stock

Directly manage the stock quantity for an existing product.

Update Stock Quantity

🔒 Requires: ADMIN role Directly sets the stock quantity for a product’s inventory record. This is an absolute assignment — it replaces the current quantity rather than incrementing or decrementing it. Uses an upsert internally, so it works even if the inventory record was somehow missing.
itemId
string
required
UUID of the Item (product), not the Inventory record itself. Use the id field returned from GET /api/items.
quantity
number
required
The new absolute stock count (e.g. 15 sets stock to exactly 15, regardless of current value).
curl -X PUT http://localhost:3000/api/inventory/<item-uuid> \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "quantity": 15 }'
Response 200 — Updated Inventory object:
{
  "id": "uuid",
  "itemId": "uuid",
  "quantity": 15
}
Automatic stock decrements occur when:
  • (a) A customer places a product in their web order via POST /api/customer/orders — inventory is decremented immediately upon order creation, before payment is received.
  • (b) A service order is finalized via PATCH /api/service-orders/:id/finish — any items defined as service resources (ServiceResource) are automatically decremented.
  • (c) A service order state is manually set to FINALIZADO via PATCH /api/service-orders/:id/state — the same resource decrement logic applies.
Use PUT /api/inventory/:itemId only for manual corrections, opening stock adjustments, or post-physical-count reconciliation.

Expenses

Record financial outflows from the business. Expenses automatically deduct from the AutoLavado’s general balance. When an expense is linked to a product (itemId) with a quantity, it also restocks that product’s inventory — making this the recommended way to record product purchases.

Get All Expenses

🔒 Requires: ADMIN role Returns the full expense history, ordered by most recent first. Each expense includes the linked item details if an itemId was provided.
curl http://localhost:3000/api/expenses \
  -H "Authorization: Bearer <token>"
Response 200 — Array of Expense objects:
id
string
UUID of the expense record.
description
string
Human-readable description of what was purchased or spent.
amountUSD
number
Amount spent in USD. Deducted from the autolavado’s USD balance.
amountBS
number
Amount spent in bolívares. Deducted from the autolavado’s BS balance. Use 0 if not applicable.
quantity
number | null
Number of units purchased. Used to restock inventory when itemId is also provided.
itemId
string | null
UUID of the restocked product. null for general expenses (utilities, fuel, etc.).
date
string
ISO 8601 datetime when the expense was recorded (auto-generated).
[
  {
    "id": "uuid",
    "description": "Compra de 10 ambientadores",
    "amountUSD": 25.0,
    "amountBS": 0,
    "quantity": 10,
    "itemId": "uuid",
    "date": "2026-06-26T15:00:00.000Z",
    "item": {
      "id": "uuid",
      "name": "Ambientador Pino",
      "priceUsd": 2.5
    }
  }
]

Create an Expense

🔒 Requires: ADMIN role Records a new expense. The following side effects occur atomically in a single database transaction:
  1. An Expense record is created.
  2. The specified amounts are deducted from the AutoLavado’s balanceUsd and balanceBs.
  3. If itemId and quantity are provided, the item’s inventory stock is incremented by quantity.
description
string
required
A clear description of the expense (e.g. "Compra de 10 ambientadores pino").
amountUSD
number
required
Amount in USD to deduct from the business balance.
amountBS
number
required
Amount in bolívares to deduct from the business balance. Pass 0 if the purchase was made entirely in USD.
quantity
number
Optional number of units purchased. If provided alongside itemId, the linked product’s stock will be restocked by this amount.
itemId
string
Optional UUID of the product being restocked. Use the id from GET /api/items. Has no effect if quantity is not also provided.
curl -X POST http://localhost:3000/api/expenses \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Compra de 10 ambientadores",
    "amountUSD": 25.0,
    "amountBS": 0,
    "quantity": 10,
    "itemId": "<item-uuid>"
  }'
Response 201 — The newly created Expense object:
{
  "id": "uuid",
  "description": "Compra de 10 ambientadores",
  "amountUSD": 25.0,
  "amountBS": 0,
  "quantity": 10,
  "itemId": "uuid",
  "date": "2026-06-26T15:00:00.000Z"
}
Recommended restocking workflow: Always link an expense to an itemId when recording product purchases. This is the canonical way to restock inventory in SCO Autolavados — it simultaneously updates financial records and product stock in one atomic operation, keeping your balance and inventory in sync.For manual stock corrections (e.g. after a physical count), use PUT /api/inventory/:itemId directly instead.

Build docs developers (and LLMs) love