34 lines
715 B
Dart
34 lines
715 B
Dart
import 'tab_item.dart';
|
|
|
|
class BarTab {
|
|
final String id;
|
|
final String customerName;
|
|
final String status;
|
|
final DateTime openedAt;
|
|
final DateTime? closedAt;
|
|
final List<TabItem> items;
|
|
|
|
const BarTab({
|
|
required this.id,
|
|
required this.customerName,
|
|
required this.status,
|
|
required this.openedAt,
|
|
required this.items,
|
|
this.closedAt,
|
|
});
|
|
|
|
int get totalInCents {
|
|
return items.fold<int>(0, (total, item) => total + item.lineTotalInCents);
|
|
}
|
|
|
|
int get itemCount {
|
|
return items.fold<int>(0, (total, item) => total + item.quantity);
|
|
}
|
|
|
|
String get formattedTotal {
|
|
return '€${(totalInCents / 100).toStringAsFixed(2)}';
|
|
}
|
|
|
|
bool get isOpen => status == 'open';
|
|
}
|