Files
kooltab/lib/models/bar_tab.dart
T
2026-10-08 04:12:36 +02:00

42 lines
986 B
Dart

import 'package:flutter/foundation.dart';
import 'tab_item.dart';
class BarTab {
final String id;
final String customerName;
final DateTime openedAt;
final int version;
final List<TabItem> items;
const BarTab({
required this.id,
required this.customerName,
required this.openedAt,
this.version = 0,
required this.items,
});
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);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BarTab &&
id == other.id &&
customerName == other.customerName &&
openedAt == other.openedAt &&
version == other.version &&
listEquals(items, other.items);
@override
int get hashCode =>
Object.hash(id, customerName, openedAt, version, Object.hashAll(items));
}