/// Order Detail Entity
///
/// Complete order detail information including addresses, items, timeline, etc.
library;

import 'package:equatable/equatable.dart';
import 'package:worker/features/account/domain/entities/address.dart';

/// Order Detail Entity
class OrderDetail extends Equatable {
  const OrderDetail({
    required this.order,
    required this.billingAddress,
    required this.shippingAddress,
    required this.items,
    required this.paymentTerms,
    required this.timeline,
    required this.payments,
    required this.invoices,
  });

  final OrderDetailInfo order;
  final Address billingAddress;
  final Address shippingAddress;
  final List<OrderItemDetail> items;
  final PaymentTermsInfo paymentTerms;
  final List<TimelineItem> timeline;
  final List<PaymentInfo> payments;
  final List<InvoiceInfo> invoices;

  @override
  List<Object?> get props => [
        order,
        billingAddress,
        shippingAddress,
        items,
        paymentTerms,
        timeline,
        payments,
        invoices,
      ];
}

/// Order Detail Info
class OrderDetailInfo extends Equatable {
  const OrderDetailInfo({
    required this.name,
    required this.customer,
    required this.transactionDate,
    required this.deliveryDate,
    required this.status,
    required this.statusColor,
    required this.totalQty,
    required this.total,
    required this.grandTotal,
    required this.totalRemaining,
    required this.description,
    required this.contractRequest,
    required this.ignorePricingRule,
    this.rejectionReason,
    required this.isAllowCancel,
  });

  final String name;
  final String customer;
  final String transactionDate;
  final String deliveryDate;
  final String status;
  final String statusColor;
  final double totalQty;
  final double total;
  final double grandTotal;
  final double totalRemaining;
  final String description;
  final bool contractRequest;
  final bool ignorePricingRule;
  final String? rejectionReason;
  final bool isAllowCancel;

  @override
  List<Object?> get props => [
        name,
        customer,
        transactionDate,
        deliveryDate,
        status,
        statusColor,
        totalQty,
        total,
        grandTotal,
        totalRemaining,
        description,
        contractRequest,
        ignorePricingRule,
        rejectionReason,
        isAllowCancel,
      ];
}

/// Order Item Detail
class OrderItemDetail extends Equatable {
  const OrderItemDetail({
    required this.name,
    required this.itemCode,
    required this.itemName,
    required this.description,
    required this.qtyEntered,
    required this.qtyOfSm,
    required this.qtyOfNos,
    required this.conversionFactor,
    required this.price,
    required this.totalAmount,
    required this.deliveryDate,
    this.thumbnail,
  });

  final String name;
  final String itemCode;
  final String itemName;
  final String description;
  final double qtyEntered;
  final double qtyOfSm;
  final double qtyOfNos;
  final double conversionFactor;
  final double price;
  final double totalAmount;
  final String deliveryDate;
  final String? thumbnail;

  @override
  List<Object?> get props => [
        name,
        itemCode,
        itemName,
        description,
        qtyEntered,
        qtyOfSm,
        qtyOfNos,
        conversionFactor,
        price,
        totalAmount,
        deliveryDate,
        thumbnail,
      ];
}

/// Payment Terms Info
class PaymentTermsInfo extends Equatable {
  const PaymentTermsInfo({
    required this.name,
    required this.description,
  });

  final String name;
  final String description;

  @override
  List<Object?> get props => [name, description];
}

/// Timeline Item
class TimelineItem extends Equatable {
  const TimelineItem({
    required this.label,
    this.value,
    required this.status,
  });

  final String label;
  final String? value;
  final String status; // Success, Warning, Secondary, etc.

  @override
  List<Object?> get props => [label, value, status];
}

/// Payment Info
class PaymentInfo extends Equatable {
  const PaymentInfo({
    required this.name,
    required this.creationDate,
    required this.amount,
  });

  final String name;
  final String creationDate;
  final double amount;

  @override
  List<Object?> get props => [name, creationDate, amount];
}

/// Invoice Info
class InvoiceInfo extends Equatable {
  const InvoiceInfo({
    required this.name,
    required this.postingDate,
    required this.grandTotal,
  });

  final String name;
  final String postingDate;
  final double grandTotal;

  @override
  List<Object?> get props => [name, postingDate, grandTotal];
}
