feat(paiement): plafonner la saisie des paiements en incluant les paiements non remis
This commit is contained in:
@@ -63,9 +63,10 @@ public class PaiementController {
|
||||
|
||||
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) {
|
||||
montant = licence.getResteAPayer();
|
||||
// Validation pour ne pas dépasser le tarif global (tous paiements remis ou non inclus)
|
||||
BigDecimal maxAutorise = licence.getSoldeRestantEngage();
|
||||
if (montant.compareTo(maxAutorise) > 0) {
|
||||
montant = maxAutorise;
|
||||
}
|
||||
|
||||
if (montant.compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -128,9 +129,8 @@ public class PaiementController {
|
||||
|
||||
Licence licence = paiement.getLicence();
|
||||
|
||||
// Validation basique pour ne pas dépasser le montant total de la licence
|
||||
BigDecimal currentContribution = Boolean.TRUE.equals(paiement.getRemis()) ? paiement.getMontant() : BigDecimal.ZERO;
|
||||
BigDecimal maxAmount = licence.getResteAPayer().add(currentContribution);
|
||||
// Validation pour ne pas dépasser le tarif global (tous paiements remis ou non inclus)
|
||||
BigDecimal maxAmount = licence.getSoldeRestantEngage().add(paiement.getMontant());
|
||||
if (montant.compareTo(maxAmount) > 0) {
|
||||
montant = maxAmount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user