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
@@ -70,6 +70,11 @@ public class PaiementEmailService {
return false;
}
if (Boolean.FALSE.equals(paiement.getRemis())) {
log.info("Paiement non remis (remis=false) pour le paiement ID {}. L'e-mail de confirmation ne sera pas envoyé.", paiement.getId());
return false;
}
Licence licence = paiement.getLicence();
String recipientEmail = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
log.info(">>> [PaiementEmailService] Adhérent: {} {}, Email: {}",
@@ -170,4 +170,23 @@ class PaiementEmailServiceTest {
assertTrue(result);
verify(mailSenderMock, timeout(2000).times(1)).send(any(MimeMessage.class));
}
@Test
void testSendPaiementConfirmation_NonRemis() {
Adherent adherent = new Adherent();
adherent.setNom("DUPONT");
adherent.setPrenom("Jean");
adherent.setEmail("jean.dupont@example.com");
Licence licence = new Licence();
licence.setAdherent(adherent);
Paiement paiement = new Paiement();
paiement.setLicence(licence);
paiement.setMontant(new BigDecimal("50.00"));
paiement.setRemis(false);
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
assertFalse(result, "Devrait retourner false et ne pas envoyer d'email si remis = false");
}
}