feat(paiement): plafonner la saisie des paiements en incluant les paiements non remis
This commit is contained in:
@@ -160,6 +160,22 @@ public class Licence {
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public BigDecimal getSoldeRestantEngage() {
|
||||
BigDecimal prixTotal = getPrixTotal();
|
||||
|
||||
if (paiements == null || paiements.isEmpty()) {
|
||||
return prixTotal;
|
||||
}
|
||||
|
||||
BigDecimal totalTousPaiements = paiements.stream()
|
||||
.map(Paiement::getMontant)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
BigDecimal reste = prixTotal.subtract(totalTousPaiements);
|
||||
return reste.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : reste;
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public Long getId() { return id; }
|
||||
|
||||
Reference in New Issue
Block a user