diff --git a/as-talange-core/src/main/java/com/astalange/core/entity/Paiement.java b/as-talange-core/src/main/java/com/astalange/core/entity/Paiement.java index 149d59d..de7d82f 100644 --- a/as-talange-core/src/main/java/com/astalange/core/entity/Paiement.java +++ b/as-talange-core/src/main/java/com/astalange/core/entity/Paiement.java @@ -29,6 +29,12 @@ public class Paiement { @Column(name = "gestionnaire") private String gestionnaire; + @Column(name = "numero_cheque", length = 50) + private String numeroCheque; + + @Column(name = "commentaire", columnDefinition = "TEXT") + private String commentaire; + // Getters and Setters public Long getId() { return id; } @@ -48,4 +54,10 @@ public class Paiement { public String getGestionnaire() { return gestionnaire; } public void setGestionnaire(String gestionnaire) { this.gestionnaire = gestionnaire; } + + public String getNumeroCheque() { return numeroCheque; } + public void setNumeroCheque(String numeroCheque) { this.numeroCheque = numeroCheque; } + + public String getCommentaire() { return commentaire; } + public void setCommentaire(String commentaire) { this.commentaire = commentaire; } } diff --git a/as-talange-core/src/main/resources/db/migration/V32__add_cheque_and_commentaire_to_paiement.sql b/as-talange-core/src/main/resources/db/migration/V32__add_cheque_and_commentaire_to_paiement.sql new file mode 100644 index 0000000..9b77ef6 --- /dev/null +++ b/as-talange-core/src/main/resources/db/migration/V32__add_cheque_and_commentaire_to_paiement.sql @@ -0,0 +1,2 @@ +ALTER TABLE paiement ADD COLUMN numero_cheque VARCHAR(50); +ALTER TABLE paiement ADD COLUMN commentaire TEXT; diff --git a/as-talange-web/src/main/java/com/astalange/web/controller/PaiementController.java b/as-talange-web/src/main/java/com/astalange/web/controller/PaiementController.java index c5eacb9..024c1fa 100644 --- a/as-talange-web/src/main/java/com/astalange/web/controller/PaiementController.java +++ b/as-talange-web/src/main/java/com/astalange/web/controller/PaiementController.java @@ -40,6 +40,8 @@ public class PaiementController { @RequestParam BigDecimal montant, @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate datePaiement, @RequestParam Long modePaiementId, + @RequestParam(required = false) String numeroCheque, + @RequestParam(required = false) String commentaire, Principal principal) { Licence licence = licenceRepository.findById(id) @@ -58,6 +60,8 @@ public class PaiementController { paiement.setModePaiement(mode); paiement.setMontant(montant); paiement.setDatePaiement(datePaiement); + paiement.setNumeroCheque(numeroCheque); + paiement.setCommentaire(commentaire); if (principal != null) { paiement.setGestionnaire(principal.getName()); } @@ -82,6 +86,8 @@ public class PaiementController { @RequestParam BigDecimal montant, @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate datePaiement, @RequestParam Long modePaiementId, + @RequestParam(required = false) String numeroCheque, + @RequestParam(required = false) String commentaire, @RequestParam(required = false) String redirect, Principal principal) { @@ -106,6 +112,8 @@ public class PaiementController { paiement.setModePaiement(mode); paiement.setMontant(montant); paiement.setDatePaiement(datePaiement); + paiement.setNumeroCheque(numeroCheque); + paiement.setCommentaire(commentaire); if (principal != null) { paiement.setGestionnaire(principal.getName()); } diff --git a/as-talange-web/src/main/resources/templates/adherents/form.html b/as-talange-web/src/main/resources/templates/adherents/form.html index d73c043..bc24322 100644 --- a/as-talange-web/src/main/resources/templates/adherents/form.html +++ b/as-talange-web/src/main/resources/templates/adherents/form.html @@ -278,6 +278,7 @@ Date Mode + Infos Géré par Montant Actions @@ -289,6 +290,14 @@ Chèque + +
+ N°: 123 +
+
+ Commentaire +
+ - 50.00 € @@ -300,7 +309,9 @@ th:data-mode-id="${paiement.modePaiement.id}" th:data-licence-id="${lic.id}" th:data-max-amount="${lic.getResteAPayer().add(paiement.montant)}" - onclick="openEditPaiementModal(this.getAttribute('data-paiement-id'), this.getAttribute('data-montant'), this.getAttribute('data-date'), this.getAttribute('data-mode-id'), this.getAttribute('data-licence-id'), this.getAttribute('data-max-amount'))" + th:data-cheque="${paiement.numeroCheque}" + th:data-commentaire="${paiement.commentaire}" + onclick="openEditPaiementModal(this.getAttribute('data-paiement-id'), this.getAttribute('data-montant'), this.getAttribute('data-date'), this.getAttribute('data-mode-id'), this.getAttribute('data-licence-id'), this.getAttribute('data-max-amount'), this.getAttribute('data-cheque'), this.getAttribute('data-commentaire'))" class="text-blue-600 hover:text-blue-900 bg-blue-50 hover:bg-blue-100 p-1.5 rounded transition-colors inline-flex items-center" title="Modifier"> @@ -529,11 +540,19 @@
- - +
+ +
+ + +
@@ -561,11 +580,19 @@
- - +
+ +
+ + +
@@ -688,17 +715,35 @@ document.getElementById('paiementModal').classList.add('hidden'); } - function openEditPaiementModal(paiementId, montant, date, modePaiementId, licenceId, maxAmount) { + function openEditPaiementModal(paiementId, montant, date, modePaiementId, licenceId, maxAmount, numeroCheque, commentaire) { document.getElementById('editPaiementModal').classList.remove('hidden'); document.getElementById('editPaiementForm').action = '/paiements/' + paiementId + '/update'; document.getElementById('editPaiementMontant').value = montant; document.getElementById('editPaiementMontant').max = maxAmount; document.getElementById('editPaiementDate').value = date; document.getElementById('editPaiementMode').value = modePaiementId; + document.getElementById('editNumeroCheque').value = numeroCheque || ''; + document.getElementById('editCommentaire').value = commentaire || ''; + toggleChequeVisibility(document.getElementById('editPaiementMode'), 'editChequeBlock', 'editNumeroCheque'); } function closeEditPaiementModal() { document.getElementById('editPaiementModal').classList.add('hidden'); } + + function toggleChequeVisibility(selectElement, blockId, inputId) { + const block = document.getElementById(blockId); + const input = document.getElementById(inputId); + const selectedOption = selectElement.options[selectElement.selectedIndex]; + + if (selectedOption && selectedOption.getAttribute('data-nom') && selectedOption.getAttribute('data-nom').includes('chèque')) { + block.classList.remove('hidden'); + input.required = true; + } else { + block.classList.add('hidden'); + input.required = false; + input.value = ''; + } + } document.addEventListener("DOMContentLoaded", function() { const dateInput = document.getElementById('dateNaissance'); const repBlock = document.getElementById('representantBlock');