Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Edwin950821/BodegaX/llms.txt

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

The Sales API records every beer crate transaction in BodegaX. A complete sale is represented by two resource types that work together: a venta (sale header) which captures the overall transaction metadata, and one or more producto_ventas (product line items) which record the quantity and subtotal for each beer brand included in the sale. Creating a sale always requires calling both endpoints in sequence — first POST /ventas/create to obtain the sale UUID, then POST /producto-ventas/create once per product with a quantity greater than zero.

POST /ventas/create

Creates a new sale record in the database. This is the first step in the Despachar Caja (dispatch) workflow, triggered when an admin confirms a client’s crate order. The response contains the sale’s uuid, which is immediately used in the subsequent POST /producto-ventas/create calls.
curl -X POST http://localhost:8080/ventas/create \
  -H "Content-Type: application/json" \
  -d '{
    "uuid_admin": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "uuid_cliente": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "total_venta": 425000,
    "fecha": "2024-11-15T14:32:00.000Z"
  }'

Request Body

uuid_admin
string
required
The UUID of the admin user who is processing the dispatch. Taken from the session object stored in sessionStorage under bodegax.
uuid_cliente
string
required
The UUID of the client receiving the crates. Selected from the client dropdown in the Despachar Caja dialog, which is populated via GET /admin/all filtered to role === 'user'.
total_venta
number
required
The total monetary value of the sale across all products. Calculated on the frontend by summing precio × quantity for every product with a quantity greater than zero.
fecha
string
required
The date and time of the sale. The frontend passes new Date() at the moment the admin confirms dispatch, serialized to an ISO 8601 string.

Response

The newly created sale object, including the server-assigned uuid.
{
  "uuid": "f6a7b8c9-d0e1-2345-fabc-456789012345",
  "uuid_admin": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "uuid_cliente": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "total_venta": 425000,
  "fecha": "2024-11-15T14:32:00.000Z"
}
After a sale is created, the frontend immediately calls POST /producto-ventas/create for each product line item and PUT /productos/edit to decrement the stock count. All three operations must succeed for the sale to be fully recorded. The Despachar Caja dialog closes only after the final stock update completes.

GET /ventas/all

Returns all sale records in the system. Used by the History page to display the transaction log, and by the TerminarJornada dialog to generate end-of-day PDF reports per client. When the logged-in user has role === 'user', the History page filters the result client-side to show only that user’s own sales (history.filter(h => h.uuid_cliente === user.uuid)).
curl http://localhost:8080/ventas/all

Response

An array of sale objects.
uuid
string
Unique identifier for the sale. Used to look up associated product line items from GET /producto-ventas/all.
uuid_cliente
string
UUID of the client who received the crates. Resolved to a name by joining against GET /admin/all.
uuid_admin
string
UUID of the admin who processed the dispatch.
total_venta
number
The total monetary value of the sale.
fecha
string
ISO 8601 date string of when the sale was created.
Example response:
[
  {
    "uuid": "f6a7b8c9-d0e1-2345-fabc-456789012345",
    "uuid_admin": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "uuid_cliente": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "total_venta": 425000,
    "fecha": "2024-11-15T14:32:00.000Z"
  },
  {
    "uuid": "g7b8c9d0-e1f2-3456-abcd-567890123456",
    "uuid_admin": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "uuid_cliente": "c3d4e5f6-a7b8-9012-cdef-123456789012",
    "total_venta": 136000,
    "fecha": "2024-11-15T16:10:00.000Z"
  }
]

POST /producto-ventas/create

Creates a single product line item associated with an existing sale. For every product that had a quantity greater than zero in the Despachar Caja dialog, the frontend calls this endpoint once — passing the sale UUID obtained from the POST /ventas/create response.
curl -X POST http://localhost:8080/producto-ventas/create \
  -H "Content-Type: application/json" \
  -d '{
    "uuid_producto": "c3d4e5f6-a7b8-9012-cdef-123456789012",
    "uuid_venta": "f6a7b8c9-d0e1-2345-fabc-456789012345",
    "cantidad": 5,
    "total_parcial": 425000
  }'

Request Body

uuid_producto
string
required
The UUID of the product being sold. Taken from the product list loaded by GET /productos/all.
uuid_venta
string
required
The UUID of the parent sale. This must be the uuid returned by the POST /ventas/create response for this transaction.
cantidad
number
required
The number of crates of this product included in the sale.
total_parcial
number
required
The subtotal for this product line: cantidad × precio. Calculated on the frontend before the request is sent.

Response

The newly created product-sale line item object.
{
  "uuid": "h8c9d0e1-f2a3-4567-bcde-678901234567",
  "uuid_producto": "c3d4e5f6-a7b8-9012-cdef-123456789012",
  "uuid_venta": "f6a7b8c9-d0e1-2345-fabc-456789012345",
  "cantidad": 5,
  "total_parcial": 425000
}

GET /producto-ventas/all

Returns all product-level sale line items across every transaction. The History page and TerminarJornada dialog use this endpoint to display per-product breakdowns within each sale. After fetching, the frontend resolves uuid_producto to a product name by joining against GET /productos/all, and groups line items by uuid_venta to attach them to their parent sale.
curl http://localhost:8080/producto-ventas/all

Response

An array of product-sale line item objects.
uuid
string
Unique identifier for this line item.
uuid_producto
string
UUID of the product. Join against GET /productos/all using this field to retrieve the brand name and price.
uuid_venta
string
UUID of the parent sale. Use this to group line items by transaction when building the history view.
cantidad
number
Number of crates of this product sold in the transaction.
total_parcial
number
Subtotal for this product within the sale (cantidad × precio).
Example response:
[
  {
    "uuid": "h8c9d0e1-f2a3-4567-bcde-678901234567",
    "uuid_producto": "c3d4e5f6-a7b8-9012-cdef-123456789012",
    "uuid_venta": "f6a7b8c9-d0e1-2345-fabc-456789012345",
    "cantidad": 5,
    "total_parcial": 425000
  },
  {
    "uuid": "i9d0e1f2-a3b4-5678-cdef-789012345678",
    "uuid_producto": "d4e5f6a7-b8c9-0123-defa-234567890123",
    "uuid_venta": "f6a7b8c9-d0e1-2345-fabc-456789012345",
    "cantidad": 3,
    "total_parcial": 216000
  }
]
To reconstruct the complete breakdown of a single sale, filter this array by uuid_venta to get all line items for that transaction, then join each item’s uuid_producto against GET /productos/all to resolve the product name. This is exactly the pattern used by the TerminarJornada PDF generator and the History detail view.

Build docs developers (and LLMs) love