Files
kooltab/lib/models/product.dart
T
2026-07-11 17:47:40 +02:00

51 lines
1.2 KiB
Dart

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,
);
}
}