fix(paiement): envoi de l'email de confirmation uniquement si le paiement est remis
This commit is contained in:
@@ -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: {}",
|
||||
|
||||
+19
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user