part of '../analytic.dart';

@freezed
class PaymentMethodAnalytic with _$PaymentMethodAnalytic {
  const factory PaymentMethodAnalytic({
    required String organizationId,
    required String outletId,
    required DateTime dateFrom,
    required DateTime dateTo,
    required String groupBy,
    required PaymentMethodAnalyticSummary summary,
    required List<PaymentMethodAnalyticItem> data,
  }) = _PaymentMethodAnalytic;

  factory PaymentMethodAnalytic.empty() => PaymentMethodAnalytic(
    organizationId: '',
    outletId: '',
    dateFrom: DateTime.now(),
    dateTo: DateTime.now(),
    groupBy: '',
    summary: PaymentMethodAnalyticSummary.empty(),
    data: const [],
  );
}

@freezed
class PaymentMethodAnalyticItem with _$PaymentMethodAnalyticItem {
  const factory PaymentMethodAnalyticItem({
    required String paymentMethodId,
    required String paymentMethodName,
    required String paymentMethodType,
    required int totalAmount,
    required int orderCount,
    required int paymentCount,
    required num percentage,
  }) = _PaymentMethodAnalyticItem;

  factory PaymentMethodAnalyticItem.empty() => const PaymentMethodAnalyticItem(
    paymentMethodId: '',
    paymentMethodName: '',
    paymentMethodType: '',
    totalAmount: 0,
    orderCount: 0,
    paymentCount: 0,
    percentage: 0,
  );
}

@freezed
class PaymentMethodAnalyticSummary with _$PaymentMethodAnalyticSummary {
  const factory PaymentMethodAnalyticSummary({
    required int totalAmount,
    required int totalOrders,
    required int totalPayments,
    required double averageOrderValue,
  }) = _PaymentMethodAnalyticSummary;

  factory PaymentMethodAnalyticSummary.empty() =>
      const PaymentMethodAnalyticSummary(
        totalAmount: 0,
        totalOrders: 0,
        totalPayments: 0,
        averageOrderValue: 0.0,
      );
}
