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
@@ -141,6 +141,7 @@ public class Licence {
}
BigDecimal totalPaye = paiements.stream()
.filter(p -> p.getRemis() == null || Boolean.TRUE.equals(p.getRemis()))
.map(Paiement::getMontant)
.reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -154,6 +155,7 @@ public class Licence {
return BigDecimal.ZERO;
}
return paiements.stream()
.filter(p -> p.getRemis() == null || Boolean.TRUE.equals(p.getRemis()))
.map(Paiement::getMontant)
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
@@ -35,6 +35,9 @@ public class Paiement {
@Column(name = "commentaire", columnDefinition = "TEXT")
private String commentaire;
@Column(name = "remis", nullable = false)
private Boolean remis = true;
// Getters and Setters
public Long getId() { return id; }
@@ -60,4 +63,7 @@ public class Paiement {
public String getCommentaire() { return commentaire; }
public void setCommentaire(String commentaire) { this.commentaire = commentaire; }
public Boolean getRemis() { return remis != null ? remis : true; }
public void setRemis(Boolean remis) { this.remis = remis != null ? remis : true; }
}
@@ -0,0 +1,4 @@
ALTER TABLE paiement ADD COLUMN IF NOT EXISTS remis BOOLEAN NOT NULL DEFAULT TRUE;
INSERT INTO mode_paiement (nom) VALUES ('Chèque Sport mairie')
ON CONFLICT (nom) DO NOTHING;
@@ -95,4 +95,34 @@ class LicenceReductionTest {
assertEquals(new BigDecimal("40.00"), licence.getMontantReduction());
assertEquals(new BigDecimal("160.00"), licence.getResteAPayer());
}
@Test
@DisplayName("Devrait inclure le paiement dans le total payé uniquement s'il est remis")
void testPaiementRemisVsNonRemis() {
Categorie cat = new Categorie();
cat.setTarifBase(new BigDecimal("100.00"));
Adherent adh = new Adherent();
adh.setResidentTalange(true);
Licence licence = new Licence();
licence.setCategorie(cat);
licence.setAdherent(adh);
com.astalange.core.entity.Paiement p1 = new com.astalange.core.entity.Paiement();
p1.setMontant(new BigDecimal("40.00"));
p1.setRemis(false); // Non remis (ex: Chèque Sport mairie en attente)
licence.addPaiement(p1);
// La somme de ce chèque non remis n'est PAS déduite => reste à payer = 100.00 €
assertEquals(0, BigDecimal.ZERO.compareTo(licence.getSommePayee()));
assertEquals(0, new BigDecimal("100.00").compareTo(licence.getResteAPayer()));
// Passage à remis = true (remis/encaissé)
p1.setRemis(true);
// La somme est déduite => reste à payer = 60.00 €
assertEquals(0, new BigDecimal("40.00").compareTo(licence.getSommePayee()));
assertEquals(0, new BigDecimal("60.00").compareTo(licence.getResteAPayer()));
}
}