part of '../order.dart';

@freezed
class ListOrder with _$ListOrder {
  const factory ListOrder({
    required List<Order> orders,
    required int totalCount,
    required int page,
    required int limit,
    required int totalPages,
  }) = _ListOrder;

  factory ListOrder.empty() =>
      ListOrder(orders: [], totalCount: 0, page: 0, limit: 0, totalPages: 0);
}

@freezed
class Order with _$Order {
  const factory Order({
    required String id,
    required String orderNumber,
    required String outletId,
    required String userId,
    required String tableNumber,
    required String orderType,
    required String status,
    required int subtotal,
    required int taxAmount,
    required int discountAmount,
    required int totalAmount,
    required num totalCost,
    required int remainingAmount,
    required String paymentStatus,
    required int refundAmount,
    required String refundReason,
    required bool isVoid,
    required bool isRefund,
    required String notes,
    required Map<String, dynamic> metadata,
    required DateTime createdAt,
    required DateTime updatedAt,
    required List<OrderItem> orderItems,
    required List<Payment> payments,
    required int totalPaid,
    required int paymentCount,
    required String splitType,
  }) = _Order;

  factory Order.empty() => Order(
    id: '',
    orderNumber: '',
    outletId: '',
    userId: '',
    tableNumber: '',
    orderType: '',
    status: '',
    subtotal: 0,
    taxAmount: 0,
    discountAmount: 0,
    totalAmount: 0,
    totalCost: 0,
    remainingAmount: 0,
    paymentStatus: '',
    refundAmount: 0,
    isVoid: false,
    isRefund: false,
    notes: '',
    metadata: const {},
    createdAt: DateTime(1970),
    updatedAt: DateTime(1970),
    orderItems: const [],
    payments: const [],
    totalPaid: 0,
    paymentCount: 0,
    splitType: '',
    refundReason: '',
  );
}

@freezed
class OrderItem with _$OrderItem {
  const factory OrderItem({
    required String id,
    required String orderId,
    required String productId,
    required String productName,
    required String productVariantId,
    required String productVariantName,
    required int quantity,
    required int unitPrice,
    required int totalPrice,
    required List<dynamic> modifiers,
    required String notes,
    required String status,
    required DateTime createdAt,
    required DateTime updatedAt,
    required String printerType,
    required int paidQuantity,
  }) = _OrderItem;

  factory OrderItem.empty() => OrderItem(
    id: '',
    orderId: '',
    productId: '',
    productName: '',
    productVariantId: '',
    productVariantName: '',
    quantity: 0,
    unitPrice: 0,
    totalPrice: 0,
    modifiers: const [],
    notes: '',
    status: '',
    createdAt: DateTime(1970),
    updatedAt: DateTime(1970),
    printerType: '',
    paidQuantity: 0,
  );
}
