feat: New Open Tab dialog with search and optional customer email. Drinks are now grouped per order. Payments trigger cha-ching and money rain.

This commit is contained in:
2026-10-28 02:11:32 +01:00
parent 1aee0541c4
commit 29ceb51177
41 changed files with 2771 additions and 812 deletions
+33 -2
View File
@@ -55,6 +55,9 @@ class BarTabs extends Table {
TextColumn get customerName => text()();
/// Optional, entered when the customer was added.
TextColumn get email => text().nullable()();
DateTimeColumn get openedAt => dateTime()();
IntColumn get version => integer().withDefault(const Constant(0))();
@@ -95,6 +98,10 @@ class TabItemPurchases extends Table {
DateTimeColumn get removedAt => dateTime().nullable()();
/// The order this drink was rung up in: drinks ordered together are shown
/// together. Null for drinks from before orders were tracked.
TextColumn get orderId => text().nullable()();
@override
Set<Column> get primaryKey => {id};
}
@@ -135,6 +142,8 @@ class ClosedTabItems extends Table {
DateTimeColumn get removedAt => dateTime().nullable()();
TextColumn get orderId => text().nullable()();
@override
Set<Column> get primaryKey => {id};
}
@@ -268,7 +277,7 @@ class AppDatabase extends _$AppDatabase {
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
@override
int get schemaVersion => 18;
int get schemaVersion => 20;
@override
MigrationStrategy get migration {
@@ -358,7 +367,10 @@ class AppDatabase extends _$AppDatabase {
// Tabs never close (only their items are archived), so the status
// and closed_at columns were never anything but 'open' and null.
if (await hasTableColumn('bar_tabs', 'status')) {
await migrator.alterTable(TableMigration(barTabs));
// `email` only arrives in v20
await migrator.alterTable(
TableMigration(barTabs, newColumns: [barTabs.email]),
);
}
await _backfillPurchaseRows();
await _deleteOrphanedPurchaseRows();
@@ -391,6 +403,25 @@ class AppDatabase extends _$AppDatabase {
}
await migrator.createTable(pendingImageUploads);
}
if (from < 19) {
// `id`: the table exists
if (await hasTableColumn('tab_item_purchases', 'id') &&
!await hasTableColumn('tab_item_purchases', 'order_id')) {
await migrator.addColumn(
tabItemPurchases,
tabItemPurchases.orderId,
);
}
if (await hasTableColumn('closed_tab_items', 'id') &&
!await hasTableColumn('closed_tab_items', 'order_id')) {
await migrator.addColumn(closedTabItems, closedTabItems.orderId);
}
}
if (from < 20 && !await hasTableColumn('bar_tabs', 'email')) {
await migrator.addColumn(barTabs, barTabs.email);
}
},
);
}