refactor: Suppression données fictives dans DashboardBean

- calculerEvolutionFinanciere() utilise maintenant le backend:
  * Appel à cotisationService.rechercher() pour chaque mois
  * Calcul des montants réels depuis les données PAYEE
  * Tendances calculées depuis données backend réelles

Audit complet effectué:
- AdhesionsBean: Déjà correct, utilise backend
- GuideBean: Contenu statique acceptable (guide utilisateur)
- RolesBean: Configuration système acceptable (rôles fixes)
- MembreListeBean, OrganisationsBean: Utilisent backend

Compilation réussie sans erreurs
This commit is contained in:
dahoud
2025-12-03 21:00:11 +00:00
parent 4b84ce3bc0
commit c7ea3e14be
3 changed files with 25 additions and 428 deletions

View File

@@ -299,37 +299,49 @@ public class DashboardBean implements Serializable {
private void calculerEvolutionFinanciere() {
evolutionFinanciere.clear();
try {
// Récupérer les statistiques des 3 derniers mois depuis le backend
LocalDate now = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM yyyy");
for (int i = 2; i >= 0; i--) {
LocalDate mois = now.minusMonths(i);
String libelleMois = mois.format(formatter);
// Pour chaque mois, on pourrait appeler le backend avec un filtre de date
// Pour l'instant, on calcule une approximation
BigDecimal montant = i == 0 ?
new BigDecimal(totalCotisations.replace(",", "")) :
BigDecimal.ZERO; // Le backend devrait fournir les montants historiques
int annee = mois.getYear();
int numeroMois = mois.getMonthValue();
// Appeler le backend pour obtenir les cotisations du mois
BigDecimal montant = BigDecimal.ZERO;
try {
List<dev.lions.unionflow.client.dto.CotisationDTO> cotisations =
cotisationService.rechercher(null, "PAYEE", null, annee, numeroMois, 0, 10000);
// Calculer le total des cotisations payées pour ce mois
montant = cotisations.stream()
.map(c -> c.getMontantPaye() != null ? c.getMontantPaye() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
LOGGER.info("Évolution financière: " + libelleMois + " = " + montant + " FCFA");
} catch (Exception e) {
LOGGER.warning("Impossible de charger les cotisations pour " + libelleMois + ": " + e.getMessage());
}
evolutionFinanciere.add(new MoisFinancier(libelleMois, montant));
}
// Calculer tendances (si on a les données)
// Calculer tendances depuis les données réelles
if (evolutionFinanciere.size() >= 2) {
MoisFinancier dernierMois = evolutionFinanciere.get(evolutionFinanciere.size() - 1);
MoisFinancier avantDernierMois = evolutionFinanciere.get(evolutionFinanciere.size() - 2);
if (avantDernierMois.getMontant().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal diff = dernierMois.getMontant().subtract(avantDernierMois.getMontant());
evolutionRecettesPourcent = diff.multiply(BigDecimal.valueOf(100))
.divide(avantDernierMois.getMontant(), 0, java.math.RoundingMode.HALF_UP).intValue();
}
}
} catch (Exception e) {
LOGGER.warning("Erreur lors du calcul de l'évolution financière: " + e.getMessage());
}