import 'order_item.dart';
import 'order_status.dart';

/// A customer order placed through the Kell Creations store.
class Order {
  final String id;
  final String customerName;
  final String customerEmail;
  final DateTime orderDate;
  final OrderStatus status;
  final List<OrderItem> items;
  final String shippingAddress;

  const Order({
    required this.id,
    required this.customerName,
    required this.customerEmail,
    required this.orderDate,
    required this.status,
    required this.items,
    required this.shippingAddress,
  });

  /// The total value of the order.
  double get total => items.fold(0, (sum, item) => sum + item.lineTotal);

  /// The number of individual items in the order.
  int get itemCount => items.fold(0, (sum, item) => sum + item.quantity);
}
