part of '../analytic.dart';

@freezed
class ExclusiveSummary with _$ExclusiveSummary {
  const factory ExclusiveSummary({
    required String organizationId,
    required String outletId,
    required String outletName,
    required ExclusiveSummaryPeriod period,
    required ExclusiveSummarySummary summary,
    required ExclusiveSummaryReimburse reimburse,
    required List<ExclusiveSummaryBreakdown> hppBreakdown,
    required List<ExclusiveSummaryBreakdown> operationalExpenseBreakdown,
    required List<ExclusiveSummaryDaily> dailySummary,
    required List<ExclusiveSummaryTransaction> dailyTransactions,
  }) = _ExclusiveSummary;

  factory ExclusiveSummary.empty() => ExclusiveSummary(
    organizationId: '',
    outletId: '',
    outletName: '',
    period: ExclusiveSummaryPeriod.empty(),
    summary: ExclusiveSummarySummary.empty(),
    reimburse: ExclusiveSummaryReimburse.empty(),
    hppBreakdown: [],
    operationalExpenseBreakdown: [],
    dailySummary: [],
    dailyTransactions: [],
  );
}

@freezed
class ExclusiveSummaryPeriod with _$ExclusiveSummaryPeriod {
  const factory ExclusiveSummaryPeriod({
    required DateTime dateFrom,
    required DateTime dateTo,
  }) = _ExclusiveSummaryPeriod;

  factory ExclusiveSummaryPeriod.empty() => ExclusiveSummaryPeriod(
    dateFrom: DateTime.fromMillisecondsSinceEpoch(0),
    dateTo: DateTime.fromMillisecondsSinceEpoch(0),
  );
}

@freezed
class ExclusiveSummarySummary with _$ExclusiveSummarySummary {
  const factory ExclusiveSummarySummary({
    required int sales,
    required int hpp,
    required int grossProfit,
    required int salaryTotal,
    required int salaryDw,
    required int salaryStaff,
    required int salaryOther,
    required int otherOperationalExpenses,
    required int operationalExpensesTotal,
    required int totalCost,
    required int netProfit,
  }) = _ExclusiveSummarySummary;

  factory ExclusiveSummarySummary.empty() => const ExclusiveSummarySummary(
    sales: 0,
    hpp: 0,
    grossProfit: 0,
    salaryTotal: 0,
    salaryDw: 0,
    salaryStaff: 0,
    salaryOther: 0,
    otherOperationalExpenses: 0,
    operationalExpensesTotal: 0,
    totalCost: 0,
    netProfit: 0,
  );
}

@freezed
class ExclusiveSummaryReimburse with _$ExclusiveSummaryReimburse {
  const factory ExclusiveSummaryReimburse({
    required int totalCost,
    required int excludedSalaryStaff,
    required int totalReimburse,
  }) = _ExclusiveSummaryReimburse;

  factory ExclusiveSummaryReimburse.empty() => const ExclusiveSummaryReimburse(
    totalCost: 0,
    excludedSalaryStaff: 0,
    totalReimburse: 0,
  );
}

@freezed
class ExclusiveSummaryBreakdown with _$ExclusiveSummaryBreakdown {
  const factory ExclusiveSummaryBreakdown({
    required String categoryCode,
    required String categoryName,
    required int amount,
    required double percentage,
  }) = _ExclusiveSummaryBreakdown;
}

@freezed
class ExclusiveSummaryDaily with _$ExclusiveSummaryDaily {
  const factory ExclusiveSummaryDaily({
    required DateTime date,
    required int transactionCount,
    required int totalCost,
  }) = _ExclusiveSummaryDaily;
}

@freezed
class ExclusiveSummaryTransaction with _$ExclusiveSummaryTransaction {
  const factory ExclusiveSummaryTransaction({
    required DateTime date,
    required String categoryCode,
    required String categoryName,
    required String description,
    required int amount,
    required String source,
  }) = _ExclusiveSummaryTransaction;
}
