56 lines
1.3 KiB
Dart
56 lines
1.3 KiB
Dart
import 'tab_item_purchase.dart';
|
|
import '../utils/collection_utils.dart';
|
|
|
|
class TabItem {
|
|
final String id;
|
|
final String tabId;
|
|
final String productId;
|
|
final String productName;
|
|
final int quantity;
|
|
final int unitPriceInCents;
|
|
final List<TabItemPurchase> purchases;
|
|
|
|
const TabItem({
|
|
required this.id,
|
|
required this.tabId,
|
|
required this.productId,
|
|
required this.productName,
|
|
required this.quantity,
|
|
required this.unitPriceInCents,
|
|
this.purchases = const [],
|
|
});
|
|
|
|
int get lineTotalInCents => quantity * unitPriceInCents;
|
|
|
|
String get formattedLineTotal {
|
|
return '€${(lineTotalInCents / 100).toStringAsFixed(2)}';
|
|
}
|
|
|
|
String get formattedUnitPrice {
|
|
return '€${(unitPriceInCents / 100).toStringAsFixed(2)}';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is TabItem &&
|
|
id == other.id &&
|
|
tabId == other.tabId &&
|
|
productId == other.productId &&
|
|
productName == other.productName &&
|
|
quantity == other.quantity &&
|
|
unitPriceInCents == other.unitPriceInCents &&
|
|
listEquals(purchases, other.purchases);
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
tabId,
|
|
productId,
|
|
productName,
|
|
quantity,
|
|
unitPriceInCents,
|
|
Object.hashAll(purchases),
|
|
);
|
|
}
|