part of '../order.dart';

@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 int totalCost,
    required int remainingAmount,
    required String paymentStatus,
    required int refundAmount,
    required bool isVoid,
    required bool isRefund,
    required String notes,
    required Map<String, dynamic> metadata,
    required String createdAt,
    required String updatedAt,
    required List<OrderItem> orderItems,
    required List<OrderPayment> 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: {},
    createdAt: '',
    updatedAt: '',
    orderItems: [],
    payments: [],
    totalPaid: 0,
    paymentCount: 0,
    splitType: '',
  );
}

@freezed
class OrderItem with _$OrderItem {
  const factory OrderItem({
    required String id,
    required String orderId,
    required String productId,
    required String productName,
    required int quantity,
    required int price,
    required int subtotal,
    required int discountAmount,
    required int total,
    required int cost,
    required Map<String, dynamic> metadata,
    required String createdAt,
    required String updatedAt,
  }) = _OrderItem;

  factory OrderItem.empty() => OrderItem(
    id: '',
    orderId: '',
    productId: '',
    productName: '',
    quantity: 0,
    price: 0,
    subtotal: 0,
    discountAmount: 0,
    total: 0,
    cost: 0,
    metadata: {},
    createdAt: '',
    updatedAt: '',
  );
}

@freezed
class OrderPayment with _$OrderPayment {
  const factory OrderPayment({
    required String id,
    required String orderId,
    required String paymentMethodId,
    required String paymentMethodName,
    required String paymentMethodType,
    required int amount,
    required String status,
    required int splitNumber,
    required int splitTotal,
    required String splitType,
    required String splitDescription,
    required int refundAmount,
    required Map<String, dynamic> metadata,
    required String createdAt,
    required String updatedAt,
    required List<PaymentOrderItem> paymentOrderItems,
  }) = _OrderPayment;

  factory OrderPayment.empty() => OrderPayment(
    id: '',
    orderId: '',
    paymentMethodId: '',
    paymentMethodName: '',
    paymentMethodType: '',
    amount: 0,
    status: '',
    splitNumber: 0,
    splitTotal: 0,
    splitType: '',
    splitDescription: '',
    refundAmount: 0,
    metadata: {},
    createdAt: '',
    updatedAt: '',
    paymentOrderItems: [],
  );
}

@freezed
class PaymentOrderItem with _$PaymentOrderItem {
  const factory PaymentOrderItem({
    required String id,
    required String orderPaymentId,
    required String orderItemId,
    required int amount,
    required int refundAmount,
    required String createdAt,
    required String updatedAt,
  }) = _PaymentOrderItem;

  factory PaymentOrderItem.empty() => PaymentOrderItem(
    id: '',
    orderPaymentId: '',
    orderItemId: '',
    amount: 0,
    refundAmount: 0,
    createdAt: '',
    updatedAt: '',
  );
}
