The Sales API handles every part of the transaction lifecycle in StockManager. Authenticated users can record single-product sales or multi-item bulk transactions in one atomic call. The history endpoints expose paginated, filterable records with full product breakdowns. Admin and root users additionally have access to endpoints for retrieving sales in an edit-friendly format and applying corrections to previously recorded transactions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/InnoDev69/StockManager/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/sales
Records a sale for a single product identified by its barcode. Stock is decremented immediately on success.Request Body
The barcode of the product to sell. Must match an active product (
status = 1).Number of units to sell. Must not exceed the product’s current
stock.Payment method label (e.g.
"Efectivo", "Tarjeta"). Defaults to "Efectivo" if omitted.Response
Human-readable confirmation, e.g.
"Venta registrada: Leche Entera 1L x2".Name of the product sold.
Number of units sold.
Total transaction amount (
price × quantity).201 Created
| Status | Meaning |
|---|---|
201 | Sale recorded successfully. |
400 | Missing required fields, invalid quantity, or insufficient stock. |
401 | No active session. |
404 | No active product found for the given barcode. |
POST /api/sales/bulk
Records a multi-product sale in a single atomic database transaction. All stock validations are performed before any inventory is decremented — if any item fails, the entire sale is rejected and no changes are persisted.Request Body
Array of one or more item objects to include in the sale. Must not be empty.
Payment method label for the entire transaction. Defaults to
"Efectivo" if omitted.Response
true when the sale was created successfully.ID of the newly created sale record.
Array of line-item result objects, one per submitted item.
Grand total across all line items, rounded to 2 decimal places.
Example — bulk sale with two products
201 Created
| Status | Meaning |
|---|---|
201 | All items sold and sale recorded. |
400 | Invalid format, empty items array, insufficient stock, or disabled product. |
401 | Session is missing or user ID could not be resolved. |
GET /api/sales
Returns a paginated, filterable list of sales transactions sorted by date descending. Each record includes a breakdown of the products involved.Start date filter (inclusive) in
YYYY-MM-DD format. Filters on the sale’s local date.End date filter (inclusive) in
YYYY-MM-DD format.Partial match filter on the product name. Returns sales that contain at least one product whose name matches the search string.
Partial match filter on the vendor’s
username or email. Case-insensitive.1-based page number.
Sales per page. Clamped between 1 and 100.
Response
Array of sale objects for the current page.
Total number of sales matching the applied filters.
Current page number.
Total number of pages.
Records-per-page value used for this response.
GET /api/sales/:id
Returns the complete details of a single sale transaction by its ID.Path Parameter
The unique integer ID of the sale.
Response
Unique sale ID.
Date and time the sale was recorded.
Array of product line items.
Grand total across all line items.
Username of the vendor who recorded the sale.
Numeric ID of the vendor user.
Payment method used.
| Status | Meaning |
|---|---|
200 | Sale found and returned. |
401 | No active session. |
404 | No sale found with the given ID. |
GET /api/sales/:id/edit
Returns sale data structured for editing. This endpoint is restricted toadmin and root roles and is intended to power administrative correction workflows.
Path Parameter
The unique integer ID of the sale to retrieve for editing.
Response
Returns the sale record as a JSON object suitable for pre-populating an edit form. Structure matches the response fromGET /api/sales/:id with any additional edit-mode fields provided by the database layer.
| Status | Meaning |
|---|---|
200 | Sale data returned in edit format. |
401 | No active session. |
403 | Authenticated user lacks admin or root role. |
404 | No sale found with the given ID. |
500 | Internal error while retrieving sale. |
PUT /api/sales/:id
Updates the items, vendor, and payment method of an existing sale. Requires theadmin or root role. Stock levels are recalculated automatically after the update.
Path Parameter
The unique integer ID of the sale to update.
Request Body
Replacement list of line items for the sale. Must be a non-empty array.
ID of the vendor to associate with the sale.
Updated payment method label.
Response
200 OK
| Status | Meaning |
|---|---|
200 | Sale updated successfully. |
400 | Invalid items format, missing vendor_id or payment_method, or a stock validation error. |
401 | No active session. |
403 | Authenticated user lacks admin or root role. |
500 | Internal error during update. |