Orders are the core transaction record in Yakult App. Each order connects a client to a set of purchased products, optionally assigns a delivery driver (repartidor), and moves through a three-stage lifecycle from the moment it is placed until it reaches the customer’s door. Stock is deducted atomically at creation time, status changes trigger push notifications to the assigned driver, and every status transition can send a pre-composed WhatsApp message directly to the client — making the order system the main coordination point between your sales team, warehouse, and field drivers.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/160906/Yakultt-App/llms.txt
Use this file to discover all available pages before exploring further.
Order Lifecycle
Orders follow a strict, one-way state machine. Status can only advance forward — it cannot be reversed.| Status | Meaning |
|---|---|
Pendiente | Order has been created and is awaiting dispatch |
En camino | A driver has picked up the order and is en route |
Entregado | Order has been successfully delivered to the client |
Order Data Structure
A full order object returned by the API looks like this:items array is built by joining orden_items to productos and embedded directly in each order response, so you never need a second request to fetch line details.
API Endpoints
The orders resource is mounted at/api/ordenes.
- List Orders
- Create Order
- Change Status
- Assign Driver
- Delete Order
Retrieve all orders with their items, client details, and assigned personnel. Orders are returned with embedded Response — array of full order objects (see structure above).
items arrays.Transactional Order Creation
Creating an order involves multiple coordinated writes. The backend wraps all of them in a single MySQL transaction so that a failure at any step leaves the database completely unchanged.Client selects products
In the Nueva tab, the sales rep picks a client, optionally assigns a repartidor, then uses quantity counters to add products to the order.
Order header inserted
A row is written to
ordenes with clienteId, vendedorId, repartidorId, total, and estado = 'Pendiente'.Line items inserted
Each item in the
items array is written to orden_items with productoId, cantidad, and precio.Transaction committed
All writes commit together. If anything fails (e.g., a DB constraint violation), the entire transaction rolls back — no partial order, no orphaned items, no phantom stock deduction.
Delivery Driver Assignment
Any order can have arepartidorId assigned at creation time or updated later via PUT /api/ordenes/:id/repartidor. Reassignment works the same way — send the new driver’s ID and they receive an immediate push notification. To remove a driver from an order without assigning a replacement, send { "repartidorId": null }.
Status Change Notifications
When a status change is applied viaPUT /api/ordenes/:id/estado, the backend reads the x-user-id request header to identify who made the change. If that user ID differs from the order’s repartidorId, the assigned driver receives a push notification. If the repartidor themselves sent the request (i.e., x-user-id matches repartidorId), no notification is sent — preventing drivers from receiving redundant alerts for status changes they initiated themselves.
WhatsApp Notifications
The mobile app generates a pre-composed WhatsApp message for each order status. Tapping the WhatsApp button opens the native app with the client’s number and message ready to send — no copy-pasting required. Message templates by status:| Status | Message |
|---|---|
Pendiente | Order confirmation listing all items and the total amount |
En camino | Tu pedido #42 de Yakult ya va en camino 🚚 |
Entregado | Tu pedido #42 fue entregado ✅\n¡Gracias por tu compra! 🥛 |
wa.me format automatically:
52 is prepended only if not already present, so numbers stored with or without the prefix both work correctly.
Cancelling an Order
Mobile UI — Three-Tab Layout
The Orders screen in the mobile app is organized into three tabs, each serving a distinct role in the order workflow:
- Historial — A scrollable list of all orders showing status badge, line items, total, assigned repartidor, and action buttons for status advancement and WhatsApp messaging.
- Nueva — A guided flow for creating a new order: select client → optionally assign repartidor → choose products with quantity counters → confirm and submit.
- Avisos — The notification inbox. An unread-count badge appears on the tab icon whenever new notifications arrive (e.g., new order assignments, status changes).