Every order in La Previa Restobar begins the moment a waiter selects a table and adds items to a cart. From that point, the order travels through up to eight distinct statuses, each owned by a different role — waiter, chef, or system — and every change is persisted to Firebase Realtime Database and simultaneously stored in the local Room database for offline resilience.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/luisumit/LaPreviaRestobar/llms.txt
Use this file to discover all available pages before exploring further.
The Order Data Class
The Order data class is the central record that moves through the entire system. It is serialized to a flat Firebase map for remote storage and mapped to OrderEntity for local Room persistence.
Identity
id — UUID generated at creation. Used as the Firebase node key and Room primary key.Table Link
tableId + tableNumber — both stored for quick display without a join. tableId also drives the assignOrderToTable call.Financial
total is computed via calculateTotal(), which sums all OrderItem.subtotal values.Sync
syncStatus starts as "PENDING" and is flipped to "SYNCED" by SyncManager once the record reaches Firebase.OrderItem Structure
Each line on an order is an OrderItem. The fields are flat (no nested objects) so Firebase can serialize them without custom adapters.
OrderItem(product: Product, quantity: Int) copies all denormalized fields from the Product at the moment the order is placed, including the trackInventory flag. When an order is later confirmed, this flag signals the inventory system to deduct stock automatically.
OrderStatus Enum
The eight statuses map directly to the operational stages of the restaurant floor.
fromString() handles legacy Spanish variants and English aliases, making the system resilient to old records stored with different string values. If an unknown string is encountered, it defaults to PENDING rather than throwing.
Order Lifecycle
The lifecycle below shows every status transition, who performs it, and what side-effects are triggered.PENDING — Order created by waiter
The waiter selects a table, picks items from the product catalog, and taps Enviar Pedido.
CreateOrderUseCase calls orderRepository.createOrder(order) and then tableRepository.assignOrderToTable(order.tableId, order.id), atomically creating the order and linking it to the table.ENVIADO — Order sent to kitchen screen
The waiter confirms the order. The status is updated to
ENVIADO via UpdateOrderStatusUseCase. The kitchen’s chef panel observes the Firebase node in real time and the new order appears immediately on the ChefNotificationPanel.ACEPTADO — Chef acknowledges the order
The chef taps Aceptar on the kitchen screen.
UpdateOrderStatusUseCase writes ACEPTADO to Firebase. The waiter’s screen reflects the change, confirming the kitchen has the ticket.EN_PREPARACION — Kitchen is cooking
The chef moves the order to active preparation. Status becomes
EN_PREPARACION. At this point inventory deduction is triggered for all OrderItem entries where trackInventory = true.LISTO — Order is ready for pickup
The chef marks the order ready. Status becomes
LISTO. The waiter receives a notification and the order card highlights on their panel.ENTREGADO — Food delivered to table
The waiter picks up the food and delivers it to the table. Status becomes
ENTREGADO. The table remains OCUPADA because the guests are still seated and may order more or request the bill.COMPLETED — Bill paid, table freed
The waiter closes the order after payment. Status becomes
COMPLETED. The table status reverts to LIBRE and currentOrderId is cleared.ENTREGADO was added specifically to model the gap between food leaving the kitchen and the bill being paid. Without this status, the waiter had no way to distinguish “food on the table” from “table free.”Use Cases
CreateOrderUseCase
currentOrderId. This ensures the table is never linked to an order that failed to save.
UpdateOrderStatusUseCase
.name string before being sent to Firebase. FirebaseOrderRepositoryImpl.updateOrderStatus writes a partial update containing status and updatedAt, so only those two fields change in the database node rather than the entire document.
Local Persistence: OrderDao
The Room DAO mirrors the full Firebase schema. The syncStatus column drives the sync queue.