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