feat(paiement): gestion specifique du mode Cheque Sport mairie (masquage num cheque, option remis oui/non, calcul reste a payer)

This commit is contained in:
2026-08-08 00:08:50 +02:00
parent 76e54de182
commit 2f68af6fb5
7 changed files with 184 additions and 18 deletions
@@ -52,6 +52,7 @@ public class PaiementController {
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate datePaiement,
@RequestParam Long modePaiementId,
@RequestParam(required = false) String numeroCheque,
@RequestParam(required = false, defaultValue = "true") Boolean remis,
@RequestParam(required = false) String commentaire,
Principal principal) {
@@ -60,7 +61,7 @@ public class PaiementController {
ModePaiement mode = modePaiementRepository.findById(modePaiementId)
.orElseThrow(() -> new IllegalArgumentException("Invalid ModePaiement ID"));
log.info(">>> [PaiementController] Demande de création de paiement reçue pour Licence ID: {}, Adhérent ID: {}, Montant: {} €", id, adherentId, montant);
log.info(">>> [PaiementController] Demande de création de paiement reçue pour Licence ID: {}, Adhérent ID: {}, Montant: {} €, Remis: {}", id, adherentId, montant, remis);
// Validation basique pour ne pas payer plus que le reste à payer
if (montant.compareTo(licence.getResteAPayer()) > 0) {
@@ -75,6 +76,7 @@ public class PaiementController {
paiement.setDatePaiement(datePaiement);
paiement.setNumeroCheque(numeroCheque);
paiement.setCommentaire(commentaire);
paiement.setRemis(Boolean.TRUE.equals(remis));
if (principal != null) {
paiement.setGestionnaire(principal.getName());
}
@@ -88,7 +90,7 @@ public class PaiementController {
auditLog.setPaiementId(paiement.getId());
auditLog.setMontant(montant);
auditLog.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
auditLog.setDetails("Création d'un paiement de " + montant + "€ via " + mode.getNom() + " pour la licence " + (licence.getNumeroLicence() != null ? licence.getNumeroLicence() : "sans numéro"));
auditLog.setDetails("Création d'un paiement de " + montant + "€ via " + mode.getNom() + " (Remis: " + (Boolean.TRUE.equals(remis) ? "Oui" : "Non") + ") pour la licence " + (licence.getNumeroLicence() != null ? licence.getNumeroLicence() : "sans numéro"));
auditLogPaiementRepository.save(auditLog);
try {
@@ -109,6 +111,7 @@ public class PaiementController {
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate datePaiement,
@RequestParam Long modePaiementId,
@RequestParam(required = false) String numeroCheque,
@RequestParam(required = false, defaultValue = "true") Boolean remis,
@RequestParam(required = false) String commentaire,
@RequestParam(required = false) String redirect,
Principal principal) {
@@ -125,7 +128,8 @@ public class PaiementController {
Licence licence = paiement.getLicence();
// Validation basique pour ne pas dépasser le montant total de la licence
BigDecimal maxAmount = licence.getResteAPayer().add(paiement.getMontant());
BigDecimal currentContribution = Boolean.TRUE.equals(paiement.getRemis()) ? paiement.getMontant() : BigDecimal.ZERO;
BigDecimal maxAmount = licence.getResteAPayer().add(currentContribution);
if (montant.compareTo(maxAmount) > 0) {
montant = maxAmount;
}
@@ -136,6 +140,7 @@ public class PaiementController {
paiement.setDatePaiement(datePaiement);
paiement.setNumeroCheque(numeroCheque);
paiement.setCommentaire(commentaire);
paiement.setRemis(Boolean.TRUE.equals(remis));
if (principal != null) {
paiement.setGestionnaire(principal.getName());
}
@@ -147,7 +152,7 @@ public class PaiementController {
auditLog.setPaiementId(paiement.getId());
auditLog.setMontant(montant);
auditLog.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
auditLog.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom());
auditLog.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom() + ", remis -> " + (Boolean.TRUE.equals(remis) ? "Oui" : "Non"));
auditLogPaiementRepository.save(auditLog);
}