/// Modèle pour la réponse GET /api/dashboard/membre/me (backend MembreDashboardSyntheseResponse). /// Utilisé quand l'utilisateur est un membre sans organisationId (dashboard personnel). class MembreDashboardSyntheseModel { final String prenom; final String nom; final String? dateInscription; // ISO date string final double mesCotisationsPaiement; /// Total des cotisations payées sur l'année (pour dashboard). final double totalCotisationsPayeesAnnee; /// Total des cotisations payées tout temps (pour carte « Contribution Totale »). final double totalCotisationsPayeesToutTemps; /// Nombre de cotisations payées (pour carte « Cotisations »). final int nombreCotisationsPayees; /// Nombre total de cotisations (toutes années, tous statuts). final int nombreCotisationsTotal; final String statutCotisations; final int? tauxCotisationsPerso; final double monSoldeEpargne; final double evolutionEpargneNombre; final String evolutionEpargne; final int objectifEpargne; final int mesEvenementsInscrits; final int evenementsAVenir; final int? tauxParticipationPerso; final int mesDemandesAide; final int aidesEnCours; final int? tauxAidesApprouvees; const MembreDashboardSyntheseModel({ required this.prenom, required this.nom, this.dateInscription, this.mesCotisationsPaiement = 0, this.totalCotisationsPayeesAnnee = 0, this.totalCotisationsPayeesToutTemps = 0, this.nombreCotisationsPayees = 0, this.nombreCotisationsTotal = 0, this.statutCotisations = 'À jour', this.tauxCotisationsPerso, this.monSoldeEpargne = 0, this.evolutionEpargneNombre = 0, this.evolutionEpargne = '+0%', this.objectifEpargne = 0, this.mesEvenementsInscrits = 0, this.evenementsAVenir = 0, this.tauxParticipationPerso, this.mesDemandesAide = 0, this.aidesEnCours = 0, this.tauxAidesApprouvees, }); factory MembreDashboardSyntheseModel.fromJson(Map json) { return MembreDashboardSyntheseModel( prenom: json['prenom'] as String? ?? '', nom: json['nom'] as String? ?? '', dateInscription: json['dateInscription'] as String?, mesCotisationsPaiement: _toDouble(json['mesCotisationsPaiement']), totalCotisationsPayeesAnnee: _toDouble(json['totalCotisationsPayeesAnnee']), totalCotisationsPayeesToutTemps: _toDouble(json['totalCotisationsPayeesToutTemps']), nombreCotisationsPayees: (json['nombreCotisationsPayees'] as num?)?.toInt() ?? 0, nombreCotisationsTotal: (json['nombreCotisationsTotal'] as num?)?.toInt() ?? (json['nombreCotisationsPayees'] as num?)?.toInt() ?? 0, statutCotisations: json['statutCotisations'] as String? ?? 'À jour', tauxCotisationsPerso: (json['tauxCotisationsPerso'] as num?)?.toInt(), monSoldeEpargne: _toDouble(json['monSoldeEpargne']), evolutionEpargneNombre: _toDouble(json['evolutionEpargneNombre']), evolutionEpargne: json['evolutionEpargne'] as String? ?? '+0%', objectifEpargne: (json['objectifEpargne'] as num?)?.toInt() ?? 0, mesEvenementsInscrits: (json['mesEvenementsInscrits'] as num?)?.toInt() ?? 0, evenementsAVenir: (json['evenementsAVenir'] as num?)?.toInt() ?? 0, tauxParticipationPerso: (json['tauxParticipationPerso'] as num?)?.toInt(), mesDemandesAide: (json['mesDemandesAide'] as num?)?.toInt() ?? 0, aidesEnCours: (json['aidesEnCours'] as num?)?.toInt() ?? 0, tauxAidesApprouvees: (json['tauxAidesApprouvees'] as num?)?.toInt(), ); } static double _toDouble(dynamic v) { if (v == null) return 0; if (v is num) return v.toDouble(); if (v is String) return double.tryParse(v) ?? 0; return 0; } }