feat: add more detailed history and group per day

This commit is contained in:
2026-08-07 05:07:41 +02:00
parent 1dd7e69aa8
commit 799c1c4045
23 changed files with 2506 additions and 346 deletions
+12 -11
View File
@@ -9,7 +9,7 @@ class ClosedTab {
final String originalTabId;
final String customerName;
final DateTime closedAt;
final PaymentMethod paymentMethod;
final PaymentMethod paymentMethod;
final List<ClosedTabItem> items;
const ClosedTab({
@@ -21,10 +21,11 @@ final PaymentMethod paymentMethod;
required this.items,
});
int get itemCount => items.fold(0, (sum, item) => sum + item.quantity);
int get itemCount =>
items.fold(0, (sum, item) => sum + (item.isRemoved ? 0 : item.quantity));
int get totalInCents =>
items.fold(0, (sum, item) => sum + item.quantity * item.unitPriceInCents);
items.fold(0, (sum, item) => sum + item.lineTotalInCents);
String get formattedTotal =>
NumberFormat.simpleCurrency().format(totalInCents / 100);
@@ -44,13 +45,13 @@ final PaymentMethod paymentMethod;
@override
int get hashCode => Object.hash(
id,
originalTabId,
customerName,
closedAt,
paymentMethod,
Object.hashAll(items),
);
id,
originalTabId,
customerName,
closedAt,
paymentMethod,
Object.hashAll(items),
);
}
// _listEquals moved to utils/collection_utils.dart
// _listEquals moved to utils/collection_utils.dart
+19 -9
View File
@@ -5,6 +5,8 @@ class ClosedTabItem {
final String productName;
final int quantity;
final int unitPriceInCents;
final DateTime? purchasedAt;
final DateTime? removedAt;
ClosedTabItem({
required this.id,
@@ -13,9 +15,13 @@ class ClosedTabItem {
required this.productName,
required this.quantity,
required this.unitPriceInCents,
this.purchasedAt,
this.removedAt,
});
int get lineTotalInCents => quantity * unitPriceInCents;
bool get isRemoved => removedAt != null;
int get lineTotalInCents => isRemoved ? 0 : quantity * unitPriceInCents;
@override
bool operator ==(Object other) =>
@@ -26,15 +32,19 @@ class ClosedTabItem {
productId == other.productId &&
productName == other.productName &&
quantity == other.quantity &&
unitPriceInCents == other.unitPriceInCents;
unitPriceInCents == other.unitPriceInCents &&
purchasedAt == other.purchasedAt &&
removedAt == other.removedAt;
@override
int get hashCode => Object.hash(
id,
closedTabId,
productId,
productName,
quantity,
unitPriceInCents,
);
id,
closedTabId,
productId,
productName,
quantity,
unitPriceInCents,
purchasedAt,
removedAt,
);
}
+15 -8
View File
@@ -1,3 +1,6 @@
import 'tab_item_purchase.dart';
import '../utils/collection_utils.dart';
class TabItem {
final String id;
final String tabId;
@@ -5,6 +8,7 @@ class TabItem {
final String productName;
final int quantity;
final int unitPriceInCents;
final List<TabItemPurchase> purchases;
const TabItem({
required this.id,
@@ -13,6 +17,7 @@ class TabItem {
required this.productName,
required this.quantity,
required this.unitPriceInCents,
this.purchases = const [],
});
int get lineTotalInCents => quantity * unitPriceInCents;
@@ -34,15 +39,17 @@ class TabItem {
productId == other.productId &&
productName == other.productName &&
quantity == other.quantity &&
unitPriceInCents == other.unitPriceInCents;
unitPriceInCents == other.unitPriceInCents &&
listEquals(purchases, other.purchases);
@override
int get hashCode => Object.hash(
id,
tabId,
productId,
productName,
quantity,
unitPriceInCents,
);
id,
tabId,
productId,
productName,
quantity,
unitPriceInCents,
Object.hashAll(purchases),
);
}
+27
View File
@@ -0,0 +1,27 @@
class TabItemPurchase {
final String id;
final String tabItemId;
final DateTime purchasedAt;
final DateTime? removedAt;
const TabItemPurchase({
required this.id,
required this.tabItemId,
required this.purchasedAt,
this.removedAt,
});
bool get isRemoved => removedAt != null;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TabItemPurchase &&
id == other.id &&
tabItemId == other.tabItemId &&
purchasedAt == other.purchasedAt &&
removedAt == other.removedAt;
@override
int get hashCode => Object.hash(id, tabItemId, purchasedAt, removedAt);
}