This commit is contained in:
2026-07-11 17:47:40 +02:00
commit 6587779a58
66 changed files with 7325 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
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';
}
+51
View File
@@ -0,0 +1,51 @@
class Product {
final String id;
final String name;
final String category;
final int stockQuantity;
final int lowStockThreshold;
final int priceInCents;
final String? imagePath;
final bool active;
const Product({
required this.id,
required this.name,
required this.category,
required this.stockQuantity,
required this.lowStockThreshold,
required this.priceInCents,
this.imagePath,
this.active = true,
});
bool get isLowStock => stockQuantity <= lowStockThreshold;
String get formattedPrice {
final euros = priceInCents / 100;
return '${euros.toStringAsFixed(2)}';
}
Product copyWith({
String? id,
String? name,
String? category,
int? stockQuantity,
int? lowStockThreshold,
int? priceInCents,
String? imagePath,
bool? active,
}) {
return Product(
id: id ?? this.id,
name: name ?? this.name,
category: category ?? this.category,
stockQuantity: stockQuantity ?? this.stockQuantity,
lowStockThreshold: lowStockThreshold ?? this.lowStockThreshold,
priceInCents: priceInCents ?? this.priceInCents,
imagePath: imagePath ?? this.imagePath,
active: active ?? this.active,
);
}
}
+27
View File
@@ -0,0 +1,27 @@
class TabItem {
final String id;
final String tabId;
final String productId;
final String productName;
final int quantity;
final int unitPriceInCents;
const TabItem({
required this.id,
required this.tabId,
required this.productId,
required this.productName,
required this.quantity,
required this.unitPriceInCents,
});
int get lineTotalInCents => quantity * unitPriceInCents;
String get formattedLineTotal {
return '${(lineTotalInCents / 100).toStringAsFixed(2)}';
}
String get formattedUnitPrice {
return '${(unitPriceInCents / 100).toStringAsFixed(2)}';
}
}