Authentification stable - WIP
This commit is contained in:
@@ -1,326 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'cotisation_filter_model.g.dart';
|
||||
|
||||
/// Modèle pour les filtres de recherche des cotisations
|
||||
/// Permet de filtrer les cotisations selon différents critères
|
||||
@JsonSerializable()
|
||||
class CotisationFilterModel {
|
||||
final String? membreId;
|
||||
final String? nomMembre;
|
||||
final String? numeroMembre;
|
||||
final List<String>? statuts;
|
||||
final List<String>? typesCotisation;
|
||||
final DateTime? dateEcheanceMin;
|
||||
final DateTime? dateEcheanceMax;
|
||||
final DateTime? datePaiementMin;
|
||||
final DateTime? datePaiementMax;
|
||||
final double? montantMin;
|
||||
final double? montantMax;
|
||||
final int? annee;
|
||||
final int? mois;
|
||||
final String? periode;
|
||||
final bool? recurrente;
|
||||
final bool? enRetard;
|
||||
final bool? echeanceProche;
|
||||
final String? methodePaiement;
|
||||
final String? recherche;
|
||||
final String? triPar;
|
||||
final String? ordretri;
|
||||
final int page;
|
||||
final int size;
|
||||
|
||||
const CotisationFilterModel({
|
||||
this.membreId,
|
||||
this.nomMembre,
|
||||
this.numeroMembre,
|
||||
this.statuts,
|
||||
this.typesCotisation,
|
||||
this.dateEcheanceMin,
|
||||
this.dateEcheanceMax,
|
||||
this.datePaiementMin,
|
||||
this.datePaiementMax,
|
||||
this.montantMin,
|
||||
this.montantMax,
|
||||
this.annee,
|
||||
this.mois,
|
||||
this.periode,
|
||||
this.recurrente,
|
||||
this.enRetard,
|
||||
this.echeanceProche,
|
||||
this.methodePaiement,
|
||||
this.recherche,
|
||||
this.triPar,
|
||||
this.ordreTriPar,
|
||||
this.page = 0,
|
||||
this.size = 20,
|
||||
});
|
||||
|
||||
/// Factory pour créer depuis JSON
|
||||
factory CotisationFilterModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$CotisationFilterModelFromJson(json);
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() => _$CotisationFilterModelToJson(this);
|
||||
|
||||
/// Crée un filtre vide
|
||||
factory CotisationFilterModel.empty() {
|
||||
return const CotisationFilterModel();
|
||||
}
|
||||
|
||||
/// Crée un filtre pour les cotisations en retard
|
||||
factory CotisationFilterModel.enRetard() {
|
||||
return const CotisationFilterModel(
|
||||
enRetard: true,
|
||||
triPar: 'dateEcheance',
|
||||
ordreTriPar: 'ASC',
|
||||
);
|
||||
}
|
||||
|
||||
/// Crée un filtre pour les cotisations avec échéance proche
|
||||
factory CotisationFilterModel.echeanceProche() {
|
||||
return const CotisationFilterModel(
|
||||
echeanceProche: true,
|
||||
triPar: 'dateEcheance',
|
||||
ordreTriPar: 'ASC',
|
||||
);
|
||||
}
|
||||
|
||||
/// Crée un filtre pour un membre spécifique
|
||||
factory CotisationFilterModel.parMembre(String membreId) {
|
||||
return CotisationFilterModel(
|
||||
membreId: membreId,
|
||||
triPar: 'dateEcheance',
|
||||
ordreTriPar: 'DESC',
|
||||
);
|
||||
}
|
||||
|
||||
/// Crée un filtre pour un statut spécifique
|
||||
factory CotisationFilterModel.parStatut(String statut) {
|
||||
return CotisationFilterModel(
|
||||
statuts: [statut],
|
||||
triPar: 'dateEcheance',
|
||||
ordreTriPar: 'DESC',
|
||||
);
|
||||
}
|
||||
|
||||
/// Crée un filtre pour une période spécifique
|
||||
factory CotisationFilterModel.parPeriode(int annee, [int? mois]) {
|
||||
return CotisationFilterModel(
|
||||
annee: annee,
|
||||
mois: mois,
|
||||
triPar: 'dateEcheance',
|
||||
ordreTriPar: 'DESC',
|
||||
);
|
||||
}
|
||||
|
||||
/// Crée un filtre pour une recherche textuelle
|
||||
factory CotisationFilterModel.recherche(String terme) {
|
||||
return CotisationFilterModel(
|
||||
recherche: terme,
|
||||
triPar: 'dateCreation',
|
||||
ordreTriPar: 'DESC',
|
||||
);
|
||||
}
|
||||
|
||||
/// Vérifie si le filtre est vide
|
||||
bool get isEmpty {
|
||||
return membreId == null &&
|
||||
nomMembre == null &&
|
||||
numeroMembre == null &&
|
||||
(statuts == null || statuts!.isEmpty) &&
|
||||
(typesCotisation == null || typesCotisation!.isEmpty) &&
|
||||
dateEcheanceMin == null &&
|
||||
dateEcheanceMax == null &&
|
||||
datePaiementMin == null &&
|
||||
datePaiementMax == null &&
|
||||
montantMin == null &&
|
||||
montantMax == null &&
|
||||
annee == null &&
|
||||
mois == null &&
|
||||
periode == null &&
|
||||
recurrente == null &&
|
||||
enRetard == null &&
|
||||
echeanceProche == null &&
|
||||
methodePaiement == null &&
|
||||
(recherche == null || recherche!.isEmpty);
|
||||
}
|
||||
|
||||
/// Vérifie si le filtre a des critères actifs
|
||||
bool get hasActiveFilters => !isEmpty;
|
||||
|
||||
/// Compte le nombre de filtres actifs
|
||||
int get nombreFiltresActifs {
|
||||
int count = 0;
|
||||
if (membreId != null) count++;
|
||||
if (nomMembre != null) count++;
|
||||
if (numeroMembre != null) count++;
|
||||
if (statuts != null && statuts!.isNotEmpty) count++;
|
||||
if (typesCotisation != null && typesCotisation!.isNotEmpty) count++;
|
||||
if (dateEcheanceMin != null || dateEcheanceMax != null) count++;
|
||||
if (datePaiementMin != null || datePaiementMax != null) count++;
|
||||
if (montantMin != null || montantMax != null) count++;
|
||||
if (annee != null) count++;
|
||||
if (mois != null) count++;
|
||||
if (periode != null) count++;
|
||||
if (recurrente != null) count++;
|
||||
if (enRetard == true) count++;
|
||||
if (echeanceProche == true) count++;
|
||||
if (methodePaiement != null) count++;
|
||||
if (recherche != null && recherche!.isNotEmpty) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
/// Retourne une description textuelle des filtres actifs
|
||||
String get descriptionFiltres {
|
||||
List<String> descriptions = [];
|
||||
|
||||
if (statuts != null && statuts!.isNotEmpty) {
|
||||
descriptions.add('Statut: ${statuts!.join(', ')}');
|
||||
}
|
||||
|
||||
if (typesCotisation != null && typesCotisation!.isNotEmpty) {
|
||||
descriptions.add('Type: ${typesCotisation!.join(', ')}');
|
||||
}
|
||||
|
||||
if (annee != null) {
|
||||
String periodeDesc = 'Année: $annee';
|
||||
if (mois != null) {
|
||||
periodeDesc += ', Mois: $mois';
|
||||
}
|
||||
descriptions.add(periodeDesc);
|
||||
}
|
||||
|
||||
if (enRetard == true) {
|
||||
descriptions.add('En retard');
|
||||
}
|
||||
|
||||
if (echeanceProche == true) {
|
||||
descriptions.add('Échéance proche');
|
||||
}
|
||||
|
||||
if (montantMin != null || montantMax != null) {
|
||||
String montantDesc = 'Montant: ';
|
||||
if (montantMin != null && montantMax != null) {
|
||||
montantDesc += '${montantMin!.toStringAsFixed(0)} - ${montantMax!.toStringAsFixed(0)} XOF';
|
||||
} else if (montantMin != null) {
|
||||
montantDesc += '≥ ${montantMin!.toStringAsFixed(0)} XOF';
|
||||
} else {
|
||||
montantDesc += '≤ ${montantMax!.toStringAsFixed(0)} XOF';
|
||||
}
|
||||
descriptions.add(montantDesc);
|
||||
}
|
||||
|
||||
if (recherche != null && recherche!.isNotEmpty) {
|
||||
descriptions.add('Recherche: "$recherche"');
|
||||
}
|
||||
|
||||
return descriptions.join(' • ');
|
||||
}
|
||||
|
||||
/// Convertit vers Map pour les paramètres de requête
|
||||
Map<String, dynamic> toQueryParameters() {
|
||||
Map<String, dynamic> params = {};
|
||||
|
||||
if (membreId != null) params['membreId'] = membreId;
|
||||
if (statuts != null && statuts!.isNotEmpty) {
|
||||
params['statut'] = statuts!.length == 1 ? statuts!.first : statuts!.join(',');
|
||||
}
|
||||
if (typesCotisation != null && typesCotisation!.isNotEmpty) {
|
||||
params['typeCotisation'] = typesCotisation!.length == 1 ? typesCotisation!.first : typesCotisation!.join(',');
|
||||
}
|
||||
if (annee != null) params['annee'] = annee.toString();
|
||||
if (mois != null) params['mois'] = mois.toString();
|
||||
if (periode != null) params['periode'] = periode;
|
||||
if (recurrente != null) params['recurrente'] = recurrente.toString();
|
||||
if (enRetard == true) params['enRetard'] = 'true';
|
||||
if (echeanceProche == true) params['echeanceProche'] = 'true';
|
||||
if (methodePaiement != null) params['methodePaiement'] = methodePaiement;
|
||||
if (recherche != null && recherche!.isNotEmpty) params['q'] = recherche;
|
||||
if (triPar != null) params['sortBy'] = triPar;
|
||||
if (ordreTriPar != null) params['sortOrder'] = ordreTriPar;
|
||||
|
||||
params['page'] = page.toString();
|
||||
params['size'] = size.toString();
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
/// Copie avec modifications
|
||||
CotisationFilterModel copyWith({
|
||||
String? membreId,
|
||||
String? nomMembre,
|
||||
String? numeroMembre,
|
||||
List<String>? statuts,
|
||||
List<String>? typesCotisation,
|
||||
DateTime? dateEcheanceMin,
|
||||
DateTime? dateEcheanceMax,
|
||||
DateTime? datePaiementMin,
|
||||
DateTime? datePaiementMax,
|
||||
double? montantMin,
|
||||
double? montantMax,
|
||||
int? annee,
|
||||
int? mois,
|
||||
String? periode,
|
||||
bool? recurrente,
|
||||
bool? enRetard,
|
||||
bool? echeanceProche,
|
||||
String? methodePaiement,
|
||||
String? recherche,
|
||||
String? triPar,
|
||||
String? ordreTriPar,
|
||||
int? page,
|
||||
int? size,
|
||||
}) {
|
||||
return CotisationFilterModel(
|
||||
membreId: membreId ?? this.membreId,
|
||||
nomMembre: nomMembre ?? this.nomMembre,
|
||||
numeroMembre: numeroMembre ?? this.numeroMembre,
|
||||
statuts: statuts ?? this.statuts,
|
||||
typesCotisation: typesCotisation ?? this.typesCotisation,
|
||||
dateEcheanceMin: dateEcheanceMin ?? this.dateEcheanceMin,
|
||||
dateEcheanceMax: dateEcheanceMax ?? this.dateEcheanceMax,
|
||||
datePaiementMin: datePaiementMin ?? this.datePaiementMin,
|
||||
datePaiementMax: datePaiementMax ?? this.datePaiementMax,
|
||||
montantMin: montantMin ?? this.montantMin,
|
||||
montantMax: montantMax ?? this.montantMax,
|
||||
annee: annee ?? this.annee,
|
||||
mois: mois ?? this.mois,
|
||||
periode: periode ?? this.periode,
|
||||
recurrente: recurrente ?? this.recurrente,
|
||||
enRetard: enRetard ?? this.enRetard,
|
||||
echeanceProche: echeanceProche ?? this.echeanceProche,
|
||||
methodePaiement: methodePaiement ?? this.methodePaiement,
|
||||
recherche: recherche ?? this.recherche,
|
||||
triPar: triPar ?? this.triPar,
|
||||
ordreTriPar: ordreTriPar ?? this.ordreTriPar,
|
||||
page: page ?? this.page,
|
||||
size: size ?? this.size,
|
||||
);
|
||||
}
|
||||
|
||||
/// Réinitialise tous les filtres
|
||||
CotisationFilterModel clear() {
|
||||
return const CotisationFilterModel();
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is CotisationFilterModel &&
|
||||
other.membreId == membreId &&
|
||||
other.statuts == statuts &&
|
||||
other.typesCotisation == typesCotisation &&
|
||||
other.annee == annee &&
|
||||
other.mois == mois &&
|
||||
other.recherche == recherche;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(membreId, statuts, typesCotisation, annee, mois, recherche);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CotisationFilterModel(filtres actifs: $nombreFiltresActifs)';
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'cotisation_filter_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CotisationFilterModel _$CotisationFilterModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
CotisationFilterModel(
|
||||
membreId: json['membreId'] as String?,
|
||||
nomMembre: json['nomMembre'] as String?,
|
||||
numeroMembre: json['numeroMembre'] as String?,
|
||||
statuts:
|
||||
(json['statuts'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
typesCotisation: (json['typesCotisation'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList(),
|
||||
dateEcheanceMin: json['dateEcheanceMin'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateEcheanceMin'] as String),
|
||||
dateEcheanceMax: json['dateEcheanceMax'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateEcheanceMax'] as String),
|
||||
datePaiementMin: json['datePaiementMin'] == null
|
||||
? null
|
||||
: DateTime.parse(json['datePaiementMin'] as String),
|
||||
datePaiementMax: json['datePaiementMax'] == null
|
||||
? null
|
||||
: DateTime.parse(json['datePaiementMax'] as String),
|
||||
montantMin: (json['montantMin'] as num?)?.toDouble(),
|
||||
montantMax: (json['montantMax'] as num?)?.toDouble(),
|
||||
annee: (json['annee'] as num?)?.toInt(),
|
||||
mois: (json['mois'] as num?)?.toInt(),
|
||||
periode: json['periode'] as String?,
|
||||
recurrente: json['recurrente'] as bool?,
|
||||
enRetard: json['enRetard'] as bool?,
|
||||
echeanceProche: json['echeanceProche'] as bool?,
|
||||
methodePaiement: json['methodePaiement'] as String?,
|
||||
recherche: json['recherche'] as String?,
|
||||
triPar: json['triPar'] as String?,
|
||||
page: (json['page'] as num?)?.toInt() ?? 0,
|
||||
size: (json['size'] as num?)?.toInt() ?? 20,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CotisationFilterModelToJson(
|
||||
CotisationFilterModel instance) =>
|
||||
<String, dynamic>{
|
||||
'membreId': instance.membreId,
|
||||
'nomMembre': instance.nomMembre,
|
||||
'numeroMembre': instance.numeroMembre,
|
||||
'statuts': instance.statuts,
|
||||
'typesCotisation': instance.typesCotisation,
|
||||
'dateEcheanceMin': instance.dateEcheanceMin?.toIso8601String(),
|
||||
'dateEcheanceMax': instance.dateEcheanceMax?.toIso8601String(),
|
||||
'datePaiementMin': instance.datePaiementMin?.toIso8601String(),
|
||||
'datePaiementMax': instance.datePaiementMax?.toIso8601String(),
|
||||
'montantMin': instance.montantMin,
|
||||
'montantMax': instance.montantMax,
|
||||
'annee': instance.annee,
|
||||
'mois': instance.mois,
|
||||
'periode': instance.periode,
|
||||
'recurrente': instance.recurrente,
|
||||
'enRetard': instance.enRetard,
|
||||
'echeanceProche': instance.echeanceProche,
|
||||
'methodePaiement': instance.methodePaiement,
|
||||
'recherche': instance.recherche,
|
||||
'triPar': instance.triPar,
|
||||
'page': instance.page,
|
||||
'size': instance.size,
|
||||
};
|
||||
@@ -1,277 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'cotisation_model.g.dart';
|
||||
|
||||
/// Modèle de données pour les cotisations
|
||||
/// Correspond au CotisationDTO du backend
|
||||
@JsonSerializable()
|
||||
class CotisationModel {
|
||||
final String id;
|
||||
final String numeroReference;
|
||||
final String membreId;
|
||||
final String? nomMembre;
|
||||
final String? numeroMembre;
|
||||
final String typeCotisation;
|
||||
final double montantDu;
|
||||
final double montantPaye;
|
||||
final String codeDevise;
|
||||
final String statut;
|
||||
final DateTime dateEcheance;
|
||||
final DateTime? datePaiement;
|
||||
final String? description;
|
||||
final String? periode;
|
||||
final int annee;
|
||||
final int? mois;
|
||||
final String? observations;
|
||||
final bool recurrente;
|
||||
final int nombreRappels;
|
||||
final DateTime? dateDernierRappel;
|
||||
final String? valideParId;
|
||||
final String? nomValidateur;
|
||||
final DateTime? dateValidation;
|
||||
final String? methodePaiement;
|
||||
final String? referencePaiement;
|
||||
final DateTime dateCreation;
|
||||
final DateTime? dateModification;
|
||||
|
||||
const CotisationModel({
|
||||
required this.id,
|
||||
required this.numeroReference,
|
||||
required this.membreId,
|
||||
this.nomMembre,
|
||||
this.numeroMembre,
|
||||
required this.typeCotisation,
|
||||
required this.montantDu,
|
||||
required this.montantPaye,
|
||||
required this.codeDevise,
|
||||
required this.statut,
|
||||
required this.dateEcheance,
|
||||
this.datePaiement,
|
||||
this.description,
|
||||
this.periode,
|
||||
required this.annee,
|
||||
this.mois,
|
||||
this.observations,
|
||||
required this.recurrente,
|
||||
required this.nombreRappels,
|
||||
this.dateDernierRappel,
|
||||
this.valideParId,
|
||||
this.nomValidateur,
|
||||
this.dateValidation,
|
||||
this.methodePaiement,
|
||||
this.referencePaiement,
|
||||
required this.dateCreation,
|
||||
this.dateModification,
|
||||
});
|
||||
|
||||
/// Factory pour créer depuis JSON
|
||||
factory CotisationModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$CotisationModelFromJson(json);
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() => _$CotisationModelToJson(this);
|
||||
|
||||
/// Calcule le montant restant à payer
|
||||
double get montantRestant => montantDu - montantPaye;
|
||||
|
||||
/// Vérifie si la cotisation est entièrement payée
|
||||
bool get isEntierementPayee => montantRestant <= 0;
|
||||
|
||||
/// Vérifie si la cotisation est en retard
|
||||
bool get isEnRetard {
|
||||
return dateEcheance.isBefore(DateTime.now()) && !isEntierementPayee;
|
||||
}
|
||||
|
||||
/// Retourne le pourcentage de paiement
|
||||
double get pourcentagePaiement {
|
||||
if (montantDu == 0) return 0;
|
||||
return (montantPaye / montantDu * 100).clamp(0, 100);
|
||||
}
|
||||
|
||||
/// Calcule le nombre de jours de retard
|
||||
int get joursRetard {
|
||||
if (!isEnRetard) return 0;
|
||||
return DateTime.now().difference(dateEcheance).inDays;
|
||||
}
|
||||
|
||||
/// Retourne la couleur associée au statut
|
||||
String get couleurStatut {
|
||||
switch (statut) {
|
||||
case 'PAYEE':
|
||||
return '#4CAF50'; // Vert
|
||||
case 'EN_ATTENTE':
|
||||
return '#FF9800'; // Orange
|
||||
case 'EN_RETARD':
|
||||
return '#F44336'; // Rouge
|
||||
case 'PARTIELLEMENT_PAYEE':
|
||||
return '#2196F3'; // Bleu
|
||||
case 'ANNULEE':
|
||||
return '#9E9E9E'; // Gris
|
||||
default:
|
||||
return '#757575'; // Gris foncé
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne le libellé du statut en français
|
||||
String get libelleStatut {
|
||||
switch (statut) {
|
||||
case 'PAYEE':
|
||||
return 'Payée';
|
||||
case 'EN_ATTENTE':
|
||||
return 'En attente';
|
||||
case 'EN_RETARD':
|
||||
return 'En retard';
|
||||
case 'PARTIELLEMENT_PAYEE':
|
||||
return 'Partiellement payée';
|
||||
case 'ANNULEE':
|
||||
return 'Annulée';
|
||||
default:
|
||||
return statut;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne le libellé du type de cotisation
|
||||
String get libelleTypeCotisation {
|
||||
switch (typeCotisation) {
|
||||
case 'MENSUELLE':
|
||||
return 'Mensuelle';
|
||||
case 'TRIMESTRIELLE':
|
||||
return 'Trimestrielle';
|
||||
case 'SEMESTRIELLE':
|
||||
return 'Semestrielle';
|
||||
case 'ANNUELLE':
|
||||
return 'Annuelle';
|
||||
case 'EXCEPTIONNELLE':
|
||||
return 'Exceptionnelle';
|
||||
case 'ADHESION':
|
||||
return 'Adhésion';
|
||||
default:
|
||||
return typeCotisation;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne l'icône associée au type de cotisation
|
||||
String get iconeTypeCotisation {
|
||||
switch (typeCotisation) {
|
||||
case 'MENSUELLE':
|
||||
return '📅';
|
||||
case 'TRIMESTRIELLE':
|
||||
return '📊';
|
||||
case 'SEMESTRIELLE':
|
||||
return '📈';
|
||||
case 'ANNUELLE':
|
||||
return '🗓️';
|
||||
case 'EXCEPTIONNELLE':
|
||||
return '⚡';
|
||||
case 'ADHESION':
|
||||
return '🎯';
|
||||
default:
|
||||
return '💰';
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne le nombre de jours jusqu'à l'échéance
|
||||
int get joursJusquEcheance {
|
||||
final maintenant = DateTime.now();
|
||||
final difference = dateEcheance.difference(maintenant);
|
||||
return difference.inDays;
|
||||
}
|
||||
|
||||
/// Vérifie si l'échéance approche (moins de 7 jours)
|
||||
bool get echeanceProche {
|
||||
return joursJusquEcheance <= 7 && joursJusquEcheance >= 0;
|
||||
}
|
||||
|
||||
/// Retourne un message d'urgence basé sur l'échéance
|
||||
String get messageUrgence {
|
||||
final jours = joursJusquEcheance;
|
||||
if (jours < 0) {
|
||||
return 'En retard de ${-jours} jour${-jours > 1 ? 's' : ''}';
|
||||
} else if (jours == 0) {
|
||||
return 'Échéance aujourd\'hui';
|
||||
} else if (jours <= 3) {
|
||||
return 'Échéance dans $jours jour${jours > 1 ? 's' : ''}';
|
||||
} else if (jours <= 7) {
|
||||
return 'Échéance dans $jours jours';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/// Copie avec modifications
|
||||
CotisationModel copyWith({
|
||||
String? id,
|
||||
String? numeroReference,
|
||||
String? membreId,
|
||||
String? nomMembre,
|
||||
String? numeroMembre,
|
||||
String? typeCotisation,
|
||||
double? montantDu,
|
||||
double? montantPaye,
|
||||
String? codeDevise,
|
||||
String? statut,
|
||||
DateTime? dateEcheance,
|
||||
DateTime? datePaiement,
|
||||
String? description,
|
||||
String? periode,
|
||||
int? annee,
|
||||
int? mois,
|
||||
String? observations,
|
||||
bool? recurrente,
|
||||
int? nombreRappels,
|
||||
DateTime? dateDernierRappel,
|
||||
String? valideParId,
|
||||
String? nomValidateur,
|
||||
DateTime? dateValidation,
|
||||
String? methodePaiement,
|
||||
String? referencePaiement,
|
||||
DateTime? dateCreation,
|
||||
DateTime? dateModification,
|
||||
}) {
|
||||
return CotisationModel(
|
||||
id: id ?? this.id,
|
||||
numeroReference: numeroReference ?? this.numeroReference,
|
||||
membreId: membreId ?? this.membreId,
|
||||
nomMembre: nomMembre ?? this.nomMembre,
|
||||
numeroMembre: numeroMembre ?? this.numeroMembre,
|
||||
typeCotisation: typeCotisation ?? this.typeCotisation,
|
||||
montantDu: montantDu ?? this.montantDu,
|
||||
montantPaye: montantPaye ?? this.montantPaye,
|
||||
codeDevise: codeDevise ?? this.codeDevise,
|
||||
statut: statut ?? this.statut,
|
||||
dateEcheance: dateEcheance ?? this.dateEcheance,
|
||||
datePaiement: datePaiement ?? this.datePaiement,
|
||||
description: description ?? this.description,
|
||||
periode: periode ?? this.periode,
|
||||
annee: annee ?? this.annee,
|
||||
mois: mois ?? this.mois,
|
||||
observations: observations ?? this.observations,
|
||||
recurrente: recurrente ?? this.recurrente,
|
||||
nombreRappels: nombreRappels ?? this.nombreRappels,
|
||||
dateDernierRappel: dateDernierRappel ?? this.dateDernierRappel,
|
||||
valideParId: valideParId ?? this.valideParId,
|
||||
nomValidateur: nomValidateur ?? this.nomValidateur,
|
||||
dateValidation: dateValidation ?? this.dateValidation,
|
||||
methodePaiement: methodePaiement ?? this.methodePaiement,
|
||||
referencePaiement: referencePaiement ?? this.referencePaiement,
|
||||
dateCreation: dateCreation ?? this.dateCreation,
|
||||
dateModification: dateModification ?? this.dateModification,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is CotisationModel && other.id == id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CotisationModel(id: $id, numeroReference: $numeroReference, '
|
||||
'nomMembre: $nomMembre, typeCotisation: $typeCotisation, '
|
||||
'montantDu: $montantDu, statut: $statut)';
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'cotisation_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CotisationModel _$CotisationModelFromJson(Map<String, dynamic> json) =>
|
||||
CotisationModel(
|
||||
id: json['id'] as String,
|
||||
numeroReference: json['numeroReference'] as String,
|
||||
membreId: json['membreId'] as String,
|
||||
nomMembre: json['nomMembre'] as String?,
|
||||
numeroMembre: json['numeroMembre'] as String?,
|
||||
typeCotisation: json['typeCotisation'] as String,
|
||||
montantDu: (json['montantDu'] as num).toDouble(),
|
||||
montantPaye: (json['montantPaye'] as num).toDouble(),
|
||||
codeDevise: json['codeDevise'] as String,
|
||||
statut: json['statut'] as String,
|
||||
dateEcheance: DateTime.parse(json['dateEcheance'] as String),
|
||||
datePaiement: json['datePaiement'] == null
|
||||
? null
|
||||
: DateTime.parse(json['datePaiement'] as String),
|
||||
description: json['description'] as String?,
|
||||
periode: json['periode'] as String?,
|
||||
annee: (json['annee'] as num).toInt(),
|
||||
mois: (json['mois'] as num?)?.toInt(),
|
||||
observations: json['observations'] as String?,
|
||||
recurrente: json['recurrente'] as bool,
|
||||
nombreRappels: (json['nombreRappels'] as num).toInt(),
|
||||
dateDernierRappel: json['dateDernierRappel'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateDernierRappel'] as String),
|
||||
valideParId: json['valideParId'] as String?,
|
||||
nomValidateur: json['nomValidateur'] as String?,
|
||||
dateValidation: json['dateValidation'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateValidation'] as String),
|
||||
methodePaiement: json['methodePaiement'] as String?,
|
||||
referencePaiement: json['referencePaiement'] as String?,
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: json['dateModification'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateModification'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CotisationModelToJson(CotisationModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'numeroReference': instance.numeroReference,
|
||||
'membreId': instance.membreId,
|
||||
'nomMembre': instance.nomMembre,
|
||||
'numeroMembre': instance.numeroMembre,
|
||||
'typeCotisation': instance.typeCotisation,
|
||||
'montantDu': instance.montantDu,
|
||||
'montantPaye': instance.montantPaye,
|
||||
'codeDevise': instance.codeDevise,
|
||||
'statut': instance.statut,
|
||||
'dateEcheance': instance.dateEcheance.toIso8601String(),
|
||||
'datePaiement': instance.datePaiement?.toIso8601String(),
|
||||
'description': instance.description,
|
||||
'periode': instance.periode,
|
||||
'annee': instance.annee,
|
||||
'mois': instance.mois,
|
||||
'observations': instance.observations,
|
||||
'recurrente': instance.recurrente,
|
||||
'nombreRappels': instance.nombreRappels,
|
||||
'dateDernierRappel': instance.dateDernierRappel?.toIso8601String(),
|
||||
'valideParId': instance.valideParId,
|
||||
'nomValidateur': instance.nomValidateur,
|
||||
'dateValidation': instance.dateValidation?.toIso8601String(),
|
||||
'methodePaiement': instance.methodePaiement,
|
||||
'referencePaiement': instance.referencePaiement,
|
||||
'dateCreation': instance.dateCreation.toIso8601String(),
|
||||
'dateModification': instance.dateModification?.toIso8601String(),
|
||||
};
|
||||
@@ -1,295 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'cotisation_statistics_model.g.dart';
|
||||
|
||||
/// Modèle de données pour les statistiques des cotisations
|
||||
/// Représente les métriques et analyses des cotisations
|
||||
@JsonSerializable()
|
||||
class CotisationStatisticsModel {
|
||||
final int totalCotisations;
|
||||
final double montantTotal;
|
||||
final double montantPaye;
|
||||
final double montantRestant;
|
||||
final int cotisationsPayees;
|
||||
final int cotisationsEnAttente;
|
||||
final int cotisationsEnRetard;
|
||||
final int cotisationsAnnulees;
|
||||
final double tauxPaiement;
|
||||
final double tauxRetard;
|
||||
final double montantMoyenCotisation;
|
||||
final double montantMoyenPaiement;
|
||||
final Map<String, int>? repartitionParType;
|
||||
final Map<String, double>? montantParType;
|
||||
final Map<String, int>? repartitionParStatut;
|
||||
final Map<String, double>? montantParStatut;
|
||||
final Map<String, int>? evolutionMensuelle;
|
||||
final Map<String, double>? chiffreAffaireMensuel;
|
||||
final List<CotisationTrendModel>? tendances;
|
||||
final DateTime dateCalcul;
|
||||
final String? periode;
|
||||
final int? annee;
|
||||
final int? mois;
|
||||
|
||||
const CotisationStatisticsModel({
|
||||
required this.totalCotisations,
|
||||
required this.montantTotal,
|
||||
required this.montantPaye,
|
||||
required this.montantRestant,
|
||||
required this.cotisationsPayees,
|
||||
required this.cotisationsEnAttente,
|
||||
required this.cotisationsEnRetard,
|
||||
required this.cotisationsAnnulees,
|
||||
required this.tauxPaiement,
|
||||
required this.tauxRetard,
|
||||
required this.montantMoyenCotisation,
|
||||
required this.montantMoyenPaiement,
|
||||
this.repartitionParType,
|
||||
this.montantParType,
|
||||
this.repartitionParStatut,
|
||||
this.montantParStatut,
|
||||
this.evolutionMensuelle,
|
||||
this.chiffreAffaireMensuel,
|
||||
this.tendances,
|
||||
required this.dateCalcul,
|
||||
this.periode,
|
||||
this.annee,
|
||||
this.mois,
|
||||
});
|
||||
|
||||
/// Factory pour créer depuis JSON
|
||||
factory CotisationStatisticsModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$CotisationStatisticsModelFromJson(json);
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() => _$CotisationStatisticsModelToJson(this);
|
||||
|
||||
/// Calcule le pourcentage de cotisations payées
|
||||
double get pourcentageCotisationsPayees {
|
||||
if (totalCotisations == 0) return 0;
|
||||
return (cotisationsPayees / totalCotisations * 100);
|
||||
}
|
||||
|
||||
/// Calcule le pourcentage de cotisations en retard
|
||||
double get pourcentageCotisationsEnRetard {
|
||||
if (totalCotisations == 0) return 0;
|
||||
return (cotisationsEnRetard / totalCotisations * 100);
|
||||
}
|
||||
|
||||
/// Calcule le pourcentage de cotisations en attente
|
||||
double get pourcentageCotisationsEnAttente {
|
||||
if (totalCotisations == 0) return 0;
|
||||
return (cotisationsEnAttente / totalCotisations * 100);
|
||||
}
|
||||
|
||||
/// Retourne le statut de santé financière
|
||||
String get statutSanteFinanciere {
|
||||
if (tauxPaiement >= 90) return 'EXCELLENT';
|
||||
if (tauxPaiement >= 75) return 'BON';
|
||||
if (tauxPaiement >= 60) return 'MOYEN';
|
||||
if (tauxPaiement >= 40) return 'FAIBLE';
|
||||
return 'CRITIQUE';
|
||||
}
|
||||
|
||||
/// Retourne la couleur associée au statut de santé
|
||||
String get couleurSanteFinanciere {
|
||||
switch (statutSanteFinanciere) {
|
||||
case 'EXCELLENT':
|
||||
return '#4CAF50'; // Vert
|
||||
case 'BON':
|
||||
return '#8BC34A'; // Vert clair
|
||||
case 'MOYEN':
|
||||
return '#FF9800'; // Orange
|
||||
case 'FAIBLE':
|
||||
return '#FF5722'; // Orange foncé
|
||||
case 'CRITIQUE':
|
||||
return '#F44336'; // Rouge
|
||||
default:
|
||||
return '#757575'; // Gris
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne le libellé du statut de santé
|
||||
String get libelleSanteFinanciere {
|
||||
switch (statutSanteFinanciere) {
|
||||
case 'EXCELLENT':
|
||||
return 'Excellente santé financière';
|
||||
case 'BON':
|
||||
return 'Bonne santé financière';
|
||||
case 'MOYEN':
|
||||
return 'Santé financière moyenne';
|
||||
case 'FAIBLE':
|
||||
return 'Santé financière faible';
|
||||
case 'CRITIQUE':
|
||||
return 'Situation critique';
|
||||
default:
|
||||
return 'Statut inconnu';
|
||||
}
|
||||
}
|
||||
|
||||
/// Calcule la progression par rapport à la période précédente
|
||||
double? calculerProgression(CotisationStatisticsModel? precedent) {
|
||||
if (precedent == null || precedent.montantPaye == 0) return null;
|
||||
return ((montantPaye - precedent.montantPaye) / precedent.montantPaye * 100);
|
||||
}
|
||||
|
||||
/// Retourne les indicateurs clés de performance
|
||||
Map<String, dynamic> get kpis {
|
||||
return {
|
||||
'tauxRecouvrement': tauxPaiement,
|
||||
'tauxRetard': tauxRetard,
|
||||
'montantMoyenCotisation': montantMoyenCotisation,
|
||||
'montantMoyenPaiement': montantMoyenPaiement,
|
||||
'efficaciteRecouvrement': montantPaye / montantTotal * 100,
|
||||
'risqueImpaye': montantRestant / montantTotal * 100,
|
||||
};
|
||||
}
|
||||
|
||||
/// Retourne les alertes basées sur les seuils
|
||||
List<String> get alertes {
|
||||
List<String> alertes = [];
|
||||
|
||||
if (tauxRetard > 20) {
|
||||
alertes.add('Taux de retard élevé (${tauxRetard.toStringAsFixed(1)}%)');
|
||||
}
|
||||
|
||||
if (tauxPaiement < 60) {
|
||||
alertes.add('Taux de paiement faible (${tauxPaiement.toStringAsFixed(1)}%)');
|
||||
}
|
||||
|
||||
if (cotisationsEnRetard > totalCotisations * 0.3) {
|
||||
alertes.add('Trop de cotisations en retard ($cotisationsEnRetard)');
|
||||
}
|
||||
|
||||
if (montantRestant > montantTotal * 0.4) {
|
||||
alertes.add('Montant impayé important (${montantRestant.toStringAsFixed(0)} XOF)');
|
||||
}
|
||||
|
||||
return alertes;
|
||||
}
|
||||
|
||||
/// Vérifie si des actions sont nécessaires
|
||||
bool get actionRequise => alertes.isNotEmpty;
|
||||
|
||||
/// Retourne les recommandations d'amélioration
|
||||
List<String> get recommandations {
|
||||
List<String> recommandations = [];
|
||||
|
||||
if (tauxRetard > 15) {
|
||||
recommandations.add('Mettre en place des rappels automatiques');
|
||||
recommandations.add('Contacter les membres en retard');
|
||||
}
|
||||
|
||||
if (tauxPaiement < 70) {
|
||||
recommandations.add('Faciliter les moyens de paiement');
|
||||
recommandations.add('Proposer des échéanciers personnalisés');
|
||||
}
|
||||
|
||||
if (cotisationsEnRetard > 10) {
|
||||
recommandations.add('Organiser une campagne de recouvrement');
|
||||
}
|
||||
|
||||
return recommandations;
|
||||
}
|
||||
|
||||
/// Copie avec modifications
|
||||
CotisationStatisticsModel copyWith({
|
||||
int? totalCotisations,
|
||||
double? montantTotal,
|
||||
double? montantPaye,
|
||||
double? montantRestant,
|
||||
int? cotisationsPayees,
|
||||
int? cotisationsEnAttente,
|
||||
int? cotisationsEnRetard,
|
||||
int? cotisationsAnnulees,
|
||||
double? tauxPaiement,
|
||||
double? tauxRetard,
|
||||
double? montantMoyenCotisation,
|
||||
double? montantMoyenPaiement,
|
||||
Map<String, int>? repartitionParType,
|
||||
Map<String, double>? montantParType,
|
||||
Map<String, int>? repartitionParStatut,
|
||||
Map<String, double>? montantParStatut,
|
||||
Map<String, int>? evolutionMensuelle,
|
||||
Map<String, double>? chiffreAffaireMensuel,
|
||||
List<CotisationTrendModel>? tendances,
|
||||
DateTime? dateCalcul,
|
||||
String? periode,
|
||||
int? annee,
|
||||
int? mois,
|
||||
}) {
|
||||
return CotisationStatisticsModel(
|
||||
totalCotisations: totalCotisations ?? this.totalCotisations,
|
||||
montantTotal: montantTotal ?? this.montantTotal,
|
||||
montantPaye: montantPaye ?? this.montantPaye,
|
||||
montantRestant: montantRestant ?? this.montantRestant,
|
||||
cotisationsPayees: cotisationsPayees ?? this.cotisationsPayees,
|
||||
cotisationsEnAttente: cotisationsEnAttente ?? this.cotisationsEnAttente,
|
||||
cotisationsEnRetard: cotisationsEnRetard ?? this.cotisationsEnRetard,
|
||||
cotisationsAnnulees: cotisationsAnnulees ?? this.cotisationsAnnulees,
|
||||
tauxPaiement: tauxPaiement ?? this.tauxPaiement,
|
||||
tauxRetard: tauxRetard ?? this.tauxRetard,
|
||||
montantMoyenCotisation: montantMoyenCotisation ?? this.montantMoyenCotisation,
|
||||
montantMoyenPaiement: montantMoyenPaiement ?? this.montantMoyenPaiement,
|
||||
repartitionParType: repartitionParType ?? this.repartitionParType,
|
||||
montantParType: montantParType ?? this.montantParType,
|
||||
repartitionParStatut: repartitionParStatut ?? this.repartitionParStatut,
|
||||
montantParStatut: montantParStatut ?? this.montantParStatut,
|
||||
evolutionMensuelle: evolutionMensuelle ?? this.evolutionMensuelle,
|
||||
chiffreAffaireMensuel: chiffreAffaireMensuel ?? this.chiffreAffaireMensuel,
|
||||
tendances: tendances ?? this.tendances,
|
||||
dateCalcul: dateCalcul ?? this.dateCalcul,
|
||||
periode: periode ?? this.periode,
|
||||
annee: annee ?? this.annee,
|
||||
mois: mois ?? this.mois,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is CotisationStatisticsModel &&
|
||||
other.dateCalcul == dateCalcul &&
|
||||
other.periode == periode &&
|
||||
other.annee == annee &&
|
||||
other.mois == mois;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(dateCalcul, periode, annee, mois);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CotisationStatisticsModel(totalCotisations: $totalCotisations, '
|
||||
'montantTotal: $montantTotal, tauxPaiement: $tauxPaiement%)';
|
||||
}
|
||||
}
|
||||
|
||||
/// Modèle pour les tendances des cotisations
|
||||
@JsonSerializable()
|
||||
class CotisationTrendModel {
|
||||
final String periode;
|
||||
final int totalCotisations;
|
||||
final double montantTotal;
|
||||
final double montantPaye;
|
||||
final double tauxPaiement;
|
||||
final DateTime date;
|
||||
|
||||
const CotisationTrendModel({
|
||||
required this.periode,
|
||||
required this.totalCotisations,
|
||||
required this.montantTotal,
|
||||
required this.montantPaye,
|
||||
required this.tauxPaiement,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
factory CotisationTrendModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$CotisationTrendModelFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CotisationTrendModelToJson(this);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CotisationTrendModel(periode: $periode, tauxPaiement: $tauxPaiement%)';
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'cotisation_statistics_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CotisationStatisticsModel _$CotisationStatisticsModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
CotisationStatisticsModel(
|
||||
totalCotisations: (json['totalCotisations'] as num).toInt(),
|
||||
montantTotal: (json['montantTotal'] as num).toDouble(),
|
||||
montantPaye: (json['montantPaye'] as num).toDouble(),
|
||||
montantRestant: (json['montantRestant'] as num).toDouble(),
|
||||
cotisationsPayees: (json['cotisationsPayees'] as num).toInt(),
|
||||
cotisationsEnAttente: (json['cotisationsEnAttente'] as num).toInt(),
|
||||
cotisationsEnRetard: (json['cotisationsEnRetard'] as num).toInt(),
|
||||
cotisationsAnnulees: (json['cotisationsAnnulees'] as num).toInt(),
|
||||
tauxPaiement: (json['tauxPaiement'] as num).toDouble(),
|
||||
tauxRetard: (json['tauxRetard'] as num).toDouble(),
|
||||
montantMoyenCotisation:
|
||||
(json['montantMoyenCotisation'] as num).toDouble(),
|
||||
montantMoyenPaiement: (json['montantMoyenPaiement'] as num).toDouble(),
|
||||
repartitionParType:
|
||||
(json['repartitionParType'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toInt()),
|
||||
),
|
||||
montantParType: (json['montantParType'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toDouble()),
|
||||
),
|
||||
repartitionParStatut:
|
||||
(json['repartitionParStatut'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toInt()),
|
||||
),
|
||||
montantParStatut:
|
||||
(json['montantParStatut'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toDouble()),
|
||||
),
|
||||
evolutionMensuelle:
|
||||
(json['evolutionMensuelle'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toInt()),
|
||||
),
|
||||
chiffreAffaireMensuel:
|
||||
(json['chiffreAffaireMensuel'] as Map<String, dynamic>?)?.map(
|
||||
(k, e) => MapEntry(k, (e as num).toDouble()),
|
||||
),
|
||||
tendances: (json['tendances'] as List<dynamic>?)
|
||||
?.map((e) => CotisationTrendModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
dateCalcul: DateTime.parse(json['dateCalcul'] as String),
|
||||
periode: json['periode'] as String?,
|
||||
annee: (json['annee'] as num?)?.toInt(),
|
||||
mois: (json['mois'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CotisationStatisticsModelToJson(
|
||||
CotisationStatisticsModel instance) =>
|
||||
<String, dynamic>{
|
||||
'totalCotisations': instance.totalCotisations,
|
||||
'montantTotal': instance.montantTotal,
|
||||
'montantPaye': instance.montantPaye,
|
||||
'montantRestant': instance.montantRestant,
|
||||
'cotisationsPayees': instance.cotisationsPayees,
|
||||
'cotisationsEnAttente': instance.cotisationsEnAttente,
|
||||
'cotisationsEnRetard': instance.cotisationsEnRetard,
|
||||
'cotisationsAnnulees': instance.cotisationsAnnulees,
|
||||
'tauxPaiement': instance.tauxPaiement,
|
||||
'tauxRetard': instance.tauxRetard,
|
||||
'montantMoyenCotisation': instance.montantMoyenCotisation,
|
||||
'montantMoyenPaiement': instance.montantMoyenPaiement,
|
||||
'repartitionParType': instance.repartitionParType,
|
||||
'montantParType': instance.montantParType,
|
||||
'repartitionParStatut': instance.repartitionParStatut,
|
||||
'montantParStatut': instance.montantParStatut,
|
||||
'evolutionMensuelle': instance.evolutionMensuelle,
|
||||
'chiffreAffaireMensuel': instance.chiffreAffaireMensuel,
|
||||
'tendances': instance.tendances,
|
||||
'dateCalcul': instance.dateCalcul.toIso8601String(),
|
||||
'periode': instance.periode,
|
||||
'annee': instance.annee,
|
||||
'mois': instance.mois,
|
||||
};
|
||||
|
||||
CotisationTrendModel _$CotisationTrendModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
CotisationTrendModel(
|
||||
periode: json['periode'] as String,
|
||||
totalCotisations: (json['totalCotisations'] as num).toInt(),
|
||||
montantTotal: (json['montantTotal'] as num).toDouble(),
|
||||
montantPaye: (json['montantPaye'] as num).toDouble(),
|
||||
tauxPaiement: (json['tauxPaiement'] as num).toDouble(),
|
||||
date: DateTime.parse(json['date'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CotisationTrendModelToJson(
|
||||
CotisationTrendModel instance) =>
|
||||
<String, dynamic>{
|
||||
'periode': instance.periode,
|
||||
'totalCotisations': instance.totalCotisations,
|
||||
'montantTotal': instance.montantTotal,
|
||||
'montantPaye': instance.montantPaye,
|
||||
'tauxPaiement': instance.tauxPaiement,
|
||||
'date': instance.date.toIso8601String(),
|
||||
};
|
||||
@@ -1,391 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'evenement_model.g.dart';
|
||||
|
||||
/// Modèle de données pour un événement UnionFlow
|
||||
/// Aligné avec l'entité Evenement du serveur API
|
||||
@JsonSerializable()
|
||||
class EvenementModel extends Equatable {
|
||||
/// ID unique de l'événement
|
||||
final String? id;
|
||||
|
||||
/// Titre de l'événement
|
||||
final String titre;
|
||||
|
||||
/// Description détaillée
|
||||
final String? description;
|
||||
|
||||
/// Date et heure de début
|
||||
@JsonKey(name: 'dateDebut')
|
||||
final DateTime dateDebut;
|
||||
|
||||
/// Date et heure de fin
|
||||
@JsonKey(name: 'dateFin')
|
||||
final DateTime? dateFin;
|
||||
|
||||
/// Lieu de l'événement
|
||||
final String? lieu;
|
||||
|
||||
/// Adresse complète
|
||||
final String? adresse;
|
||||
|
||||
/// Type d'événement
|
||||
@JsonKey(name: 'typeEvenement')
|
||||
final TypeEvenement typeEvenement;
|
||||
|
||||
/// Statut de l'événement
|
||||
final StatutEvenement statut;
|
||||
|
||||
/// Capacité maximale
|
||||
@JsonKey(name: 'capaciteMax')
|
||||
final int? capaciteMax;
|
||||
|
||||
/// Prix de participation
|
||||
final double? prix;
|
||||
|
||||
/// Inscription requise
|
||||
@JsonKey(name: 'inscriptionRequise')
|
||||
final bool inscriptionRequise;
|
||||
|
||||
/// Date limite d'inscription
|
||||
@JsonKey(name: 'dateLimiteInscription')
|
||||
final DateTime? dateLimiteInscription;
|
||||
|
||||
/// Instructions particulières
|
||||
@JsonKey(name: 'instructionsParticulieres')
|
||||
final String? instructionsParticulieres;
|
||||
|
||||
/// Contact organisateur
|
||||
@JsonKey(name: 'contactOrganisateur')
|
||||
final String? contactOrganisateur;
|
||||
|
||||
/// Matériel requis
|
||||
@JsonKey(name: 'materielRequis')
|
||||
final String? materielRequis;
|
||||
|
||||
/// Visible au public
|
||||
@JsonKey(name: 'visiblePublic')
|
||||
final bool visiblePublic;
|
||||
|
||||
/// Événement actif
|
||||
final bool actif;
|
||||
|
||||
/// Créé par
|
||||
@JsonKey(name: 'creePar')
|
||||
final String? creePar;
|
||||
|
||||
/// Date de création
|
||||
@JsonKey(name: 'dateCreation')
|
||||
final DateTime? dateCreation;
|
||||
|
||||
/// Modifié par
|
||||
@JsonKey(name: 'modifiePar')
|
||||
final String? modifiePar;
|
||||
|
||||
/// Date de modification
|
||||
@JsonKey(name: 'dateModification')
|
||||
final DateTime? dateModification;
|
||||
|
||||
/// Organisation associée (ID)
|
||||
@JsonKey(name: 'organisationId')
|
||||
final String? organisationId;
|
||||
|
||||
/// Organisateur (ID)
|
||||
@JsonKey(name: 'organisateurId')
|
||||
final String? organisateurId;
|
||||
|
||||
const EvenementModel({
|
||||
this.id,
|
||||
required this.titre,
|
||||
this.description,
|
||||
required this.dateDebut,
|
||||
this.dateFin,
|
||||
this.lieu,
|
||||
this.adresse,
|
||||
required this.typeEvenement,
|
||||
required this.statut,
|
||||
this.capaciteMax,
|
||||
this.prix,
|
||||
required this.inscriptionRequise,
|
||||
this.dateLimiteInscription,
|
||||
this.instructionsParticulieres,
|
||||
this.contactOrganisateur,
|
||||
this.materielRequis,
|
||||
required this.visiblePublic,
|
||||
required this.actif,
|
||||
this.creePar,
|
||||
this.dateCreation,
|
||||
this.modifiePar,
|
||||
this.dateModification,
|
||||
this.organisationId,
|
||||
this.organisateurId,
|
||||
});
|
||||
|
||||
/// Factory pour créer depuis JSON
|
||||
factory EvenementModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$EvenementModelFromJson(json);
|
||||
|
||||
/// Convertir vers JSON
|
||||
Map<String, dynamic> toJson() => _$EvenementModelToJson(this);
|
||||
|
||||
/// Copie avec modifications
|
||||
EvenementModel copyWith({
|
||||
String? id,
|
||||
String? titre,
|
||||
String? description,
|
||||
DateTime? dateDebut,
|
||||
DateTime? dateFin,
|
||||
String? lieu,
|
||||
String? adresse,
|
||||
TypeEvenement? typeEvenement,
|
||||
StatutEvenement? statut,
|
||||
int? capaciteMax,
|
||||
double? prix,
|
||||
bool? inscriptionRequise,
|
||||
DateTime? dateLimiteInscription,
|
||||
String? instructionsParticulieres,
|
||||
String? contactOrganisateur,
|
||||
String? materielRequis,
|
||||
bool? visiblePublic,
|
||||
bool? actif,
|
||||
String? creePar,
|
||||
DateTime? dateCreation,
|
||||
String? modifiePar,
|
||||
DateTime? dateModification,
|
||||
String? organisationId,
|
||||
String? organisateurId,
|
||||
}) {
|
||||
return EvenementModel(
|
||||
id: id ?? this.id,
|
||||
titre: titre ?? this.titre,
|
||||
description: description ?? this.description,
|
||||
dateDebut: dateDebut ?? this.dateDebut,
|
||||
dateFin: dateFin ?? this.dateFin,
|
||||
lieu: lieu ?? this.lieu,
|
||||
adresse: adresse ?? this.adresse,
|
||||
typeEvenement: typeEvenement ?? this.typeEvenement,
|
||||
statut: statut ?? this.statut,
|
||||
capaciteMax: capaciteMax ?? this.capaciteMax,
|
||||
prix: prix ?? this.prix,
|
||||
inscriptionRequise: inscriptionRequise ?? this.inscriptionRequise,
|
||||
dateLimiteInscription: dateLimiteInscription ?? this.dateLimiteInscription,
|
||||
instructionsParticulieres: instructionsParticulieres ?? this.instructionsParticulieres,
|
||||
contactOrganisateur: contactOrganisateur ?? this.contactOrganisateur,
|
||||
materielRequis: materielRequis ?? this.materielRequis,
|
||||
visiblePublic: visiblePublic ?? this.visiblePublic,
|
||||
actif: actif ?? this.actif,
|
||||
creePar: creePar ?? this.creePar,
|
||||
dateCreation: dateCreation ?? this.dateCreation,
|
||||
modifiePar: modifiePar ?? this.modifiePar,
|
||||
dateModification: dateModification ?? this.dateModification,
|
||||
organisationId: organisationId ?? this.organisationId,
|
||||
organisateurId: organisateurId ?? this.organisateurId,
|
||||
);
|
||||
}
|
||||
|
||||
/// Méthodes utilitaires
|
||||
|
||||
/// Vérifie si l'événement est à venir
|
||||
bool get estAVenir => dateDebut.isAfter(DateTime.now());
|
||||
|
||||
/// Vérifie si l'événement est en cours
|
||||
bool get estEnCours {
|
||||
final maintenant = DateTime.now();
|
||||
return dateDebut.isBefore(maintenant) &&
|
||||
(dateFin?.isAfter(maintenant) ?? false);
|
||||
}
|
||||
|
||||
/// Vérifie si l'événement est terminé
|
||||
bool get estTermine {
|
||||
final maintenant = DateTime.now();
|
||||
return dateFin?.isBefore(maintenant) ?? dateDebut.isBefore(maintenant);
|
||||
}
|
||||
|
||||
/// Vérifie si les inscriptions sont ouvertes
|
||||
bool get inscriptionsOuvertes {
|
||||
if (!inscriptionRequise) return false;
|
||||
if (dateLimiteInscription == null) return estAVenir;
|
||||
return dateLimiteInscription!.isAfter(DateTime.now()) && estAVenir;
|
||||
}
|
||||
|
||||
/// Durée de l'événement
|
||||
Duration? get duree {
|
||||
if (dateFin == null) return null;
|
||||
return dateFin!.difference(dateDebut);
|
||||
}
|
||||
|
||||
/// Formatage de la durée
|
||||
String get dureeFormatee {
|
||||
final d = duree;
|
||||
if (d == null) return 'Non spécifiée';
|
||||
|
||||
if (d.inDays > 0) {
|
||||
return '${d.inDays} jour${d.inDays > 1 ? 's' : ''}';
|
||||
} else if (d.inHours > 0) {
|
||||
return '${d.inHours}h${d.inMinutes.remainder(60) > 0 ? '${d.inMinutes.remainder(60)}' : ''}';
|
||||
} else {
|
||||
return '${d.inMinutes} min';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
titre,
|
||||
description,
|
||||
dateDebut,
|
||||
dateFin,
|
||||
lieu,
|
||||
adresse,
|
||||
typeEvenement,
|
||||
statut,
|
||||
capaciteMax,
|
||||
prix,
|
||||
inscriptionRequise,
|
||||
dateLimiteInscription,
|
||||
instructionsParticulieres,
|
||||
contactOrganisateur,
|
||||
materielRequis,
|
||||
visiblePublic,
|
||||
actif,
|
||||
creePar,
|
||||
dateCreation,
|
||||
modifiePar,
|
||||
dateModification,
|
||||
organisationId,
|
||||
organisateurId,
|
||||
];
|
||||
}
|
||||
|
||||
/// Types d'événements disponibles
|
||||
@JsonEnum()
|
||||
enum TypeEvenement {
|
||||
@JsonValue('ASSEMBLEE_GENERALE')
|
||||
assembleeGenerale,
|
||||
@JsonValue('REUNION')
|
||||
reunion,
|
||||
@JsonValue('FORMATION')
|
||||
formation,
|
||||
@JsonValue('CONFERENCE')
|
||||
conference,
|
||||
@JsonValue('ATELIER')
|
||||
atelier,
|
||||
@JsonValue('SEMINAIRE')
|
||||
seminaire,
|
||||
@JsonValue('EVENEMENT_SOCIAL')
|
||||
evenementSocial,
|
||||
@JsonValue('MANIFESTATION')
|
||||
manifestation,
|
||||
@JsonValue('CELEBRATION')
|
||||
celebration,
|
||||
@JsonValue('AUTRE')
|
||||
autre,
|
||||
}
|
||||
|
||||
/// Extension pour les libellés des types
|
||||
extension TypeEvenementExtension on TypeEvenement {
|
||||
String get libelle {
|
||||
switch (this) {
|
||||
case TypeEvenement.assembleeGenerale:
|
||||
return 'Assemblée Générale';
|
||||
case TypeEvenement.reunion:
|
||||
return 'Réunion';
|
||||
case TypeEvenement.formation:
|
||||
return 'Formation';
|
||||
case TypeEvenement.conference:
|
||||
return 'Conférence';
|
||||
case TypeEvenement.atelier:
|
||||
return 'Atelier';
|
||||
case TypeEvenement.seminaire:
|
||||
return 'Séminaire';
|
||||
case TypeEvenement.evenementSocial:
|
||||
return 'Événement Social';
|
||||
case TypeEvenement.manifestation:
|
||||
return 'Manifestation';
|
||||
case TypeEvenement.celebration:
|
||||
return 'Célébration';
|
||||
case TypeEvenement.autre:
|
||||
return 'Autre';
|
||||
}
|
||||
}
|
||||
|
||||
String get icone {
|
||||
switch (this) {
|
||||
case TypeEvenement.assembleeGenerale:
|
||||
return '🏛️';
|
||||
case TypeEvenement.reunion:
|
||||
return '👥';
|
||||
case TypeEvenement.formation:
|
||||
return '📚';
|
||||
case TypeEvenement.conference:
|
||||
return '🎤';
|
||||
case TypeEvenement.atelier:
|
||||
return '🔧';
|
||||
case TypeEvenement.seminaire:
|
||||
return '🎓';
|
||||
case TypeEvenement.evenementSocial:
|
||||
return '🎉';
|
||||
case TypeEvenement.manifestation:
|
||||
return '📢';
|
||||
case TypeEvenement.celebration:
|
||||
return '🎊';
|
||||
case TypeEvenement.autre:
|
||||
return '📅';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Statuts d'événements disponibles
|
||||
@JsonEnum()
|
||||
enum StatutEvenement {
|
||||
@JsonValue('PLANIFIE')
|
||||
planifie,
|
||||
@JsonValue('CONFIRME')
|
||||
confirme,
|
||||
@JsonValue('EN_COURS')
|
||||
enCours,
|
||||
@JsonValue('TERMINE')
|
||||
termine,
|
||||
@JsonValue('ANNULE')
|
||||
annule,
|
||||
@JsonValue('REPORTE')
|
||||
reporte,
|
||||
}
|
||||
|
||||
/// Extension pour les libellés des statuts
|
||||
extension StatutEvenementExtension on StatutEvenement {
|
||||
String get libelle {
|
||||
switch (this) {
|
||||
case StatutEvenement.planifie:
|
||||
return 'Planifié';
|
||||
case StatutEvenement.confirme:
|
||||
return 'Confirmé';
|
||||
case StatutEvenement.enCours:
|
||||
return 'En cours';
|
||||
case StatutEvenement.termine:
|
||||
return 'Terminé';
|
||||
case StatutEvenement.annule:
|
||||
return 'Annulé';
|
||||
case StatutEvenement.reporte:
|
||||
return 'Reporté';
|
||||
}
|
||||
}
|
||||
|
||||
String get couleur {
|
||||
switch (this) {
|
||||
case StatutEvenement.planifie:
|
||||
return '#FFA500'; // Orange
|
||||
case StatutEvenement.confirme:
|
||||
return '#4CAF50'; // Vert
|
||||
case StatutEvenement.enCours:
|
||||
return '#2196F3'; // Bleu
|
||||
case StatutEvenement.termine:
|
||||
return '#9E9E9E'; // Gris
|
||||
case StatutEvenement.annule:
|
||||
return '#F44336'; // Rouge
|
||||
case StatutEvenement.reporte:
|
||||
return '#FF9800'; // Orange foncé
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'evenement_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
EvenementModel _$EvenementModelFromJson(Map<String, dynamic> json) =>
|
||||
EvenementModel(
|
||||
id: json['id'] as String?,
|
||||
titre: json['titre'] as String,
|
||||
description: json['description'] as String?,
|
||||
dateDebut: DateTime.parse(json['dateDebut'] as String),
|
||||
dateFin: json['dateFin'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateFin'] as String),
|
||||
lieu: json['lieu'] as String?,
|
||||
adresse: json['adresse'] as String?,
|
||||
typeEvenement: $enumDecode(_$TypeEvenementEnumMap, json['typeEvenement']),
|
||||
statut: $enumDecode(_$StatutEvenementEnumMap, json['statut']),
|
||||
capaciteMax: (json['capaciteMax'] as num?)?.toInt(),
|
||||
prix: (json['prix'] as num?)?.toDouble(),
|
||||
inscriptionRequise: json['inscriptionRequise'] as bool,
|
||||
dateLimiteInscription: json['dateLimiteInscription'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateLimiteInscription'] as String),
|
||||
instructionsParticulieres: json['instructionsParticulieres'] as String?,
|
||||
contactOrganisateur: json['contactOrganisateur'] as String?,
|
||||
materielRequis: json['materielRequis'] as String?,
|
||||
visiblePublic: json['visiblePublic'] as bool,
|
||||
actif: json['actif'] as bool,
|
||||
creePar: json['creePar'] as String?,
|
||||
dateCreation: json['dateCreation'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateCreation'] as String),
|
||||
modifiePar: json['modifiePar'] as String?,
|
||||
dateModification: json['dateModification'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateModification'] as String),
|
||||
organisationId: json['organisationId'] as String?,
|
||||
organisateurId: json['organisateurId'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$EvenementModelToJson(EvenementModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'titre': instance.titre,
|
||||
'description': instance.description,
|
||||
'dateDebut': instance.dateDebut.toIso8601String(),
|
||||
'dateFin': instance.dateFin?.toIso8601String(),
|
||||
'lieu': instance.lieu,
|
||||
'adresse': instance.adresse,
|
||||
'typeEvenement': _$TypeEvenementEnumMap[instance.typeEvenement]!,
|
||||
'statut': _$StatutEvenementEnumMap[instance.statut]!,
|
||||
'capaciteMax': instance.capaciteMax,
|
||||
'prix': instance.prix,
|
||||
'inscriptionRequise': instance.inscriptionRequise,
|
||||
'dateLimiteInscription':
|
||||
instance.dateLimiteInscription?.toIso8601String(),
|
||||
'instructionsParticulieres': instance.instructionsParticulieres,
|
||||
'contactOrganisateur': instance.contactOrganisateur,
|
||||
'materielRequis': instance.materielRequis,
|
||||
'visiblePublic': instance.visiblePublic,
|
||||
'actif': instance.actif,
|
||||
'creePar': instance.creePar,
|
||||
'dateCreation': instance.dateCreation?.toIso8601String(),
|
||||
'modifiePar': instance.modifiePar,
|
||||
'dateModification': instance.dateModification?.toIso8601String(),
|
||||
'organisationId': instance.organisationId,
|
||||
'organisateurId': instance.organisateurId,
|
||||
};
|
||||
|
||||
const _$TypeEvenementEnumMap = {
|
||||
TypeEvenement.assembleeGenerale: 'ASSEMBLEE_GENERALE',
|
||||
TypeEvenement.reunion: 'REUNION',
|
||||
TypeEvenement.formation: 'FORMATION',
|
||||
TypeEvenement.conference: 'CONFERENCE',
|
||||
TypeEvenement.atelier: 'ATELIER',
|
||||
TypeEvenement.seminaire: 'SEMINAIRE',
|
||||
TypeEvenement.evenementSocial: 'EVENEMENT_SOCIAL',
|
||||
TypeEvenement.manifestation: 'MANIFESTATION',
|
||||
TypeEvenement.celebration: 'CELEBRATION',
|
||||
TypeEvenement.autre: 'AUTRE',
|
||||
};
|
||||
|
||||
const _$StatutEvenementEnumMap = {
|
||||
StatutEvenement.planifie: 'PLANIFIE',
|
||||
StatutEvenement.confirme: 'CONFIRME',
|
||||
StatutEvenement.enCours: 'EN_COURS',
|
||||
StatutEvenement.termine: 'TERMINE',
|
||||
StatutEvenement.annule: 'ANNULE',
|
||||
StatutEvenement.reporte: 'REPORTE',
|
||||
};
|
||||
@@ -1,212 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'membre_model.g.dart';
|
||||
|
||||
/// Modèle de données pour un membre UnionFlow
|
||||
/// Aligné avec MembreDTO du serveur API
|
||||
@JsonSerializable()
|
||||
class MembreModel extends Equatable {
|
||||
/// ID unique du membre
|
||||
final String? id;
|
||||
|
||||
/// Numéro unique du membre (format: UF-YYYY-XXXXXXXX)
|
||||
@JsonKey(name: 'numeroMembre')
|
||||
final String numeroMembre;
|
||||
|
||||
/// Nom de famille du membre
|
||||
final String nom;
|
||||
|
||||
/// Prénom du membre
|
||||
final String prenom;
|
||||
|
||||
/// Adresse email
|
||||
final String email;
|
||||
|
||||
/// Numéro de téléphone
|
||||
final String telephone;
|
||||
|
||||
/// Date de naissance
|
||||
@JsonKey(name: 'dateNaissance')
|
||||
final DateTime? dateNaissance;
|
||||
|
||||
/// Adresse complète
|
||||
final String? adresse;
|
||||
|
||||
/// Ville
|
||||
final String? ville;
|
||||
|
||||
/// Code postal
|
||||
@JsonKey(name: 'codePostal')
|
||||
final String? codePostal;
|
||||
|
||||
/// Pays
|
||||
final String? pays;
|
||||
|
||||
/// Profession
|
||||
final String? profession;
|
||||
|
||||
/// Statut du membre (ACTIF, INACTIF, SUSPENDU)
|
||||
final String statut;
|
||||
|
||||
/// Date d'adhésion
|
||||
@JsonKey(name: 'dateAdhesion')
|
||||
final DateTime dateAdhesion;
|
||||
|
||||
/// Date de création
|
||||
@JsonKey(name: 'dateCreation')
|
||||
final DateTime dateCreation;
|
||||
|
||||
/// Date de dernière modification
|
||||
@JsonKey(name: 'dateModification')
|
||||
final DateTime? dateModification;
|
||||
|
||||
/// Indique si le membre est actif
|
||||
final bool actif;
|
||||
|
||||
/// Version pour optimistic locking
|
||||
final int version;
|
||||
|
||||
const MembreModel({
|
||||
this.id,
|
||||
required this.numeroMembre,
|
||||
required this.nom,
|
||||
required this.prenom,
|
||||
required this.email,
|
||||
required this.telephone,
|
||||
this.dateNaissance,
|
||||
this.adresse,
|
||||
this.ville,
|
||||
this.codePostal,
|
||||
this.pays,
|
||||
this.profession,
|
||||
required this.statut,
|
||||
required this.dateAdhesion,
|
||||
required this.dateCreation,
|
||||
this.dateModification,
|
||||
required this.actif,
|
||||
required this.version,
|
||||
});
|
||||
|
||||
/// Constructeur depuis JSON
|
||||
factory MembreModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$MembreModelFromJson(json);
|
||||
|
||||
/// Conversion vers JSON
|
||||
Map<String, dynamic> toJson() => _$MembreModelToJson(this);
|
||||
|
||||
/// Nom complet du membre
|
||||
String get nomComplet => '$prenom $nom';
|
||||
|
||||
/// Initiales du membre
|
||||
String get initiales {
|
||||
final prenomInitial = prenom.isNotEmpty ? prenom[0].toUpperCase() : '';
|
||||
final nomInitial = nom.isNotEmpty ? nom[0].toUpperCase() : '';
|
||||
return '$prenomInitial$nomInitial';
|
||||
}
|
||||
|
||||
/// Adresse complète formatée
|
||||
String get adresseComplete {
|
||||
final parts = <String>[];
|
||||
if (adresse?.isNotEmpty == true) parts.add(adresse!);
|
||||
if (ville?.isNotEmpty == true) parts.add(ville!);
|
||||
if (codePostal?.isNotEmpty == true) parts.add(codePostal!);
|
||||
if (pays?.isNotEmpty == true) parts.add(pays!);
|
||||
return parts.join(', ');
|
||||
}
|
||||
|
||||
/// Libellé du statut formaté
|
||||
String get statutLibelle {
|
||||
switch (statut.toUpperCase()) {
|
||||
case 'ACTIF':
|
||||
return 'Actif';
|
||||
case 'INACTIF':
|
||||
return 'Inactif';
|
||||
case 'SUSPENDU':
|
||||
return 'Suspendu';
|
||||
default:
|
||||
return statut;
|
||||
}
|
||||
}
|
||||
|
||||
/// Âge calculé à partir de la date de naissance
|
||||
int get age {
|
||||
if (dateNaissance == null) return 0;
|
||||
final now = DateTime.now();
|
||||
int age = now.year - dateNaissance!.year;
|
||||
if (now.month < dateNaissance!.month ||
|
||||
(now.month == dateNaissance!.month && now.day < dateNaissance!.day)) {
|
||||
age--;
|
||||
}
|
||||
return age;
|
||||
}
|
||||
|
||||
/// Copie avec modifications
|
||||
MembreModel copyWith({
|
||||
String? id,
|
||||
String? numeroMembre,
|
||||
String? nom,
|
||||
String? prenom,
|
||||
String? email,
|
||||
String? telephone,
|
||||
DateTime? dateNaissance,
|
||||
String? adresse,
|
||||
String? ville,
|
||||
String? codePostal,
|
||||
String? pays,
|
||||
String? profession,
|
||||
String? statut,
|
||||
DateTime? dateAdhesion,
|
||||
DateTime? dateCreation,
|
||||
DateTime? dateModification,
|
||||
bool? actif,
|
||||
int? version,
|
||||
}) {
|
||||
return MembreModel(
|
||||
id: id ?? this.id,
|
||||
numeroMembre: numeroMembre ?? this.numeroMembre,
|
||||
nom: nom ?? this.nom,
|
||||
prenom: prenom ?? this.prenom,
|
||||
email: email ?? this.email,
|
||||
telephone: telephone ?? this.telephone,
|
||||
dateNaissance: dateNaissance ?? this.dateNaissance,
|
||||
adresse: adresse ?? this.adresse,
|
||||
ville: ville ?? this.ville,
|
||||
codePostal: codePostal ?? this.codePostal,
|
||||
pays: pays ?? this.pays,
|
||||
profession: profession ?? this.profession,
|
||||
statut: statut ?? this.statut,
|
||||
dateAdhesion: dateAdhesion ?? this.dateAdhesion,
|
||||
dateCreation: dateCreation ?? this.dateCreation,
|
||||
dateModification: dateModification ?? this.dateModification,
|
||||
actif: actif ?? this.actif,
|
||||
version: version ?? this.version,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
numeroMembre,
|
||||
nom,
|
||||
prenom,
|
||||
email,
|
||||
telephone,
|
||||
dateNaissance,
|
||||
adresse,
|
||||
ville,
|
||||
codePostal,
|
||||
pays,
|
||||
profession,
|
||||
statut,
|
||||
dateAdhesion,
|
||||
dateCreation,
|
||||
dateModification,
|
||||
actif,
|
||||
version,
|
||||
];
|
||||
|
||||
@override
|
||||
String toString() => 'MembreModel(id: $id, numeroMembre: $numeroMembre, '
|
||||
'nomComplet: $nomComplet, email: $email, statut: $statut)';
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'membre_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MembreModel _$MembreModelFromJson(Map<String, dynamic> json) => MembreModel(
|
||||
id: json['id'] as String?,
|
||||
numeroMembre: json['numeroMembre'] as String,
|
||||
nom: json['nom'] as String,
|
||||
prenom: json['prenom'] as String,
|
||||
email: json['email'] as String,
|
||||
telephone: json['telephone'] as String,
|
||||
dateNaissance: json['dateNaissance'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateNaissance'] as String),
|
||||
adresse: json['adresse'] as String?,
|
||||
ville: json['ville'] as String?,
|
||||
codePostal: json['codePostal'] as String?,
|
||||
pays: json['pays'] as String?,
|
||||
profession: json['profession'] as String?,
|
||||
statut: json['statut'] as String,
|
||||
dateAdhesion: DateTime.parse(json['dateAdhesion'] as String),
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: json['dateModification'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateModification'] as String),
|
||||
actif: json['actif'] as bool,
|
||||
version: (json['version'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MembreModelToJson(MembreModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'numeroMembre': instance.numeroMembre,
|
||||
'nom': instance.nom,
|
||||
'prenom': instance.prenom,
|
||||
'email': instance.email,
|
||||
'telephone': instance.telephone,
|
||||
'dateNaissance': instance.dateNaissance?.toIso8601String(),
|
||||
'adresse': instance.adresse,
|
||||
'ville': instance.ville,
|
||||
'codePostal': instance.codePostal,
|
||||
'pays': instance.pays,
|
||||
'profession': instance.profession,
|
||||
'statut': instance.statut,
|
||||
'dateAdhesion': instance.dateAdhesion.toIso8601String(),
|
||||
'dateCreation': instance.dateCreation.toIso8601String(),
|
||||
'dateModification': instance.dateModification?.toIso8601String(),
|
||||
'actif': instance.actif,
|
||||
'version': instance.version,
|
||||
};
|
||||
@@ -1,279 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'payment_model.g.dart';
|
||||
|
||||
/// Modèle de données pour les paiements
|
||||
/// Représente une transaction de paiement de cotisation
|
||||
@JsonSerializable()
|
||||
class PaymentModel {
|
||||
final String id;
|
||||
final String cotisationId;
|
||||
final String numeroReference;
|
||||
final double montant;
|
||||
final String codeDevise;
|
||||
final String methodePaiement;
|
||||
final String statut;
|
||||
final DateTime dateTransaction;
|
||||
final String? numeroTransaction;
|
||||
final String? referencePaiement;
|
||||
final String? description;
|
||||
final Map<String, dynamic>? metadonnees;
|
||||
final String? operateurMobileMoney;
|
||||
final String? numeroTelephone;
|
||||
final String? nomPayeur;
|
||||
final String? emailPayeur;
|
||||
final double? fraisTransaction;
|
||||
final String? codeAutorisation;
|
||||
final String? messageErreur;
|
||||
final int? nombreTentatives;
|
||||
final DateTime? dateEcheance;
|
||||
final DateTime dateCreation;
|
||||
final DateTime? dateModification;
|
||||
|
||||
const PaymentModel({
|
||||
required this.id,
|
||||
required this.cotisationId,
|
||||
required this.numeroReference,
|
||||
required this.montant,
|
||||
required this.codeDevise,
|
||||
required this.methodePaiement,
|
||||
required this.statut,
|
||||
required this.dateTransaction,
|
||||
this.numeroTransaction,
|
||||
this.referencePaiement,
|
||||
this.description,
|
||||
this.metadonnees,
|
||||
this.operateurMobileMoney,
|
||||
this.numeroTelephone,
|
||||
this.nomPayeur,
|
||||
this.emailPayeur,
|
||||
this.fraisTransaction,
|
||||
this.codeAutorisation,
|
||||
this.messageErreur,
|
||||
this.nombreTentatives,
|
||||
this.dateEcheance,
|
||||
required this.dateCreation,
|
||||
this.dateModification,
|
||||
});
|
||||
|
||||
/// Factory pour créer depuis JSON
|
||||
factory PaymentModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentModelFromJson(json);
|
||||
|
||||
/// Convertit vers JSON
|
||||
Map<String, dynamic> toJson() => _$PaymentModelToJson(this);
|
||||
|
||||
/// Vérifie si le paiement est réussi
|
||||
bool get isSuccessful => statut == 'COMPLETED' || statut == 'SUCCESS';
|
||||
|
||||
/// Vérifie si le paiement est en cours
|
||||
bool get isPending => statut == 'PENDING' || statut == 'PROCESSING';
|
||||
|
||||
/// Vérifie si le paiement a échoué
|
||||
bool get isFailed => statut == 'FAILED' || statut == 'ERROR' || statut == 'CANCELLED';
|
||||
|
||||
/// Retourne la couleur associée au statut
|
||||
String get couleurStatut {
|
||||
switch (statut) {
|
||||
case 'COMPLETED':
|
||||
case 'SUCCESS':
|
||||
return '#4CAF50'; // Vert
|
||||
case 'PENDING':
|
||||
case 'PROCESSING':
|
||||
return '#FF9800'; // Orange
|
||||
case 'FAILED':
|
||||
case 'ERROR':
|
||||
return '#F44336'; // Rouge
|
||||
case 'CANCELLED':
|
||||
return '#9E9E9E'; // Gris
|
||||
default:
|
||||
return '#757575'; // Gris foncé
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne le libellé du statut en français
|
||||
String get libelleStatut {
|
||||
switch (statut) {
|
||||
case 'COMPLETED':
|
||||
case 'SUCCESS':
|
||||
return 'Réussi';
|
||||
case 'PENDING':
|
||||
return 'En attente';
|
||||
case 'PROCESSING':
|
||||
return 'En cours';
|
||||
case 'FAILED':
|
||||
return 'Échoué';
|
||||
case 'ERROR':
|
||||
return 'Erreur';
|
||||
case 'CANCELLED':
|
||||
return 'Annulé';
|
||||
default:
|
||||
return statut;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne le libellé de la méthode de paiement
|
||||
String get libelleMethodePaiement {
|
||||
switch (methodePaiement) {
|
||||
case 'MOBILE_MONEY':
|
||||
return 'Mobile Money';
|
||||
case 'ORANGE_MONEY':
|
||||
return 'Orange Money';
|
||||
case 'WAVE':
|
||||
return 'Wave';
|
||||
case 'MOOV_MONEY':
|
||||
return 'Moov Money';
|
||||
case 'CARTE_BANCAIRE':
|
||||
return 'Carte bancaire';
|
||||
case 'VIREMENT':
|
||||
return 'Virement bancaire';
|
||||
case 'ESPECES':
|
||||
return 'Espèces';
|
||||
case 'CHEQUE':
|
||||
return 'Chèque';
|
||||
default:
|
||||
return methodePaiement;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retourne l'icône associée à la méthode de paiement
|
||||
String get iconeMethodePaiement {
|
||||
switch (methodePaiement) {
|
||||
case 'MOBILE_MONEY':
|
||||
case 'ORANGE_MONEY':
|
||||
case 'WAVE':
|
||||
case 'MOOV_MONEY':
|
||||
return '📱';
|
||||
case 'CARTE_BANCAIRE':
|
||||
return '💳';
|
||||
case 'VIREMENT':
|
||||
return '🏦';
|
||||
case 'ESPECES':
|
||||
return '💵';
|
||||
case 'CHEQUE':
|
||||
return '📝';
|
||||
default:
|
||||
return '💰';
|
||||
}
|
||||
}
|
||||
|
||||
/// Calcule le montant net (montant - frais)
|
||||
double get montantNet {
|
||||
return montant - (fraisTransaction ?? 0);
|
||||
}
|
||||
|
||||
/// Vérifie si des frais sont appliqués
|
||||
bool get hasFrais => fraisTransaction != null && fraisTransaction! > 0;
|
||||
|
||||
/// Retourne le pourcentage de frais
|
||||
double get pourcentageFrais {
|
||||
if (montant == 0 || fraisTransaction == null) return 0;
|
||||
return (fraisTransaction! / montant * 100);
|
||||
}
|
||||
|
||||
/// Vérifie si le paiement est expiré
|
||||
bool get isExpired {
|
||||
if (dateEcheance == null) return false;
|
||||
return DateTime.now().isAfter(dateEcheance!) && !isSuccessful;
|
||||
}
|
||||
|
||||
/// Retourne le temps restant avant expiration
|
||||
Duration? get tempsRestant {
|
||||
if (dateEcheance == null || isExpired) return null;
|
||||
return dateEcheance!.difference(DateTime.now());
|
||||
}
|
||||
|
||||
/// Retourne un message d'état détaillé
|
||||
String get messageStatut {
|
||||
switch (statut) {
|
||||
case 'COMPLETED':
|
||||
case 'SUCCESS':
|
||||
return 'Paiement effectué avec succès';
|
||||
case 'PENDING':
|
||||
return 'Paiement en attente de confirmation';
|
||||
case 'PROCESSING':
|
||||
return 'Traitement du paiement en cours';
|
||||
case 'FAILED':
|
||||
return messageErreur ?? 'Le paiement a échoué';
|
||||
case 'ERROR':
|
||||
return messageErreur ?? 'Erreur lors du paiement';
|
||||
case 'CANCELLED':
|
||||
return 'Paiement annulé par l\'utilisateur';
|
||||
default:
|
||||
return 'Statut inconnu';
|
||||
}
|
||||
}
|
||||
|
||||
/// Vérifie si le paiement peut être retenté
|
||||
bool get canRetry {
|
||||
return isFailed && (nombreTentatives ?? 0) < 3 && !isExpired;
|
||||
}
|
||||
|
||||
/// Copie avec modifications
|
||||
PaymentModel copyWith({
|
||||
String? id,
|
||||
String? cotisationId,
|
||||
String? numeroReference,
|
||||
double? montant,
|
||||
String? codeDevise,
|
||||
String? methodePaiement,
|
||||
String? statut,
|
||||
DateTime? dateTransaction,
|
||||
String? numeroTransaction,
|
||||
String? referencePaiement,
|
||||
String? description,
|
||||
Map<String, dynamic>? metadonnees,
|
||||
String? operateurMobileMoney,
|
||||
String? numeroTelephone,
|
||||
String? nomPayeur,
|
||||
String? emailPayeur,
|
||||
double? fraisTransaction,
|
||||
String? codeAutorisation,
|
||||
String? messageErreur,
|
||||
int? nombreTentatives,
|
||||
DateTime? dateEcheance,
|
||||
DateTime? dateCreation,
|
||||
DateTime? dateModification,
|
||||
}) {
|
||||
return PaymentModel(
|
||||
id: id ?? this.id,
|
||||
cotisationId: cotisationId ?? this.cotisationId,
|
||||
numeroReference: numeroReference ?? this.numeroReference,
|
||||
montant: montant ?? this.montant,
|
||||
codeDevise: codeDevise ?? this.codeDevise,
|
||||
methodePaiement: methodePaiement ?? this.methodePaiement,
|
||||
statut: statut ?? this.statut,
|
||||
dateTransaction: dateTransaction ?? this.dateTransaction,
|
||||
numeroTransaction: numeroTransaction ?? this.numeroTransaction,
|
||||
referencePaiement: referencePaiement ?? this.referencePaiement,
|
||||
description: description ?? this.description,
|
||||
metadonnees: metadonnees ?? this.metadonnees,
|
||||
operateurMobileMoney: operateurMobileMoney ?? this.operateurMobileMoney,
|
||||
numeroTelephone: numeroTelephone ?? this.numeroTelephone,
|
||||
nomPayeur: nomPayeur ?? this.nomPayeur,
|
||||
emailPayeur: emailPayeur ?? this.emailPayeur,
|
||||
fraisTransaction: fraisTransaction ?? this.fraisTransaction,
|
||||
codeAutorisation: codeAutorisation ?? this.codeAutorisation,
|
||||
messageErreur: messageErreur ?? this.messageErreur,
|
||||
nombreTentatives: nombreTentatives ?? this.nombreTentatives,
|
||||
dateEcheance: dateEcheance ?? this.dateEcheance,
|
||||
dateCreation: dateCreation ?? this.dateCreation,
|
||||
dateModification: dateModification ?? this.dateModification,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is PaymentModel && other.id == id;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentModel(id: $id, numeroReference: $numeroReference, '
|
||||
'montant: $montant, methodePaiement: $methodePaiement, statut: $statut)';
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'payment_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
PaymentModel _$PaymentModelFromJson(Map<String, dynamic> json) => PaymentModel(
|
||||
id: json['id'] as String,
|
||||
cotisationId: json['cotisationId'] as String,
|
||||
numeroReference: json['numeroReference'] as String,
|
||||
montant: (json['montant'] as num).toDouble(),
|
||||
codeDevise: json['codeDevise'] as String,
|
||||
methodePaiement: json['methodePaiement'] as String,
|
||||
statut: json['statut'] as String,
|
||||
dateTransaction: DateTime.parse(json['dateTransaction'] as String),
|
||||
numeroTransaction: json['numeroTransaction'] as String?,
|
||||
referencePaiement: json['referencePaiement'] as String?,
|
||||
description: json['description'] as String?,
|
||||
metadonnees: json['metadonnees'] as Map<String, dynamic>?,
|
||||
operateurMobileMoney: json['operateurMobileMoney'] as String?,
|
||||
numeroTelephone: json['numeroTelephone'] as String?,
|
||||
nomPayeur: json['nomPayeur'] as String?,
|
||||
emailPayeur: json['emailPayeur'] as String?,
|
||||
fraisTransaction: (json['fraisTransaction'] as num?)?.toDouble(),
|
||||
codeAutorisation: json['codeAutorisation'] as String?,
|
||||
messageErreur: json['messageErreur'] as String?,
|
||||
nombreTentatives: (json['nombreTentatives'] as num?)?.toInt(),
|
||||
dateEcheance: json['dateEcheance'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateEcheance'] as String),
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateModification: json['dateModification'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateModification'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PaymentModelToJson(PaymentModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'cotisationId': instance.cotisationId,
|
||||
'numeroReference': instance.numeroReference,
|
||||
'montant': instance.montant,
|
||||
'codeDevise': instance.codeDevise,
|
||||
'methodePaiement': instance.methodePaiement,
|
||||
'statut': instance.statut,
|
||||
'dateTransaction': instance.dateTransaction.toIso8601String(),
|
||||
'numeroTransaction': instance.numeroTransaction,
|
||||
'referencePaiement': instance.referencePaiement,
|
||||
'description': instance.description,
|
||||
'metadonnees': instance.metadonnees,
|
||||
'operateurMobileMoney': instance.operateurMobileMoney,
|
||||
'numeroTelephone': instance.numeroTelephone,
|
||||
'nomPayeur': instance.nomPayeur,
|
||||
'emailPayeur': instance.emailPayeur,
|
||||
'fraisTransaction': instance.fraisTransaction,
|
||||
'codeAutorisation': instance.codeAutorisation,
|
||||
'messageErreur': instance.messageErreur,
|
||||
'nombreTentatives': instance.nombreTentatives,
|
||||
'dateEcheance': instance.dateEcheance?.toIso8601String(),
|
||||
'dateCreation': instance.dateCreation.toIso8601String(),
|
||||
'dateModification': instance.dateModification?.toIso8601String(),
|
||||
};
|
||||
@@ -1,206 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'wave_checkout_session_model.g.dart';
|
||||
|
||||
/// Modèle pour les sessions de paiement Wave Money
|
||||
/// Aligné avec WaveCheckoutSessionDTO du serveur API
|
||||
@JsonSerializable()
|
||||
class WaveCheckoutSessionModel extends Equatable {
|
||||
/// ID unique de la session
|
||||
final String? id;
|
||||
|
||||
/// ID de la session Wave (retourné par l'API Wave)
|
||||
@JsonKey(name: 'waveSessionId')
|
||||
final String waveSessionId;
|
||||
|
||||
/// URL de la session de paiement Wave
|
||||
@JsonKey(name: 'waveUrl')
|
||||
final String? waveUrl;
|
||||
|
||||
/// Montant du paiement
|
||||
final double montant;
|
||||
|
||||
/// Devise (XOF pour la Côte d'Ivoire)
|
||||
final String devise;
|
||||
|
||||
/// URL de succès (redirection après paiement réussi)
|
||||
@JsonKey(name: 'successUrl')
|
||||
final String successUrl;
|
||||
|
||||
/// URL d'erreur (redirection après échec)
|
||||
@JsonKey(name: 'errorUrl')
|
||||
final String errorUrl;
|
||||
|
||||
/// Statut de la session
|
||||
final String statut;
|
||||
|
||||
/// ID de l'organisation qui effectue le paiement
|
||||
@JsonKey(name: 'organisationId')
|
||||
final String? organisationId;
|
||||
|
||||
/// Nom de l'organisation
|
||||
@JsonKey(name: 'nomOrganisation')
|
||||
final String? nomOrganisation;
|
||||
|
||||
/// ID du membre qui effectue le paiement
|
||||
@JsonKey(name: 'membreId')
|
||||
final String? membreId;
|
||||
|
||||
/// Nom du membre
|
||||
@JsonKey(name: 'nomMembre')
|
||||
final String? nomMembre;
|
||||
|
||||
/// Type de paiement (COTISATION, ADHESION, AIDE, EVENEMENT)
|
||||
@JsonKey(name: 'typePaiement')
|
||||
final String? typePaiement;
|
||||
|
||||
/// Description du paiement
|
||||
final String? description;
|
||||
|
||||
/// Référence externe
|
||||
@JsonKey(name: 'referenceExterne')
|
||||
final String? referenceExterne;
|
||||
|
||||
/// Date de création
|
||||
@JsonKey(name: 'dateCreation')
|
||||
final DateTime dateCreation;
|
||||
|
||||
/// Date d'expiration
|
||||
@JsonKey(name: 'dateExpiration')
|
||||
final DateTime? dateExpiration;
|
||||
|
||||
/// Date de dernière modification
|
||||
@JsonKey(name: 'dateModification')
|
||||
final DateTime? dateModification;
|
||||
|
||||
/// Indique si la session est active
|
||||
final bool actif;
|
||||
|
||||
/// Version pour optimistic locking
|
||||
final int version;
|
||||
|
||||
const WaveCheckoutSessionModel({
|
||||
this.id,
|
||||
required this.waveSessionId,
|
||||
this.waveUrl,
|
||||
required this.montant,
|
||||
required this.devise,
|
||||
required this.successUrl,
|
||||
required this.errorUrl,
|
||||
required this.statut,
|
||||
this.organisationId,
|
||||
this.nomOrganisation,
|
||||
this.membreId,
|
||||
this.nomMembre,
|
||||
this.typePaiement,
|
||||
this.description,
|
||||
this.referenceExterne,
|
||||
required this.dateCreation,
|
||||
this.dateExpiration,
|
||||
this.dateModification,
|
||||
required this.actif,
|
||||
required this.version,
|
||||
});
|
||||
|
||||
/// Constructeur depuis JSON
|
||||
factory WaveCheckoutSessionModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$WaveCheckoutSessionModelFromJson(json);
|
||||
|
||||
/// Conversion vers JSON
|
||||
Map<String, dynamic> toJson() => _$WaveCheckoutSessionModelToJson(this);
|
||||
|
||||
/// Montant formaté avec devise
|
||||
String get montantFormate => '${montant.toStringAsFixed(0)} $devise';
|
||||
|
||||
/// Indique si la session est expirée
|
||||
bool get estExpiree {
|
||||
if (dateExpiration == null) return false;
|
||||
return DateTime.now().isAfter(dateExpiration!);
|
||||
}
|
||||
|
||||
/// Indique si la session est en attente
|
||||
bool get estEnAttente => statut == 'PENDING' || statut == 'EN_ATTENTE';
|
||||
|
||||
/// Indique si la session est réussie
|
||||
bool get estReussie => statut == 'SUCCESS' || statut == 'REUSSIE';
|
||||
|
||||
/// Indique si la session a échoué
|
||||
bool get aEchoue => statut == 'FAILED' || statut == 'ECHEC';
|
||||
|
||||
/// Copie avec modifications
|
||||
WaveCheckoutSessionModel copyWith({
|
||||
String? id,
|
||||
String? waveSessionId,
|
||||
String? waveUrl,
|
||||
double? montant,
|
||||
String? devise,
|
||||
String? successUrl,
|
||||
String? errorUrl,
|
||||
String? statut,
|
||||
String? organisationId,
|
||||
String? nomOrganisation,
|
||||
String? membreId,
|
||||
String? nomMembre,
|
||||
String? typePaiement,
|
||||
String? description,
|
||||
String? referenceExterne,
|
||||
DateTime? dateCreation,
|
||||
DateTime? dateExpiration,
|
||||
DateTime? dateModification,
|
||||
bool? actif,
|
||||
int? version,
|
||||
}) {
|
||||
return WaveCheckoutSessionModel(
|
||||
id: id ?? this.id,
|
||||
waveSessionId: waveSessionId ?? this.waveSessionId,
|
||||
waveUrl: waveUrl ?? this.waveUrl,
|
||||
montant: montant ?? this.montant,
|
||||
devise: devise ?? this.devise,
|
||||
successUrl: successUrl ?? this.successUrl,
|
||||
errorUrl: errorUrl ?? this.errorUrl,
|
||||
statut: statut ?? this.statut,
|
||||
organisationId: organisationId ?? this.organisationId,
|
||||
nomOrganisation: nomOrganisation ?? this.nomOrganisation,
|
||||
membreId: membreId ?? this.membreId,
|
||||
nomMembre: nomMembre ?? this.nomMembre,
|
||||
typePaiement: typePaiement ?? this.typePaiement,
|
||||
description: description ?? this.description,
|
||||
referenceExterne: referenceExterne ?? this.referenceExterne,
|
||||
dateCreation: dateCreation ?? this.dateCreation,
|
||||
dateExpiration: dateExpiration ?? this.dateExpiration,
|
||||
dateModification: dateModification ?? this.dateModification,
|
||||
actif: actif ?? this.actif,
|
||||
version: version ?? this.version,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
waveSessionId,
|
||||
waveUrl,
|
||||
montant,
|
||||
devise,
|
||||
successUrl,
|
||||
errorUrl,
|
||||
statut,
|
||||
organisationId,
|
||||
nomOrganisation,
|
||||
membreId,
|
||||
nomMembre,
|
||||
typePaiement,
|
||||
description,
|
||||
referenceExterne,
|
||||
dateCreation,
|
||||
dateExpiration,
|
||||
dateModification,
|
||||
actif,
|
||||
version,
|
||||
];
|
||||
|
||||
@override
|
||||
String toString() => 'WaveCheckoutSessionModel(id: $id, '
|
||||
'waveSessionId: $waveSessionId, montant: $montantFormate, '
|
||||
'statut: $statut, typePaiement: $typePaiement)';
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'wave_checkout_session_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
WaveCheckoutSessionModel _$WaveCheckoutSessionModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
WaveCheckoutSessionModel(
|
||||
id: json['id'] as String?,
|
||||
waveSessionId: json['waveSessionId'] as String,
|
||||
waveUrl: json['waveUrl'] as String?,
|
||||
montant: (json['montant'] as num).toDouble(),
|
||||
devise: json['devise'] as String,
|
||||
successUrl: json['successUrl'] as String,
|
||||
errorUrl: json['errorUrl'] as String,
|
||||
statut: json['statut'] as String,
|
||||
organisationId: json['organisationId'] as String?,
|
||||
nomOrganisation: json['nomOrganisation'] as String?,
|
||||
membreId: json['membreId'] as String?,
|
||||
nomMembre: json['nomMembre'] as String?,
|
||||
typePaiement: json['typePaiement'] as String?,
|
||||
description: json['description'] as String?,
|
||||
referenceExterne: json['referenceExterne'] as String?,
|
||||
dateCreation: DateTime.parse(json['dateCreation'] as String),
|
||||
dateExpiration: json['dateExpiration'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateExpiration'] as String),
|
||||
dateModification: json['dateModification'] == null
|
||||
? null
|
||||
: DateTime.parse(json['dateModification'] as String),
|
||||
actif: json['actif'] as bool,
|
||||
version: (json['version'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WaveCheckoutSessionModelToJson(
|
||||
WaveCheckoutSessionModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'waveSessionId': instance.waveSessionId,
|
||||
'waveUrl': instance.waveUrl,
|
||||
'montant': instance.montant,
|
||||
'devise': instance.devise,
|
||||
'successUrl': instance.successUrl,
|
||||
'errorUrl': instance.errorUrl,
|
||||
'statut': instance.statut,
|
||||
'organisationId': instance.organisationId,
|
||||
'nomOrganisation': instance.nomOrganisation,
|
||||
'membreId': instance.membreId,
|
||||
'nomMembre': instance.nomMembre,
|
||||
'typePaiement': instance.typePaiement,
|
||||
'description': instance.description,
|
||||
'referenceExterne': instance.referenceExterne,
|
||||
'dateCreation': instance.dateCreation.toIso8601String(),
|
||||
'dateExpiration': instance.dateExpiration?.toIso8601String(),
|
||||
'dateModification': instance.dateModification?.toIso8601String(),
|
||||
'actif': instance.actif,
|
||||
'version': instance.version,
|
||||
};
|
||||
Reference in New Issue
Block a user