Skip to main content

Overview

The table management system allows business owners to configure their restaurant’s table layout, including table names, capacities, and zone assignments.

Table Entity Structure

Each table in the system has the following properties:
class Mesa {
  final String id;           // Unique identifier
  final String nombre;       // Table name (e.g., "Mesa 1", "VIP 5")
  final int capacidad;       // Number of people the table can seat
  final String negocioId;    // Restaurant ID this table belongs to
  final String zona;         // Zone/section (e.g., "Salón", "Terraza")
}
Implementation: source/lib/dominio/entidades/mesa.dart

Table Capacity Logic

Tables use intelligent capacity matching to optimize seating:

Capacity Matching Rules

1

Minimum capacity check

Table capacity must be greater than or equal to the party size
2

Maximum overflow check

Table capacity cannot exceed party size by more than 3 people
3

Optimal assignment

This prevents wasting large tables on small parties

Examples

Table CapacityParty SizeCan Accommodate?Reason
42✅ YesDifference is 2 (≤ 3)
44✅ YesExact match
66✅ YesExact match
84❌ NoDifference is 4 (> 3) - table too large
45❌ NoCapacity too small
63✅ YesDifference is 3 (≤ 3)
bool puedeAcomodar(int numeroPersonas) {
  if (capacidad < numeroPersonas) {
    return false; // Table too small
  }
  
  if (capacidad > numeroPersonas + 3) {
    return false; // Table too large, difference > 3
  }
  
  return true; // Table is suitable
}
Implementation reference: source/lib/dominio/entidades/mesa.dart:16-30

Adding Tables

Business owners can add new tables through the admin panel:

Add Table Process

final cubit = context.read<PantallaDuenoCubit>();

final nuevaMesa = await cubit.agregarMesa(
  negocioId: 'restaurant_id',
  nombre: 'Mesa 5',
  capacidad: 4,
  zona: 'Terraza',
);

if (nuevaMesa != null) {
  print('Table added successfully');
}
Implementation reference: source/lib/presentacion/pantalla_dueno/pantalla_dueno_cubit.dart:262-281

Required Information

When adding a table, you must provide:
A unique identifier for the table within your restaurantExamples:
  • “Mesa 1”, “Mesa 2”, etc.
  • “VIP 1”, “VIP 2”
  • “Terraza A”, “Terraza B”
  • “Barra 1”
Number of people the table can comfortably seatCommon capacities:
  • 2 people (couples/small tables)
  • 4 people (standard tables)
  • 6 people (family tables)
  • 8+ people (large groups)
The section or area where the table is locatedDefault zones:
  • “Salón” (Main dining room)
  • “Terraza” (Outdoor patio)
Custom zones: Owners can define custom zones based on their layout
Use consistent naming conventions for tables to make them easier to identify and manage.

Editing Tables

Update existing table information:
final updatedMesa = mesa.copyWith(
  nombre: 'Mesa VIP 1',
  capacidad: 6,
  zona: 'Salón Principal',
);

final success = await cubit.actualizarMesa(updatedMesa);

if (success) {
  print('Table updated successfully');
}
Implementation reference: source/lib/presentacion/pantalla_dueno/pantalla_dueno_cubit.dart:283-290

Editable Properties

You can modify:
  • ✅ Table name
  • ✅ Table capacity
  • ✅ Zone assignment
You cannot modify:
  • ❌ Table ID (system-generated)
  • ❌ Business ID (fixed to restaurant)

Deleting Tables

Remove tables that are no longer in use:
final success = await cubit.eliminarMesa(mesaId);

if (success) {
  print('Table deleted successfully');
}
Before deleting a table, ensure it has no active reservations. Deleting a table with existing reservations may cause issues with reservation management.
Implementation reference: source/lib/presentacion/pantalla_dueno/pantalla_dueno_cubit.dart:292-299

Viewing Restaurant Tables

Retrieve all tables for your restaurant:
final mesas = await cubit.obtenerMesasDelNegocio(negocioId);

print('Total tables: ${mesas.length}');

for (var mesa in mesas) {
  print('${mesa.nombre} - Capacity: ${mesa.capacidad} - Zone: ${mesa.zona}');
}
Implementation reference: source/lib/presentacion/pantalla_dueno/pantalla_dueno_cubit.dart:258-260

Zone Management

Zones help organize tables by location or purpose.

Default Zones

Every restaurant starts with two default zones:
final zonas = ['Salón', 'Terraza'];
Implementation reference: source/lib/dominio/entidades/negocio.dart:35

Custom Zones

Business owners can add custom zones to match their layout:
final cubit = context.read<PantallaDuenoCubit>();

final nuevasZonas = [
  'Salón Principal',
  'Terraza',
  'Bar',
  'Área VIP',
  'Jardín',
];

final success = await cubit.actualizarZonas(negocio, nuevasZonas);
Implementation reference: source/lib/presentacion/pantalla_dueno/pantalla_dueno_cubit.dart:104-116

Zone Use Cases

Indoor vs Outdoor

Separate indoor seating from outdoor terraces or patios

VIP Areas

Designate special sections for premium seating

Bar Seating

Distinguish bar-height seating from dining tables

Private Rooms

Mark private dining areas or party rooms

Firestore Data Structure

Tables are stored in Firestore with the following structure:
mesas/
  {mesaId}/
    id: "mesa_abc123"
    nombre: "Mesa 5"
    capacidad: 4
    negocioId: "restaurant_xyz"
    zona: "Terraza"
The MesaRepositorio handles all database operations:
  • agregarMesa(Mesa mesa) - Add new table
  • actualizarMesa(Mesa mesa) - Update existing table
  • eliminarMesa(String mesaId) - Delete table
  • obtenerMesasPorNegocio(String negocioId) - Get all tables for a restaurant
  • obtenerMesa(String mesaId) - Get specific table by ID
Implementation: source/lib/adaptadores/adaptador_firestore_mesa.dart

Best Practices

Use a consistent naming scheme for easy identification:
  • Number-based: “Mesa 1”, “Mesa 2”, “Mesa 3”
  • Zone-based: “Terraza A”, “Terraza B”
  • Type-based: “VIP 1”, “Bar 1”
Set realistic capacities that match physical table sizes:
  • Don’t overestimate to avoid cramped seating
  • Consider table shape (round, square, rectangular)
  • Account for accessibility requirements
Organize zones to match your physical layout:
  • Use customer-facing zone names
  • Group similar seating types together
  • Consider different service areas
Keep table configuration current:
  • Update when rearranging layout
  • Remove tables that are permanently retired
  • Add seasonal seating (outdoor tables)

Common Scenarios

Scenario 1: Seasonal Patio Tables

For restaurants with seasonal outdoor seating:
1

Spring setup

Add patio tables with “Terraza” zone when weather permits
2

Summer operations

Tables are available for reservations throughout the season
3

Fall teardown

Remove or disable patio tables when closing outdoor area

Scenario 2: Event Configuration

For special events requiring table rearrangement:
1

Create event zone

Add a custom zone like “Sala de Eventos”
2

Configure tables

Add larger tables or modify capacities for group seating
3

Post-event cleanup

Remove event-specific tables and restore normal configuration

Scenario 3: Renovation

During restaurant renovations:
1

Reduce capacity

Temporarily delete or reduce table count in affected areas
2

Mark zones unavailable

Prevent reservations in renovation zones
3

Restore after completion

Re-add tables with updated layout and capacities

Integration with Reservations

Tables integrate directly with the reservation system:

Availability Checking

When customers search for availability, the system:
  1. Retrieves all tables for the restaurant
  2. Filters tables by zone preference (if specified)
  3. Checks table capacity using puedeAcomodar()
  4. Verifies no conflicting reservations exist
  5. Returns available table options

Reservation Assignment

When creating a reservation:
final reserva = Reserva(
  mesaId: mesa.id,        // Link to specific table
  numeroPersonas: 4,
  fechaHora: DateTime.now(),
  // ... other properties
);
Each reservation is tied to a specific table through the mesaId field.

Troubleshooting

Problem: Table Not Appearing in Availability

Possible causes:
  • Table capacity doesn’t match party size within ±3 people rule
  • Table has conflicting reservation at requested time
  • Table zone doesn’t match customer filter
Solution: Verify table capacity and check existing reservations

Problem: Cannot Delete Table

Possible causes:
  • Table has active or future reservations
  • Database connection issues
  • Insufficient permissions
Solution: Cancel or reassign reservations before deleting table

Problem: Zone Not Displaying

Possible causes:
  • Zone list not updated in business configuration
  • Table assigned to non-existent zone
Solution: Update business zones in configuration panel

Next Steps

Reservation Management

Learn how to manage customer reservations on your tables

Business Configuration

Configure business hours and reservation rules

Build docs developers (and LLMs) love