fix(paiement): envoi de l'email de confirmation uniquement si le paiement est remis

This commit is contained in:
2026-08-08 00:17:59 +02:00
parent 2f68af6fb5
commit be1ec1c96a
3 changed files with 35 additions and 0 deletions
@@ -124,6 +124,7 @@ public class PaiementController {
BigDecimal ancienMontant = paiement.getMontant();
String ancienMode = paiement.getModePaiement().getNom();
Boolean ancienRemis = paiement.getRemis();
Licence licence = paiement.getLicence();
@@ -154,6 +155,16 @@ public class PaiementController {
auditLog.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
auditLog.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom() + ", remis -> " + (Boolean.TRUE.equals(remis) ? "Oui" : "Non"));
auditLogPaiementRepository.save(auditLog);
// Si le paiement passe de non remis (ex: Chèque Sport mairie) à remis (Oui), envoyer l'email de confirmation
if (Boolean.FALSE.equals(ancienRemis) && Boolean.TRUE.equals(remis)) {
try {
log.info("Appel de sendPaiementConfirmation depuis updatePaiement (passage de remis=false à remis=true) pour le paiement ID: {}", paiement.getId());
paiementEmailService.sendPaiementConfirmation(paiement);
} catch (Exception e) {
log.error("Erreur lors de l'envoi de l'e-mail de confirmation après la remise du paiement ID {}: ", id, e);
}
}
}
if (redirect != null && !redirect.isEmpty()) {