/// Événements pour le BLoC des contributions
library contributions_event;

import 'package:equatable/equatable.dart';
import '../data/models/contribution_model.dart';

/// Classe de base pour tous les événements de contributions
abstract class ContributionsEvent extends Equatable {
  const ContributionsEvent();

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

/// Charger la liste des contributions
class LoadContributions extends ContributionsEvent {
  final int page;
  final int size;

  const LoadContributions({
    this.page = 0,
    this.size = 20,
  });

  @override
  List<Object?> get props => [page, size];
}

/// Charger une contribution par ID
class LoadContributionById extends ContributionsEvent {
  final String id;

  const LoadContributionById({required this.id});

  @override
  List<Object?> get props => [id];
}

/// Créer une nouvelle contribution
class CreateContribution extends ContributionsEvent {
  final ContributionModel contribution;

  const CreateContribution({required this.contribution});

  @override
  List<Object?> get props => [contribution];
}

/// Mettre à jour une contribution
class UpdateContribution extends ContributionsEvent {
  final String id;
  final ContributionModel contribution;

  const UpdateContribution({
    required this.id,
    required this.contribution,
  });

  @override
  List<Object?> get props => [id, contribution];
}

/// Supprimer une contribution
class DeleteContribution extends ContributionsEvent {
  final String id;

  const DeleteContribution({required this.id});

  @override
  List<Object?> get props => [id];
}

/// Rechercher des contributions
class SearchContributions extends ContributionsEvent {
  final String? membreId;
  final ContributionStatus? statut;
  final ContributionType? type;
  final int? annee;
  final String? query;
  final int page;
  final int size;

  const SearchContributions({
    this.membreId,
    this.statut,
    this.type,
    this.annee,
    this.query,
    this.page = 0,
    this.size = 20,
  });

  @override
  List<Object?> get props => [membreId, statut, type, annee, query, page, size];
}

/// Charger les contributions d'un membre
class LoadContributionsByMembre extends ContributionsEvent {
  final String membreId;
  final int page;
  final int size;

  const LoadContributionsByMembre({
    required this.membreId,
    this.page = 0,
    this.size = 20,
  });

  @override
  List<Object?> get props => [membreId, page, size];
}

/// Charger les contributions payées
class LoadContributionsPayees extends ContributionsEvent {
  final int page;
  final int size;

  const LoadContributionsPayees({
    this.page = 0,
    this.size = 20,
  });

  @override
  List<Object?> get props => [page, size];
}

/// Charger les contributions non payées
class LoadContributionsNonPayees extends ContributionsEvent {
  final int page;
  final int size;

  const LoadContributionsNonPayees({
    this.page = 0,
    this.size = 20,
  });

  @override
  List<Object?> get props => [page, size];
}

/// Charger les contributions en retard
class LoadContributionsEnRetard extends ContributionsEvent {
  final int page;
  final int size;

  const LoadContributionsEnRetard({
    this.page = 0,
    this.size = 20,
  });

  @override
  List<Object?> get props => [page, size];
}

/// Enregistrer un paiement
class RecordPayment extends ContributionsEvent {
  final String contributionId;
  final double montant;
  final PaymentMethod methodePaiement;
  final String? numeroPaiement;
  final String? referencePaiement;
  final DateTime datePaiement;
  final String? notes;
  final String? reference;

  const RecordPayment({
    required this.contributionId,
    required this.montant,
    required this.methodePaiement,
    this.numeroPaiement,
    this.referencePaiement,
    required this.datePaiement,
    this.notes,
    this.reference,
  });

  @override
  List<Object?> get props => [
        contributionId,
        montant,
        methodePaiement,
        numeroPaiement,
        referencePaiement,
        datePaiement,
        notes,
        reference,
      ];
}

/// Charger les statistiques des contributions
class LoadContributionsStats extends ContributionsEvent {
  final int? annee;

  const LoadContributionsStats({this.annee});

  @override
  List<Object?> get props => [annee];
}

/// Générer les contributions annuelles
class GenerateAnnualContributions extends ContributionsEvent {
  final int annee;
  final double montant;
  final DateTime dateEcheance;

  const GenerateAnnualContributions({
    required this.annee,
    required this.montant,
    required this.dateEcheance,
  });

  @override
  List<Object?> get props => [annee, montant, dateEcheance];
}

/// Envoyer un rappel de paiement
class SendPaymentReminder extends ContributionsEvent {
  final String contributionId;

  const SendPaymentReminder({required this.contributionId});

  @override
  List<Object?> get props => [contributionId];
}

