Files
kooltab/lib/models/closed_tab_item.dart

51 lines
1.2 KiB
Dart

class ClosedTabItem {
final String id;
final String closedTabId;
final String productId;
final String productName;
final int quantity;
final int unitPriceInCents;
final DateTime? purchasedAt;
final DateTime? removedAt;
ClosedTabItem({
required this.id,
required this.closedTabId,
required this.productId,
required this.productName,
required this.quantity,
required this.unitPriceInCents,
this.purchasedAt,
this.removedAt,
});
bool get isRemoved => removedAt != null;
int get lineTotalInCents => isRemoved ? 0 : quantity * unitPriceInCents;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ClosedTabItem &&
id == other.id &&
closedTabId == other.closedTabId &&
productId == other.productId &&
productName == other.productName &&
quantity == other.quantity &&
unitPriceInCents == other.unitPriceInCents &&
purchasedAt == other.purchasedAt &&
removedAt == other.removedAt;
@override
int get hashCode => Object.hash(
id,
closedTabId,
productId,
productName,
quantity,
unitPriceInCents,
purchasedAt,
removedAt,
);
}