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.

The inventory module in SCO Autolavados tracks stock levels for all physical products — cleaning chemicals, lubricants, accessories such as air fresheners, and any other item sold or consumed during services. Inventory is deeply integrated with both the sales/POS system and the service order pipeline, meaning stock is automatically decremented through normal business operations without requiring separate manual adjustments.

Items and Inventory

Every product in the system is represented by an Item record with a 1:1 linked Inventory record. Creating an item via POST /api/items automatically creates the corresponding inventory entry in a single database transaction — there is no separate step to “add” the product to inventory.
POST /api/items
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
  "name": "Ambientador Pino",
  "priceUsd": 2.5,
  "photo": null,
  "initialQuantity": 10
}
FieldTypeRequiredDescription
namestringUnique product name
priceUsdfloatUnit price in USD
photostringURL or path to product image
initialQuantityintegerStarting stock level (defaults to 0 if omitted)

Updating an Item

To update a product’s name, price, or photo, use PUT /api/items/:id. This is an Admin-only endpoint and also accepts multipart/form-data for photo uploads via Multer.
PUT /api/items/:id
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
  "name": "Ambientador Pino Premium",
  "priceUsd": 3.0
}
All fields (name, priceUsd, photo) are optional — only the fields provided will be updated. This endpoint updates the Item record only; to change the stock quantity use PUT /api/inventory/:itemId instead.

Service Resources

Services can declare the consumable inventory items they require via the ServiceResource join table. This links a Services record to one or more Item records with a specified quantity per use. When a service order transitions to FINALIZADO, the system automatically iterates over the service’s resources and decrements each linked item’s inventory quantity. This eliminates the need for manual stock adjustments after every wash. Example: A “Lavado Completo” service might declare:
  • 1× Ambientador Pino
  • 50ml × Shampoo Carrocería
When a service order for “Lavado Completo” is finished, those quantities are decremented from inventory automatically.

Stock Operations

The following operations affect inventory stock levels:
OperationEffect on StockEndpoint
Sale of a product itemDecremented by cant soldPOST /api/sales with itemId in details
Customer order containing a productDecremented at order creationPOST /api/customer/orders
Service order finalized with resourcesDecremented per ServiceResource quantitiesPATCH /api/service-orders/:id/finish
Manual stock adjustmentSet to exact value specifiedPUT /api/inventory/:itemId
Expense with itemId + quantityIncremented (restocking)POST /api/expenses

Manual Stock Adjustment

To set a product’s stock to a specific quantity (e.g., after a physical count):
PUT /api/inventory/:itemId
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
  "quantity": 15
}
This uses an upsert operation — it will create the inventory record if it somehow doesn’t exist yet, or update it if it does.

Restocking via Expenses

When recording a supply purchase as an expense, including the optional itemId and quantity fields will automatically add the purchased quantity to that item’s inventory. This way, a single call to POST /api/expenses both records the financial outflow and updates the stock:
POST /api/expenses
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json
{
  "description": "Compra de 10 ambientadores",
  "amountUSD": 25.0,
  "amountBS": 0,
  "quantity": 10,
  "itemId": "<ID_AMBIENTADOR_PINO>"
}

Viewing Products

GET /api/items returns all products ordered alphabetically by name, with each item’s current stock nested in an inventory object:
GET /api/items
Authorization: Bearer <ADMIN_TOKEN>
Sample response item:
{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "Ambientador Pino",
  "priceUsd": 2.5,
  "photo": null,
  "inventory": {
    "id": "f1e2d3c4-b5a6-7890-abcd-ef0987654321",
    "quantity": 8
  }
}
When a sale or service order attempts to decrement inventory below zero, the operation will throw an "Inventario insuficiente" error and the entire transaction will be rolled back. Ensure adequate stock is maintained to avoid blocking sales.

Inventory API Reference

Full endpoint reference for item creation, inventory updates, and stock management including request/response schemas.

Build docs developers (and LLMs) love