feat: alphabet list, change Layout etc

This commit is contained in:
2026-10-11 20:37:59 +02:00
parent 489896305d
commit 072f560989
31 changed files with 1847 additions and 832 deletions
+15 -1
View File
@@ -2,7 +2,7 @@ import 'package:drift/native.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:kooltap/database/app_database.dart';
/// The parts of the v12 schema that the v13 migration touches.
/// The parts of the v12 schema that the v13 and v14 migrations touch.
const _v12Schema = [
'CREATE TABLE bar_tabs (id TEXT NOT NULL, customer_name TEXT NOT NULL, '
"status TEXT NOT NULL DEFAULT 'open', opened_at INTEGER NOT NULL, "
@@ -15,6 +15,13 @@ const _v12Schema = [
'CREATE TABLE tab_item_purchases (id TEXT NOT NULL, '
'tab_item_id TEXT NOT NULL, purchased_at INTEGER NOT NULL, '
'removed_at INTEGER NULL, PRIMARY KEY (id))',
'CREATE TABLE products (id TEXT NOT NULL, name TEXT NOT NULL, '
'category TEXT NOT NULL, stock_quantity INTEGER NOT NULL, '
'low_stock_threshold INTEGER NOT NULL, price_in_cents INTEGER NOT NULL, '
'image_path TEXT NULL, active INTEGER NOT NULL DEFAULT 1, '
'PRIMARY KEY (id))',
"INSERT INTO products VALUES ('prod-1', 'Beer', 'Drinks', 20, 5, 400, "
'NULL, 1)',
"INSERT INTO bar_tabs VALUES ('tab-1', 'Alice', 'open', 1700000000, NULL, 4)",
"INSERT INTO tab_items VALUES ('item-1', 'tab-1', 'prod-1', 'Beer', 3, 400, "
'1700000100)',
@@ -68,6 +75,13 @@ void main() {
expect(purchases.where((row) => row.removedAt != null), hasLength(1));
});
test('gives existing products a counted stock', () async {
final product = await database.select(database.products).getSingle();
expect(product.infiniteStock, false);
expect(product.stockQuantity, 20);
});
test('deletes purchases whose item no longer exists', () async {
final orphan = await (database.select(
database.tabItemPurchases,