part of '../analytic.dart';

@freezed
class SalesAnalytic with _$SalesAnalytic {
  const factory SalesAnalytic({
    required String organizationId,
    required String outletId,
    required String outletName,
    required DateTime dateFrom,
    required DateTime dateTo,
    required String groupBy,
    required SalesAnalyticSummary summary,
    required List<SalesAnalyticData> data,
  }) = _SalesAnalytic;

  factory SalesAnalytic.empty() => SalesAnalytic(
    organizationId: '',
    outletId: '',
    outletName: '',
    dateFrom: DateTime.fromMillisecondsSinceEpoch(0),
    dateTo: DateTime.fromMillisecondsSinceEpoch(0),
    groupBy: '',
    summary: SalesAnalyticSummary.empty(),
    data: [],
  );
}

@freezed
class SalesAnalyticSummary with _$SalesAnalyticSummary {
  const factory SalesAnalyticSummary({
    required int totalSales,
    required int totalOrders,
    required int totalItems,
    required double averageOrderValue,
    required int totalTax,
    required int totalDiscount,
    required int netSales,
  }) = _SalesAnalyticSummary;

  factory SalesAnalyticSummary.empty() => const SalesAnalyticSummary(
    totalSales: 0,
    totalOrders: 0,
    totalItems: 0,
    averageOrderValue: 0,
    totalTax: 0,
    totalDiscount: 0,
    netSales: 0,
  );
}

@freezed
class SalesAnalyticData with _$SalesAnalyticData {
  const factory SalesAnalyticData({
    required DateTime date,
    required int sales,
    required int orders,
    required int items,
    required int tax,
    required int discount,
    required int netSales,
  }) = _SalesAnalyticData;

  factory SalesAnalyticData.empty() => SalesAnalyticData(
    date: DateTime.fromMillisecondsSinceEpoch(0),
    sales: 0,
    orders: 0,
    items: 0,
    tax: 0,
    discount: 0,
    netSales: 0,
  );
}
