Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c40f70e6b3 | ||
|
|
1a49216b02 | ||
|
|
019a445d2c | ||
|
|
9dcd12872a |
@@ -0,0 +1,19 @@
|
|||||||
|
# Configuration Base de données
|
||||||
|
POSTGRES_USER=myuser
|
||||||
|
POSTGRES_PASSWORD=mypassword
|
||||||
|
|
||||||
|
# Configuration Email Brevo (SMTP Relay)
|
||||||
|
# 1. Host: smtp-relay.brevo.com (ou smtp-relay.sendinblue.com)
|
||||||
|
# 2. Port: 587 (TLS/STARTTLS) ou 465 (SSL)
|
||||||
|
# 3. Username: Votre identifiant SMTP Brevo (visible dans Brevo > SMTP & API > SMTP)
|
||||||
|
# 4. Password: Votre clef SMTP Brevo (Master Key ou Clef SMTP générée dans Brevo)
|
||||||
|
SPRING_MAIL_HOST=smtp-relay.brevo.com
|
||||||
|
SPRING_MAIL_PORT=587
|
||||||
|
SPRING_MAIL_USERNAME=votre_login_smtp_brevo@exemple.com
|
||||||
|
SPRING_MAIL_PASSWORD=xsmtpsib-votre_cle_smtp_brevo
|
||||||
|
SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true
|
||||||
|
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true
|
||||||
|
|
||||||
|
# Configuration Captcha (si applicable)
|
||||||
|
CAPTCHA_SITEKEY=
|
||||||
|
CAPTCHA_SECRET=
|
||||||
@@ -51,11 +51,21 @@ jobs:
|
|||||||
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
|
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
|
||||||
CAPTCHA_SECRET: ${{ secrets.CAPTCHA_SECRET }}
|
CAPTCHA_SECRET: ${{ secrets.CAPTCHA_SECRET }}
|
||||||
CAPTCHA_SITEKEY: ${{ secrets.CAPTCHA_SITEKEY }}
|
CAPTCHA_SITEKEY: ${{ secrets.CAPTCHA_SITEKEY }}
|
||||||
|
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
|
||||||
|
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
echo "POSTGRES_USER=${PROD_DB_USER:-myuser}" > .env
|
echo "POSTGRES_USER=${PROD_DB_USER:-myuser}" > .env
|
||||||
echo "POSTGRES_PASSWORD=${PROD_DB_PASSWORD:-mypassword}" >> .env
|
echo "POSTGRES_PASSWORD=${PROD_DB_PASSWORD:-mypassword}" >> .env
|
||||||
echo "CAPTCHA_SECRET=${CAPTCHA_SECRET:-1x0000000000000000000000000000000AA}" >> .env
|
echo "CAPTCHA_SECRET=${CAPTCHA_SECRET:-1x0000000000000000000000000000000AA}" >> .env
|
||||||
echo "CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-1x00000000000000000000AA}" >> .env
|
echo "CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-1x00000000000000000000AA}" >> .env
|
||||||
|
if [ -n "${MAIL_USERNAME}" ]; then
|
||||||
|
echo "SPRING_MAIL_HOST=smtp-relay.brevo.com" >> .env
|
||||||
|
echo "SPRING_MAIL_PORT=587" >> .env
|
||||||
|
echo "SPRING_MAIL_USERNAME=${MAIL_USERNAME}" >> .env
|
||||||
|
echo "SPRING_MAIL_PASSWORD=${MAIL_PASSWORD}" >> .env
|
||||||
|
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true" >> .env
|
||||||
|
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true" >> .env
|
||||||
|
fi
|
||||||
docker compose down app || true
|
docker compose down app || true
|
||||||
docker compose up -d --build app
|
docker compose up -d --build app
|
||||||
|
|
||||||
|
|||||||
@@ -47,11 +47,21 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DB_USER: ${{ secrets.DB_USER }}
|
DB_USER: ${{ secrets.DB_USER }}
|
||||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||||
|
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
|
||||||
|
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
echo "POSTGRES_USER=${DB_USER:-myuser}" > .env
|
echo "POSTGRES_USER=${DB_USER:-myuser}" > .env
|
||||||
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
||||||
echo "CAPTCHA_SECRET=1x0000000000000000000000000000000AA" >> .env
|
echo "CAPTCHA_SECRET=1x0000000000000000000000000000000AA" >> .env
|
||||||
echo "CAPTCHA_SITEKEY=1x00000000000000000000AA" >> .env
|
echo "CAPTCHA_SITEKEY=1x00000000000000000000AA" >> .env
|
||||||
|
if [ -n "${MAIL_USERNAME}" ]; then
|
||||||
|
echo "SPRING_MAIL_HOST=smtp-relay.brevo.com" >> .env
|
||||||
|
echo "SPRING_MAIL_PORT=587" >> .env
|
||||||
|
echo "SPRING_MAIL_USERNAME=${MAIL_USERNAME}" >> .env
|
||||||
|
echo "SPRING_MAIL_PASSWORD=${MAIL_PASSWORD}" >> .env
|
||||||
|
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true" >> .env
|
||||||
|
echo "SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true" >> .env
|
||||||
|
fi
|
||||||
docker compose down app || true
|
docker compose down app || true
|
||||||
docker compose up -d --build app
|
docker compose up -d --build app
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ public class Dotation {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Boolean choisi = false;
|
private Boolean choisi = false;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Boolean commandee = false;
|
||||||
|
|
||||||
|
@Column(name = "date_commande")
|
||||||
|
private java.time.LocalDateTime dateCommande;
|
||||||
|
|
||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
|
|
||||||
public Long getId() { return id; }
|
public Long getId() { return id; }
|
||||||
@@ -65,6 +71,12 @@ public class Dotation {
|
|||||||
public Boolean getChoisi() { return choisi; }
|
public Boolean getChoisi() { return choisi; }
|
||||||
public void setChoisi(Boolean choisi) { this.choisi = choisi; }
|
public void setChoisi(Boolean choisi) { this.choisi = choisi; }
|
||||||
|
|
||||||
|
public Boolean getCommandee() { return commandee; }
|
||||||
|
public void setCommandee(Boolean commandee) { this.commandee = commandee; }
|
||||||
|
|
||||||
|
public java.time.LocalDateTime getDateCommande() { return dateCommande; }
|
||||||
|
public void setDateCommande(java.time.LocalDateTime dateCommande) { this.dateCommande = dateCommande; }
|
||||||
|
|
||||||
public static boolean isSizeMatch(String option, String adherentSize) {
|
public static boolean isSizeMatch(String option, String adherentSize) {
|
||||||
if (option == null || adherentSize == null) return false;
|
if (option == null || adherentSize == null) return false;
|
||||||
String opt = option.trim();
|
String opt = option.trim();
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ import com.astalange.core.entity.Saison;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface DotationRepository extends JpaRepository<Dotation, Long>, JpaSpecificationExecutor<Dotation> {
|
public interface DotationRepository extends JpaRepository<Dotation, Long>, JpaSpecificationExecutor<Dotation> {
|
||||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndFourniFalse(Saison saison);
|
List<Dotation> findByLicence_SaisonAndChoisiTrueAndFourniFalse(Saison saison);
|
||||||
|
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(Saison saison);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,17 @@ public interface PaiementRepository extends JpaRepository<Paiement, Long> {
|
|||||||
"LEFT JOIN FETCH p.licence l " +
|
"LEFT JOIN FETCH p.licence l " +
|
||||||
"LEFT JOIN FETCH l.adherent a " +
|
"LEFT JOIN FETCH l.adherent a " +
|
||||||
"LEFT JOIN FETCH l.categorie c " +
|
"LEFT JOIN FETCH l.categorie c " +
|
||||||
|
"LEFT JOIN FETCH l.saison s " +
|
||||||
"LEFT JOIN FETCH p.modePaiement m " +
|
"LEFT JOIN FETCH p.modePaiement m " +
|
||||||
"ORDER BY p.datePaiement DESC, p.id DESC")
|
"ORDER BY p.datePaiement DESC, p.id DESC")
|
||||||
java.util.List<Paiement> findAllWithAssociations();
|
java.util.List<Paiement> findAllWithAssociations();
|
||||||
|
|
||||||
|
@Query("SELECT p FROM Paiement p " +
|
||||||
|
"LEFT JOIN FETCH p.licence l " +
|
||||||
|
"LEFT JOIN FETCH l.adherent a " +
|
||||||
|
"LEFT JOIN FETCH l.categorie c " +
|
||||||
|
"LEFT JOIN FETCH l.saison s " +
|
||||||
|
"LEFT JOIN FETCH p.modePaiement m " +
|
||||||
|
"WHERE p.id = :id")
|
||||||
|
java.util.Optional<Paiement> findByIdWithDetails(@org.springframework.data.repository.query.Param("id") Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,50 +4,70 @@ import com.astalange.core.entity.Dotation;
|
|||||||
import com.astalange.core.entity.Saison;
|
import com.astalange.core.entity.Saison;
|
||||||
import com.astalange.core.repository.DotationRepository;
|
import com.astalange.core.repository.DotationRepository;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DotationService {
|
public class DotationService {
|
||||||
|
|
||||||
private final DotationRepository dotationRepository;
|
private final DotationRepository dotationRepository;
|
||||||
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
|
||||||
|
|
||||||
public DotationService(DotationRepository dotationRepository) {
|
public DotationService(DotationRepository dotationRepository) {
|
||||||
this.dotationRepository = dotationRepository;
|
this.dotationRepository = dotationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public String genererCsvCommandeEquipement(Saison saisonActive) {
|
public String genererCsvCommandeEquipement(Saison saisonActive) {
|
||||||
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndFourniFalse(saisonActive);
|
return genererCsvCommandeEquipementGrouped(saisonActive, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public String genererCsvCommandeEquipementGrouped(Saison saisonActive, boolean markAsCommandee) {
|
||||||
|
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(saisonActive);
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
String dateCommandeFormatted = now.format(DATE_FORMATTER);
|
||||||
|
|
||||||
|
Map<String, Integer> groupCountMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
for (Dotation d : dotations) {
|
||||||
|
String equipement = d.getEquipement() != null ? d.getEquipement().getNom() : "Inconnu";
|
||||||
|
String reference = d.getEquipement() != null && d.getEquipement().getReference() != null ? d.getEquipement().getReference() : "";
|
||||||
|
String taille = d.getTaille() != null && !d.getTaille().trim().isEmpty() ? d.getTaille() : "Non renseignée";
|
||||||
|
|
||||||
|
String key = equipement + "|||" + reference + "|||" + taille;
|
||||||
|
groupCountMap.put(key, groupCountMap.getOrDefault(key, 0) + 1);
|
||||||
|
|
||||||
|
if (markAsCommandee) {
|
||||||
|
d.setCommandee(true);
|
||||||
|
d.setDateCommande(now);
|
||||||
|
dotationRepository.save(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// BOM for Excel to open UTF-8 correctly
|
// BOM for Excel to open UTF-8 correctly
|
||||||
sb.append('\ufeff');
|
sb.append('\ufeff');
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
sb.append("Catégorie;Nom;Prénom;Poste;Sexe;Équipement;Référence;Taille;Flocage;Numéro\n");
|
sb.append("Équipement;Référence;Taille;Quantité;Commandé;Date de Commande\n");
|
||||||
|
|
||||||
for (Dotation d : dotations) {
|
for (Map.Entry<String, Integer> entry : groupCountMap.entrySet()) {
|
||||||
String categorie = d.getLicence().getCategorie() != null ? d.getLicence().getCategorie().getNom() : "";
|
String[] parts = entry.getKey().split("\\|\\|\\|", -1);
|
||||||
String nom = d.getLicence().getAdherent().getNom();
|
String equipement = parts[0];
|
||||||
String prenom = d.getLicence().getAdherent().getPrenom();
|
String reference = parts[1];
|
||||||
String poste = d.getLicence().getAdherent().getTypeMaillot() != null ? d.getLicence().getAdherent().getTypeMaillot() : "";
|
String taille = parts[2];
|
||||||
String sexe = d.getLicence().getAdherent().getSexe() != null ? d.getLicence().getAdherent().getSexe() : "";
|
int quantite = entry.getValue();
|
||||||
String equipement = d.getEquipement() != null ? d.getEquipement().getNom() : "";
|
|
||||||
String reference = d.getEquipement() != null && d.getEquipement().getReference() != null ? d.getEquipement().getReference() : "";
|
|
||||||
String taille = d.getTaille() != null ? d.getTaille() : "";
|
|
||||||
String flocage = d.getFlocage() != null ? d.getFlocage() : "";
|
|
||||||
String numero = d.getNumero() != null ? d.getNumero() : "";
|
|
||||||
|
|
||||||
sb.append(escapeCsv(categorie)).append(";")
|
sb.append(escapeCsv(equipement)).append(";")
|
||||||
.append(escapeCsv(nom)).append(";")
|
|
||||||
.append(escapeCsv(prenom)).append(";")
|
|
||||||
.append(escapeCsv(poste)).append(";")
|
|
||||||
.append(escapeCsv(sexe)).append(";")
|
|
||||||
.append(escapeCsv(equipement)).append(";")
|
|
||||||
.append(escapeCsv(reference)).append(";")
|
.append(escapeCsv(reference)).append(";")
|
||||||
.append(escapeCsv(taille)).append(";")
|
.append(escapeCsv(taille)).append(";")
|
||||||
.append(escapeCsv(flocage)).append(";")
|
.append(quantite).append(";")
|
||||||
.append(escapeCsv(numero)).append("\n");
|
.append("Oui").append(";")
|
||||||
|
.append(escapeCsv(dateCommandeFormatted)).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@@ -57,9 +77,9 @@ public class DotationService {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// BOM for Excel to open UTF-8 correctly
|
// BOM for Excel to open UTF-8 correctly
|
||||||
sb.append('\ufeff');
|
sb.append('\ufeff');
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
sb.append("Saison;Catégorie;Nom;Prénom;Poste;Sexe;Équipement;Référence;Taille;Flocage;Numéro;Fourni\n");
|
sb.append("Saison;Catégorie;Nom;Prénom;Poste;Sexe;Équipement;Référence;Taille;Flocage;Numéro;Fourni;Commandé;Date Commande\n");
|
||||||
|
|
||||||
for (Dotation d : dotations) {
|
for (Dotation d : dotations) {
|
||||||
String saison = d.getLicence().getSaison() != null ? d.getLicence().getSaison().getNom() : "";
|
String saison = d.getLicence().getSaison() != null ? d.getLicence().getSaison().getNom() : "";
|
||||||
@@ -74,6 +94,8 @@ public class DotationService {
|
|||||||
String flocage = d.getFlocage() != null ? d.getFlocage() : "";
|
String flocage = d.getFlocage() != null ? d.getFlocage() : "";
|
||||||
String numero = d.getNumero() != null ? d.getNumero() : "";
|
String numero = d.getNumero() != null ? d.getNumero() : "";
|
||||||
String fourni = Boolean.TRUE.equals(d.getFourni()) ? "Oui" : "Non";
|
String fourni = Boolean.TRUE.equals(d.getFourni()) ? "Oui" : "Non";
|
||||||
|
String commandee = Boolean.TRUE.equals(d.getCommandee()) ? "Oui" : "Non";
|
||||||
|
String dateCommande = d.getDateCommande() != null ? d.getDateCommande().format(DATE_FORMATTER) : "";
|
||||||
|
|
||||||
sb.append(escapeCsv(saison)).append(";")
|
sb.append(escapeCsv(saison)).append(";")
|
||||||
.append(escapeCsv(categorie)).append(";")
|
.append(escapeCsv(categorie)).append(";")
|
||||||
@@ -86,7 +108,9 @@ public class DotationService {
|
|||||||
.append(escapeCsv(taille)).append(";")
|
.append(escapeCsv(taille)).append(";")
|
||||||
.append(escapeCsv(flocage)).append(";")
|
.append(escapeCsv(flocage)).append(";")
|
||||||
.append(escapeCsv(numero)).append(";")
|
.append(escapeCsv(numero)).append(";")
|
||||||
.append(escapeCsv(fourni)).append("\n");
|
.append(escapeCsv(fourni)).append(";")
|
||||||
|
.append(escapeCsv(commandee)).append(";")
|
||||||
|
.append(escapeCsv(dateCommande)).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
package com.astalange.core.service;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.Licence;
|
||||||
|
import com.astalange.core.entity.Paiement;
|
||||||
|
import com.astalange.core.repository.PaiementRepository;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PaiementEmailService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(PaiementEmailService.class);
|
||||||
|
|
||||||
|
private final JavaMailSender mailSender;
|
||||||
|
private final PaiementRepository paiementRepository;
|
||||||
|
|
||||||
|
@Value("${spring.mail.username:noreply@as-talange.fr}")
|
||||||
|
private String fromEmail = "noreply@as-talange.fr";
|
||||||
|
|
||||||
|
public PaiementEmailService(@Autowired(required = false) JavaMailSender mailSender,
|
||||||
|
PaiementRepository paiementRepository) {
|
||||||
|
this.mailSender = mailSender;
|
||||||
|
this.paiementRepository = paiementRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPaiementConfirmationAsync(Long paiementId) {
|
||||||
|
if (paiementId == null) {
|
||||||
|
log.warn("Impossible d'envoyer l'e-mail de confirmation : ID de paiement nul.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Paiement paiement = paiementRepository.findByIdWithDetails(paiementId)
|
||||||
|
.orElseGet(() -> paiementRepository.findById(paiementId).orElse(null));
|
||||||
|
if (paiement == null) {
|
||||||
|
log.warn("Impossible d'envoyer un e-mail de confirmation : paiement ID {} introuvable en base.", paiementId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendPaiementConfirmation(paiement);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Erreur lors de l'envoi de l'e-mail de confirmation pour le paiement ID {}: ", paiementId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean sendPaiementConfirmation(Paiement paiement) {
|
||||||
|
log.info(">>> [PaiementEmailService] Traitement de la confirmation de paiement pour le paiement ID: {}",
|
||||||
|
paiement != null ? paiement.getId() : null);
|
||||||
|
if (paiement == null || paiement.getLicence() == null) {
|
||||||
|
log.warn("Impossible d'envoyer un e-mail de confirmation : paiement ou licence nulle.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Licence licence = paiement.getLicence();
|
||||||
|
String recipientEmail = licence.getAdherent() != null ? licence.getAdherent().getEmail() : null;
|
||||||
|
log.info(">>> [PaiementEmailService] Adhérent: {} {}, Email: {}",
|
||||||
|
licence.getAdherent() != null ? licence.getAdherent().getPrenom() : "?",
|
||||||
|
licence.getAdherent() != null ? licence.getAdherent().getNom() : "?",
|
||||||
|
recipientEmail);
|
||||||
|
|
||||||
|
if (recipientEmail == null || recipientEmail.trim().isEmpty()) {
|
||||||
|
log.info("Aucune adresse e-mail renseignée pour l'adhérent de la licence ID {}. E-mail non envoyé.", licence.getId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal resteAPayer = licence.getResteAPayer();
|
||||||
|
boolean estTotalite = resteAPayer.compareTo(BigDecimal.ZERO) <= 0;
|
||||||
|
|
||||||
|
String adherentNom = licence.getAdherent() != null
|
||||||
|
? licence.getAdherent().getPrenom() + " " + licence.getAdherent().getNom()
|
||||||
|
: "Adhérent";
|
||||||
|
String categorieNom = licence.getCategorie() != null ? licence.getCategorie().getNom() : "AS Talange";
|
||||||
|
String saisonNom = licence.getSaison() != null ? licence.getSaison().getNom() : "";
|
||||||
|
|
||||||
|
String subject = estTotalite
|
||||||
|
? "AS Talange - Confirmation de paiement (Solde intégralement réglé)"
|
||||||
|
: "AS Talange - Confirmation de paiement partiel";
|
||||||
|
|
||||||
|
String htmlContent = buildEmailHtml(paiement, licence, adherentNom, categorieNom, saisonNom, estTotalite, resteAPayer);
|
||||||
|
BigDecimal montantPaiement = paiement.getMontant();
|
||||||
|
|
||||||
|
// Envoi asynchrone via CompletableFuture pour ne pas bloquer la réponse HTTP
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
if (mailSender != null) {
|
||||||
|
try {
|
||||||
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8");
|
||||||
|
helper.setFrom(fromEmail);
|
||||||
|
helper.setTo(recipientEmail);
|
||||||
|
helper.setSubject(subject);
|
||||||
|
helper.setText(htmlContent, true);
|
||||||
|
|
||||||
|
mailSender.send(message);
|
||||||
|
log.info("E-mail de confirmation de paiement envoyé avec succès via SMTP à {} (Montant: {} €)", recipientEmail, montantPaiement);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Impossible d'envoyer l'e-mail de paiement via SMTP pour {}: {}. Simulation en mode log.", recipientEmail, e.getMessage());
|
||||||
|
logDevEmail(recipientEmail, subject, htmlContent);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("Aucun JavaMailSender configuré (Mode DEV). Simulation de l'envoi d'e-mail de paiement.");
|
||||||
|
logDevEmail(recipientEmail, subject, htmlContent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logDevEmail(String recipient, String subject, String body) {
|
||||||
|
log.info("==================== [SIMULATION E-MAIL PAIEMENT] ====================");
|
||||||
|
log.info("Destinataire: {}", recipient);
|
||||||
|
log.info("Sujet: {}", subject);
|
||||||
|
log.info("Contenu:\n{}", body);
|
||||||
|
log.info("======================================================================");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildEmailHtml(Paiement paiement, Licence licence, String adherentNom,
|
||||||
|
String categorieNom, String saisonNom,
|
||||||
|
boolean estTotalite, BigDecimal resteAPayer) {
|
||||||
|
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
|
||||||
|
String datePaiementStr = paiement.getDatePaiement() != null
|
||||||
|
? paiement.getDatePaiement().format(dateFormatter)
|
||||||
|
: "";
|
||||||
|
|
||||||
|
String montantStr = String.format(Locale.FRANCE, "%.2f €", paiement.getMontant());
|
||||||
|
String prixTotalStr = String.format(Locale.FRANCE, "%.2f €", licence.getPrixTotal());
|
||||||
|
String totalPayeStr = String.format(Locale.FRANCE, "%.2f €", licence.getSommePayee());
|
||||||
|
String resteStr = String.format(Locale.FRANCE, "%.2f €", resteAPayer);
|
||||||
|
|
||||||
|
String modePaiementStr = paiement.getModePaiement() != null ? paiement.getModePaiement().getNom() : "-";
|
||||||
|
if (paiement.getNumeroCheque() != null && !paiement.getNumeroCheque().isBlank()) {
|
||||||
|
modePaiementStr += " (N° " + paiement.getNumeroCheque() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
String headerTitle = estTotalite ? "Confirmation de paiement intégral" : "Confirmation de paiement partiel";
|
||||||
|
|
||||||
|
String messageParagraph;
|
||||||
|
if (estTotalite) {
|
||||||
|
messageParagraph = """
|
||||||
|
<p>Nous vous confirmons la bonne réception de votre versement de <strong>%s</strong> effectué le <strong>%s</strong> par <strong>%s</strong>.</p>
|
||||||
|
<div class="alert alert-success">
|
||||||
|
<strong>Paiement solde :</strong> Le paiement de votre cotisation pour la saison <strong>%s</strong> (catégorie <strong>%s</strong>) a été pris en compte et est désormais <strong>entièrement réglé</strong>.
|
||||||
|
</div>
|
||||||
|
""".formatted(montantStr, datePaiementStr, modePaiementStr, saisonNom, categorieNom);
|
||||||
|
} else {
|
||||||
|
messageParagraph = """
|
||||||
|
<p>Nous vous confirmons la bonne réception de votre versement partiel de <strong>%s</strong> effectué le <strong>%s</strong> par <strong>%s</strong>.</p>
|
||||||
|
<p>Ce paiement a bien été pris en compte pour la cotisation de la saison <strong>%s</strong> (catégorie <strong>%s</strong>).</p>
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
<strong>Information Solde :</strong> Il reste actuellement la somme de <strong>%s</strong> à régler.
|
||||||
|
</div>
|
||||||
|
""".formatted(montantStr, datePaiementStr, modePaiementStr, saisonNom, categorieNom, resteStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
String soldeBadge = estTotalite
|
||||||
|
? "<span class=\"badge badge-success\">0,00 € (Réglé)</span>"
|
||||||
|
: "<span class=\"badge badge-warning\">" + resteStr + "</span>";
|
||||||
|
|
||||||
|
return """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; background-color: #f4f6f8; margin: 0; padding: 20px; color: #333; }
|
||||||
|
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
|
||||||
|
.header { background-color: #1e3a8a; color: #ffffff; padding: 24px; text-align: center; }
|
||||||
|
.header h1 { margin: 0; font-size: 22px; }
|
||||||
|
.content { padding: 24px; line-height: 1.6; }
|
||||||
|
.alert { padding: 14px 18px; border-radius: 6px; margin: 18px 0; font-size: 14px; }
|
||||||
|
.alert-success { background-color: #d1fae5; border-left: 4px solid #10b981; color: #065f46; }
|
||||||
|
.alert-warning { background-color: #fef3c7; border-left: 4px solid #f59e0b; color: #92400e; }
|
||||||
|
.receipt-box { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 16px; margin-top: 20px; }
|
||||||
|
.receipt-box h3 { margin-top: 0; margin-bottom: 12px; font-size: 16px; color: #1e3a8a; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; }
|
||||||
|
.receipt-table { width: 100%%; border-collapse: collapse; font-size: 14px; }
|
||||||
|
.receipt-table td { padding: 6px 0; }
|
||||||
|
.receipt-table td.label { color: #6b7280; width: 50%%; }
|
||||||
|
.receipt-table td.value { font-weight: bold; text-align: right; }
|
||||||
|
.badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-weight: bold; font-size: 13px; }
|
||||||
|
.badge-success { background-color: #d1fae5; color: #065f46; }
|
||||||
|
.badge-warning { background-color: #fef3c7; color: #92400e; }
|
||||||
|
.footer { background: #f9fafb; border-top: 1px solid #e5e7eb; padding: 16px; text-align: center; font-size: 12px; color: #6b7280; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>AS Talange - %s</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>Bonjour <strong>%s</strong>,</p>
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
<div class="receipt-box">
|
||||||
|
<h3>Reçu de Paiement</h3>
|
||||||
|
<table class="receipt-table">
|
||||||
|
<tr>
|
||||||
|
<td class="label">Adhérent :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Saison / Catégorie :</td>
|
||||||
|
<td class="value">%s %s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Date du paiement :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Montant versé :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Mode de règlement :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Montant total cotisation :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Total versé à ce jour :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Reste à payer :</td>
|
||||||
|
<td class="value">%s</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="margin-top: 20px;">Ce courriel vous sert de justificatif de paiement.<br>Sportivement,<br><strong>L'équipe de l'AS Talange</strong></p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
Cet e-mail a été envoyé automatiquement par le système de gestion de l'AS Talange.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
""".formatted(
|
||||||
|
headerTitle,
|
||||||
|
adherentNom,
|
||||||
|
messageParagraph,
|
||||||
|
adherentNom,
|
||||||
|
saisonNom,
|
||||||
|
categorieNom,
|
||||||
|
datePaiementStr,
|
||||||
|
montantStr,
|
||||||
|
modePaiementStr,
|
||||||
|
prixTotalStr,
|
||||||
|
totalPayeStr,
|
||||||
|
soldeBadge
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
-8
@@ -67,13 +67,16 @@ public class SportEasyEmailService {
|
|||||||
? licence.getCategorie().getSportEasyToken().trim()
|
? licence.getCategorie().getSportEasyToken().trim()
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
|
if (token.isEmpty()) {
|
||||||
|
throw new IllegalStateException("Le lien d'invitation SportEasy n'a pas été renseigné pour la catégorie "
|
||||||
|
+ (licence.getCategorie() != null ? licence.getCategorie().getNom() : "") + ".");
|
||||||
|
}
|
||||||
|
|
||||||
String inviteUrl;
|
String inviteUrl;
|
||||||
if (token.startsWith("http://") || token.startsWith("https://")) {
|
if (token.startsWith("http://") || token.startsWith("https://")) {
|
||||||
inviteUrl = token;
|
inviteUrl = token;
|
||||||
} else if (!token.isEmpty()) {
|
|
||||||
inviteUrl = sportEasyBaseUrl.endsWith("/") ? sportEasyBaseUrl + token : sportEasyBaseUrl + "/" + token;
|
|
||||||
} else {
|
} else {
|
||||||
inviteUrl = sportEasyBaseUrl;
|
inviteUrl = sportEasyBaseUrl.endsWith("/") ? sportEasyBaseUrl + token : sportEasyBaseUrl + "/" + token;
|
||||||
}
|
}
|
||||||
|
|
||||||
String adherentNom = licence.getAdherent().getPrenom() + " " + licence.getAdherent().getNom();
|
String adherentNom = licence.getAdherent().getPrenom() + " " + licence.getAdherent().getNom();
|
||||||
@@ -193,6 +196,7 @@ public class SportEasyEmailService {
|
|||||||
.header h1 { margin: 0; font-size: 22px; }
|
.header h1 { margin: 0; font-size: 22px; }
|
||||||
.content { padding: 24px; line-height: 1.6; }
|
.content { padding: 24px; line-height: 1.6; }
|
||||||
.btn { display: inline-block; background-color: #2563eb; color: #ffffff !important; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: bold; margin-top: 16px; text-align: center; }
|
.btn { display: inline-block; background-color: #2563eb; color: #ffffff !important; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: bold; margin-top: 16px; text-align: center; }
|
||||||
|
.url-box { background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; margin-top: 16px; font-size: 13px; word-break: break-all; color: #1f2937; }
|
||||||
.footer { background: #f9fafb; border-top: 1px solid #e5e7eb; padding: 16px; text-align: center; font-size: 12px; color: #6b7280; }
|
.footer { background: #f9fafb; border-top: 1px solid #e5e7eb; padding: 16px; text-align: center; font-size: 12px; color: #6b7280; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@@ -203,13 +207,18 @@ public class SportEasyEmailService {
|
|||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p>Bonjour <strong>%s</strong>,</p>
|
<p>Bonjour <strong>%s</strong>,</p>
|
||||||
<p>Afin d'assurer le suivi des entraînements, convocations et matchs pour la saison <strong>%s</strong> (catégorie <strong>%s</strong>), le club utilise la plateforme <strong>SportEasy</strong>.</p>
|
<p>Afin d'assurer le suivi des entraînements, convocations et matchs pour la saison <strong>%s</strong> (catégorie <strong>%s</strong>), merci de rejoindre l'équipe sur la plateforme <strong>SportEasy</strong> en cliquant sur le lien ci-dessous :</p>
|
||||||
<p>Merci de rejoindre le groupe de votre catégorie en cliquant sur le bouton ci-dessous :</p>
|
|
||||||
<p style="text-align: center;">
|
<p style="text-align: center;">
|
||||||
<a href="%s" class="btn" target="_blank">Rejoindre l'équipe SportEasy</a>
|
<a href="%s" class="btn" target="_blank">Rejoindre la catégorie sur SportEasy</a>
|
||||||
</p>
|
</p>
|
||||||
<p>Si vous possédez déjà un compte SportEasy, connectez-vous avec vos identifiants puis rejoignez le groupe. Sinon, créez votre compte gratuitement en quelques secondes.</p>
|
|
||||||
<p>À très vite sur les terrains !<br><strong>L'équipe de l'AS Talange</strong></p>
|
<div class="url-box">
|
||||||
|
<strong>Lien d'invitation direct :</strong><br>
|
||||||
|
<a href="%s" style="color: #2563eb;">%s</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="margin-top: 20px;">À très vite sur les terrains !<br><strong>L'équipe de l'AS Talange</strong></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
Cet e-mail a été envoyé automatiquement par le système de gestion de l'AS Talange.
|
Cet e-mail a été envoyé automatiquement par le système de gestion de l'AS Talange.
|
||||||
@@ -221,6 +230,8 @@ public class SportEasyEmailService {
|
|||||||
adherentNom,
|
adherentNom,
|
||||||
saisonNom != null ? saisonNom : "",
|
saisonNom != null ? saisonNom : "",
|
||||||
categorieNom,
|
categorieNom,
|
||||||
|
inviteUrl,
|
||||||
|
inviteUrl,
|
||||||
inviteUrl
|
inviteUrl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE dotation ADD COLUMN commandee BOOLEAN NOT NULL DEFAULT FALSE;
|
||||||
|
ALTER TABLE dotation ADD COLUMN date_commande TIMESTAMP WITHOUT TIME ZONE;
|
||||||
+173
@@ -0,0 +1,173 @@
|
|||||||
|
package com.astalange.core.service;
|
||||||
|
|
||||||
|
import com.astalange.core.entity.Adherent;
|
||||||
|
import com.astalange.core.entity.Categorie;
|
||||||
|
import com.astalange.core.entity.Licence;
|
||||||
|
import com.astalange.core.entity.ModePaiement;
|
||||||
|
import com.astalange.core.entity.Paiement;
|
||||||
|
import com.astalange.core.entity.Saison;
|
||||||
|
import jakarta.mail.internet.MimeMessage;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
import com.astalange.core.repository.PaiementRepository;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
class PaiementEmailServiceTest {
|
||||||
|
|
||||||
|
private PaiementEmailService paiementEmailService;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
paiementEmailService = new PaiementEmailService(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSendPaiementConfirmation_Totalite_SimulatedMode() {
|
||||||
|
Adherent adherent = new Adherent();
|
||||||
|
adherent.setNom("DUPONT");
|
||||||
|
adherent.setPrenom("Jean");
|
||||||
|
adherent.setEmail("jean.dupont@example.com");
|
||||||
|
|
||||||
|
Categorie categorie = new Categorie();
|
||||||
|
categorie.setNom("U13");
|
||||||
|
categorie.setTarifBase(new BigDecimal("150.00"));
|
||||||
|
categorie.setTarifExterieur(new BigDecimal("150.00"));
|
||||||
|
|
||||||
|
Saison saison = new Saison();
|
||||||
|
saison.setNom("2026/2027");
|
||||||
|
|
||||||
|
Licence licence = new Licence();
|
||||||
|
licence.setId(1L);
|
||||||
|
licence.setAdherent(adherent);
|
||||||
|
licence.setCategorie(categorie);
|
||||||
|
licence.setSaison(saison);
|
||||||
|
|
||||||
|
ModePaiement modePaiement = new ModePaiement();
|
||||||
|
modePaiement.setId(1L);
|
||||||
|
modePaiement.setNom("Carte bancaire");
|
||||||
|
|
||||||
|
Paiement paiement = new Paiement();
|
||||||
|
paiement.setId(10L);
|
||||||
|
paiement.setLicence(licence);
|
||||||
|
paiement.setMontant(new BigDecimal("150.00"));
|
||||||
|
paiement.setDatePaiement(LocalDate.now());
|
||||||
|
paiement.setModePaiement(modePaiement);
|
||||||
|
|
||||||
|
licence.addPaiement(paiement);
|
||||||
|
|
||||||
|
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
|
||||||
|
assertTrue(result, "Dev simulation mode should return true when email processing succeeds");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSendPaiementConfirmation_Partiel_SimulatedMode() {
|
||||||
|
Adherent adherent = new Adherent();
|
||||||
|
adherent.setNom("MARTIN");
|
||||||
|
adherent.setPrenom("Sophie");
|
||||||
|
adherent.setEmail("sophie.martin@example.com");
|
||||||
|
|
||||||
|
Categorie categorie = new Categorie();
|
||||||
|
categorie.setNom("Senior");
|
||||||
|
categorie.setTarifBase(new BigDecimal("200.00"));
|
||||||
|
categorie.setTarifExterieur(new BigDecimal("200.00"));
|
||||||
|
|
||||||
|
Saison saison = new Saison();
|
||||||
|
saison.setNom("2026/2027");
|
||||||
|
|
||||||
|
Licence licence = new Licence();
|
||||||
|
licence.setId(2L);
|
||||||
|
licence.setAdherent(adherent);
|
||||||
|
licence.setCategorie(categorie);
|
||||||
|
licence.setSaison(saison);
|
||||||
|
|
||||||
|
ModePaiement modePaiement = new ModePaiement();
|
||||||
|
modePaiement.setId(2L);
|
||||||
|
modePaiement.setNom("Espèces");
|
||||||
|
|
||||||
|
Paiement paiement = new Paiement();
|
||||||
|
paiement.setId(11L);
|
||||||
|
paiement.setLicence(licence);
|
||||||
|
paiement.setMontant(new BigDecimal("80.00"));
|
||||||
|
paiement.setDatePaiement(LocalDate.now());
|
||||||
|
paiement.setModePaiement(modePaiement);
|
||||||
|
|
||||||
|
licence.addPaiement(paiement);
|
||||||
|
|
||||||
|
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
|
||||||
|
assertTrue(result);
|
||||||
|
assertEquals(new BigDecimal("120.00"), licence.getResteAPayer(), "Remaining amount should be 120.00 €");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSendPaiementConfirmation_SansEmail() {
|
||||||
|
Adherent adherent = new Adherent();
|
||||||
|
adherent.setNom("SANS");
|
||||||
|
adherent.setPrenom("Email");
|
||||||
|
adherent.setEmail(null);
|
||||||
|
|
||||||
|
Licence licence = new Licence();
|
||||||
|
licence.setAdherent(adherent);
|
||||||
|
|
||||||
|
Paiement paiement = new Paiement();
|
||||||
|
paiement.setLicence(licence);
|
||||||
|
|
||||||
|
boolean result = paiementEmailService.sendPaiementConfirmation(paiement);
|
||||||
|
assertFalse(result, "Should return false if adherent has no email");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSendPaiementConfirmation_WithJavaMailSender() {
|
||||||
|
org.springframework.mail.javamail.JavaMailSender mailSenderMock = mock(org.springframework.mail.javamail.JavaMailSender.class);
|
||||||
|
MimeMessage mimeMessage = new MimeMessage((jakarta.mail.Session) null);
|
||||||
|
|
||||||
|
when(mailSenderMock.createMimeMessage()).thenReturn(mimeMessage);
|
||||||
|
|
||||||
|
PaiementEmailService serviceWithMailSender = new PaiementEmailService(mailSenderMock, null);
|
||||||
|
|
||||||
|
Adherent adherent = new Adherent();
|
||||||
|
adherent.setNom("DURAND");
|
||||||
|
adherent.setPrenom("Paul");
|
||||||
|
adherent.setEmail("paul.durand@example.com");
|
||||||
|
|
||||||
|
Categorie categorie = new Categorie();
|
||||||
|
categorie.setNom("U11");
|
||||||
|
categorie.setTarifBase(new BigDecimal("100.00"));
|
||||||
|
categorie.setTarifExterieur(new BigDecimal("100.00"));
|
||||||
|
|
||||||
|
Saison saison = new Saison();
|
||||||
|
saison.setNom("2026/2027");
|
||||||
|
|
||||||
|
Licence licence = new Licence();
|
||||||
|
licence.setId(3L);
|
||||||
|
licence.setAdherent(adherent);
|
||||||
|
licence.setCategorie(categorie);
|
||||||
|
licence.setSaison(saison);
|
||||||
|
|
||||||
|
ModePaiement modePaiement = new ModePaiement();
|
||||||
|
modePaiement.setId(1L);
|
||||||
|
modePaiement.setNom("Chèque");
|
||||||
|
|
||||||
|
Paiement paiement = new Paiement();
|
||||||
|
paiement.setId(12L);
|
||||||
|
paiement.setLicence(licence);
|
||||||
|
paiement.setMontant(new BigDecimal("100.00"));
|
||||||
|
paiement.setDatePaiement(LocalDate.now());
|
||||||
|
paiement.setModePaiement(modePaiement);
|
||||||
|
paiement.setNumeroCheque("CHK-999");
|
||||||
|
|
||||||
|
licence.addPaiement(paiement);
|
||||||
|
|
||||||
|
boolean result = serviceWithMailSender.sendPaiementConfirmation(paiement);
|
||||||
|
|
||||||
|
assertTrue(result);
|
||||||
|
verify(mailSenderMock, timeout(2000).times(1)).send(any(MimeMessage.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,12 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = "com.astalange")
|
@SpringBootApplication(scanBasePackages = "com.astalange")
|
||||||
@EntityScan(basePackages = "com.astalange.core.entity")
|
@EntityScan(basePackages = "com.astalange.core.entity")
|
||||||
@EnableJpaRepositories(basePackages = "com.astalange.core.repository")
|
@EnableJpaRepositories(basePackages = "com.astalange.core.repository")
|
||||||
|
@EnableAsync
|
||||||
public class AsTalangeApplication {
|
public class AsTalangeApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AsTalangeApplication.class, args);
|
SpringApplication.run(AsTalangeApplication.class, args);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class DotationController {
|
|||||||
this.categorieRepository = categorieRepository;
|
this.categorieRepository = categorieRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Specification<Dotation> buildSpecification(Long equipementId, Long categorieId, Boolean fourni, Saison saisonActive) {
|
private Specification<Dotation> buildSpecification(Long equipementId, Long categorieId, Boolean fourni, Boolean commandee, Saison saisonActive) {
|
||||||
return (root, query, cb) -> {
|
return (root, query, cb) -> {
|
||||||
if (Long.class != query.getResultType() && long.class != query.getResultType()) {
|
if (Long.class != query.getResultType() && long.class != query.getResultType()) {
|
||||||
root.fetch("equipement", jakarta.persistence.criteria.JoinType.LEFT);
|
root.fetch("equipement", jakarta.persistence.criteria.JoinType.LEFT);
|
||||||
@@ -67,6 +67,9 @@ public class DotationController {
|
|||||||
if (fourni != null) {
|
if (fourni != null) {
|
||||||
predicates.add(cb.equal(root.get("fourni"), fourni));
|
predicates.add(cb.equal(root.get("fourni"), fourni));
|
||||||
}
|
}
|
||||||
|
if (commandee != null) {
|
||||||
|
predicates.add(cb.equal(root.get("commandee"), commandee));
|
||||||
|
}
|
||||||
return cb.and(predicates.toArray(new Predicate[0]));
|
return cb.and(predicates.toArray(new Predicate[0]));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -76,12 +79,13 @@ public class DotationController {
|
|||||||
@RequestParam(required = false) Long equipementId,
|
@RequestParam(required = false) Long equipementId,
|
||||||
@RequestParam(required = false) Long categorieId,
|
@RequestParam(required = false) Long categorieId,
|
||||||
@RequestParam(required = false) Boolean fourni,
|
@RequestParam(required = false) Boolean fourni,
|
||||||
|
@RequestParam(required = false) Boolean commandee,
|
||||||
@RequestParam(defaultValue = "0") int page,
|
@RequestParam(defaultValue = "0") int page,
|
||||||
@RequestParam(defaultValue = "20") int size,
|
@RequestParam(defaultValue = "20") int size,
|
||||||
Model model) {
|
Model model) {
|
||||||
|
|
||||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, saisonActive);
|
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, commandee, saisonActive);
|
||||||
List<Dotation> allDotations = dotationRepository.findAll(spec);
|
List<Dotation> allDotations = dotationRepository.findAll(spec);
|
||||||
|
|
||||||
int totalElements = allDotations.size();
|
int totalElements = allDotations.size();
|
||||||
@@ -99,6 +103,7 @@ public class DotationController {
|
|||||||
model.addAttribute("equipementId", equipementId);
|
model.addAttribute("equipementId", equipementId);
|
||||||
model.addAttribute("categorieId", categorieId);
|
model.addAttribute("categorieId", categorieId);
|
||||||
model.addAttribute("fourni", fourni);
|
model.addAttribute("fourni", fourni);
|
||||||
|
model.addAttribute("commandee", commandee);
|
||||||
|
|
||||||
model.addAttribute("currentPage", page);
|
model.addAttribute("currentPage", page);
|
||||||
model.addAttribute("totalPages", totalPages);
|
model.addAttribute("totalPages", totalPages);
|
||||||
@@ -112,10 +117,11 @@ public class DotationController {
|
|||||||
public ResponseEntity<byte[]> exportRechercheEquipements(
|
public ResponseEntity<byte[]> exportRechercheEquipements(
|
||||||
@RequestParam(required = false) Long equipementId,
|
@RequestParam(required = false) Long equipementId,
|
||||||
@RequestParam(required = false) Long categorieId,
|
@RequestParam(required = false) Long categorieId,
|
||||||
@RequestParam(required = false) Boolean fourni) {
|
@RequestParam(required = false) Boolean fourni,
|
||||||
|
@RequestParam(required = false) Boolean commandee) {
|
||||||
|
|
||||||
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
Saison saisonActive = saisonRepository.findByEstActiveTrue().orElse(null);
|
||||||
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, saisonActive);
|
Specification<Dotation> spec = buildSpecification(equipementId, categorieId, fourni, commandee, saisonActive);
|
||||||
List<Dotation> dotations = dotationRepository.findAll(spec);
|
List<Dotation> dotations = dotationRepository.findAll(spec);
|
||||||
|
|
||||||
String csvContent = dotationService.genererCsvSearchEquipement(dotations);
|
String csvContent = dotationService.genererCsvSearchEquipement(dotations);
|
||||||
@@ -137,7 +143,7 @@ public class DotationController {
|
|||||||
byte[] csvBytes = csvContent.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
byte[] csvBytes = csvContent.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentDispositionFormData("attachment", "commande_equipements_" + LocalDate.now() + ".csv");
|
headers.setContentDispositionFormData("attachment", "commande_equipements_regroupee_" + LocalDate.now() + ".csv");
|
||||||
headers.setContentType(MediaType.parseMediaType("text/csv; charset=UTF-8"));
|
headers.setContentType(MediaType.parseMediaType("text/csv; charset=UTF-8"));
|
||||||
|
|
||||||
return new ResponseEntity<>(csvBytes, headers, org.springframework.http.HttpStatus.OK);
|
return new ResponseEntity<>(csvBytes, headers, org.springframework.http.HttpStatus.OK);
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import com.astalange.core.repository.AuditLogPaiementRepository;
|
|||||||
import com.astalange.core.repository.LicenceRepository;
|
import com.astalange.core.repository.LicenceRepository;
|
||||||
import com.astalange.core.repository.ModePaiementRepository;
|
import com.astalange.core.repository.ModePaiementRepository;
|
||||||
import com.astalange.core.repository.PaiementRepository;
|
import com.astalange.core.repository.PaiementRepository;
|
||||||
|
import com.astalange.core.service.PaiementEmailService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -21,16 +24,24 @@ import java.time.LocalDate;
|
|||||||
@Controller
|
@Controller
|
||||||
public class PaiementController {
|
public class PaiementController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(PaiementController.class);
|
||||||
|
|
||||||
private final LicenceRepository licenceRepository;
|
private final LicenceRepository licenceRepository;
|
||||||
private final ModePaiementRepository modePaiementRepository;
|
private final ModePaiementRepository modePaiementRepository;
|
||||||
private final PaiementRepository paiementRepository;
|
private final PaiementRepository paiementRepository;
|
||||||
private final AuditLogPaiementRepository auditLogPaiementRepository;
|
private final AuditLogPaiementRepository auditLogPaiementRepository;
|
||||||
|
private final PaiementEmailService paiementEmailService;
|
||||||
|
|
||||||
public PaiementController(LicenceRepository licenceRepository, ModePaiementRepository modePaiementRepository, PaiementRepository paiementRepository, AuditLogPaiementRepository auditLogPaiementRepository) {
|
public PaiementController(LicenceRepository licenceRepository,
|
||||||
|
ModePaiementRepository modePaiementRepository,
|
||||||
|
PaiementRepository paiementRepository,
|
||||||
|
AuditLogPaiementRepository auditLogPaiementRepository,
|
||||||
|
PaiementEmailService paiementEmailService) {
|
||||||
this.licenceRepository = licenceRepository;
|
this.licenceRepository = licenceRepository;
|
||||||
this.modePaiementRepository = modePaiementRepository;
|
this.modePaiementRepository = modePaiementRepository;
|
||||||
this.paiementRepository = paiementRepository;
|
this.paiementRepository = paiementRepository;
|
||||||
this.auditLogPaiementRepository = auditLogPaiementRepository;
|
this.auditLogPaiementRepository = auditLogPaiementRepository;
|
||||||
|
this.paiementEmailService = paiementEmailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/licences/{id}/paiements")
|
@PostMapping("/licences/{id}/paiements")
|
||||||
@@ -49,6 +60,8 @@ public class PaiementController {
|
|||||||
ModePaiement mode = modePaiementRepository.findById(modePaiementId)
|
ModePaiement mode = modePaiementRepository.findById(modePaiementId)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Invalid ModePaiement ID"));
|
.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);
|
||||||
|
|
||||||
// Validation basique pour ne pas payer plus que le reste à payer
|
// Validation basique pour ne pas payer plus que le reste à payer
|
||||||
if (montant.compareTo(licence.getResteAPayer()) > 0) {
|
if (montant.compareTo(licence.getResteAPayer()) > 0) {
|
||||||
montant = licence.getResteAPayer();
|
montant = licence.getResteAPayer();
|
||||||
@@ -66,15 +79,24 @@ public class PaiementController {
|
|||||||
paiement.setGestionnaire(principal.getName());
|
paiement.setGestionnaire(principal.getName());
|
||||||
}
|
}
|
||||||
paiementRepository.save(paiement);
|
paiementRepository.save(paiement);
|
||||||
|
|
||||||
AuditLogPaiement log = new AuditLogPaiement();
|
licence.addPaiement(paiement);
|
||||||
log.setAction("CREATE");
|
|
||||||
log.setUtilisateur(principal != null ? principal.getName() : "Système");
|
AuditLogPaiement auditLog = new AuditLogPaiement();
|
||||||
log.setPaiementId(paiement.getId());
|
auditLog.setAction("CREATE");
|
||||||
log.setMontant(montant);
|
auditLog.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||||
log.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
auditLog.setPaiementId(paiement.getId());
|
||||||
log.setDetails("Création d'un paiement de " + montant + "€ via " + mode.getNom() + " pour la licence " + (licence.getNumeroLicence() != null ? licence.getNumeroLicence() : "sans numéro"));
|
auditLog.setMontant(montant);
|
||||||
auditLogPaiementRepository.save(log);
|
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"));
|
||||||
|
auditLogPaiementRepository.save(auditLog);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("Appel de sendPaiementConfirmation depuis addPaiement pour le paiement ID: {}", paiement.getId());
|
||||||
|
paiementEmailService.sendPaiementConfirmation(paiement);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Erreur lors de l'appel à sendPaiementConfirmation: ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "redirect:/adherents/" + adherentId + "/edit";
|
return "redirect:/adherents/" + adherentId + "/edit";
|
||||||
@@ -119,14 +141,14 @@ public class PaiementController {
|
|||||||
}
|
}
|
||||||
paiementRepository.save(paiement);
|
paiementRepository.save(paiement);
|
||||||
|
|
||||||
AuditLogPaiement log = new AuditLogPaiement();
|
AuditLogPaiement auditLog = new AuditLogPaiement();
|
||||||
log.setAction("UPDATE");
|
auditLog.setAction("UPDATE");
|
||||||
log.setUtilisateur(principal != null ? principal.getName() : "Système");
|
auditLog.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||||
log.setPaiementId(paiement.getId());
|
auditLog.setPaiementId(paiement.getId());
|
||||||
log.setMontant(montant);
|
auditLog.setMontant(montant);
|
||||||
log.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
auditLog.setAdherentNomComplet(licence.getAdherent().getNom() + " " + licence.getAdherent().getPrenom());
|
||||||
log.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom());
|
auditLog.setDetails("Modification du paiement: montant " + ancienMontant + "€ -> " + montant + "€, mode " + ancienMode + " -> " + mode.getNom());
|
||||||
auditLogPaiementRepository.save(log);
|
auditLogPaiementRepository.save(auditLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redirect != null && !redirect.isEmpty()) {
|
if (redirect != null && !redirect.isEmpty()) {
|
||||||
@@ -146,14 +168,14 @@ public class PaiementController {
|
|||||||
|
|
||||||
Long adherentId = paiement.getLicence().getAdherent().getId();
|
Long adherentId = paiement.getLicence().getAdherent().getId();
|
||||||
|
|
||||||
AuditLogPaiement log = new AuditLogPaiement();
|
AuditLogPaiement auditLog = new AuditLogPaiement();
|
||||||
log.setAction("DELETE");
|
auditLog.setAction("DELETE");
|
||||||
log.setUtilisateur(principal != null ? principal.getName() : "Système");
|
auditLog.setUtilisateur(principal != null ? principal.getName() : "Système");
|
||||||
log.setPaiementId(paiement.getId());
|
auditLog.setPaiementId(paiement.getId());
|
||||||
log.setMontant(paiement.getMontant());
|
auditLog.setMontant(paiement.getMontant());
|
||||||
log.setAdherentNomComplet(paiement.getLicence().getAdherent().getNom() + " " + paiement.getLicence().getAdherent().getPrenom());
|
auditLog.setAdherentNomComplet(paiement.getLicence().getAdherent().getNom() + " " + paiement.getLicence().getAdherent().getPrenom());
|
||||||
log.setDetails("Suppression du paiement de " + paiement.getMontant() + "€ via " + paiement.getModePaiement().getNom());
|
auditLog.setDetails("Suppression du paiement de " + paiement.getMontant() + "€ via " + paiement.getModePaiement().getNom());
|
||||||
auditLogPaiementRepository.save(log);
|
auditLogPaiementRepository.save(auditLog);
|
||||||
|
|
||||||
paiementRepository.delete(paiement);
|
paiementRepository.delete(paiement);
|
||||||
|
|
||||||
@@ -162,4 +184,27 @@ public class PaiementController {
|
|||||||
}
|
}
|
||||||
return "redirect:/adherents/" + adherentId + "/edit";
|
return "redirect:/adherents/" + adherentId + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/paiements/{id}/resend-email")
|
||||||
|
public String resendPaiementEmail(
|
||||||
|
@PathVariable Long id,
|
||||||
|
@RequestParam(required = false) String redirect) {
|
||||||
|
|
||||||
|
log.info(">>> [PaiementController] Demande de renvoi d'e-mail reçue pour le paiement ID: {}", id);
|
||||||
|
|
||||||
|
Paiement paiement = paiementRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException("Invalid Paiement ID"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("Appel de sendPaiementConfirmation depuis resendPaiementEmail pour le paiement ID: {}", id);
|
||||||
|
paiementEmailService.sendPaiementConfirmation(paiement);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Erreur lors du renvoi de l'e-mail pour le paiement ID {}: ", id, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redirect != null && !redirect.isEmpty()) {
|
||||||
|
return "redirect:" + redirect;
|
||||||
|
}
|
||||||
|
return "redirect:/adherents/" + paiement.getLicence().getAdherent().getId() + "/edit";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ spring:
|
|||||||
mail:
|
mail:
|
||||||
host: ${SPRING_MAIL_HOST:localhost}
|
host: ${SPRING_MAIL_HOST:localhost}
|
||||||
port: ${SPRING_MAIL_PORT:1025}
|
port: ${SPRING_MAIL_PORT:1025}
|
||||||
|
username: ${SPRING_MAIL_USERNAME:}
|
||||||
|
password: ${SPRING_MAIL_PASSWORD:}
|
||||||
properties:
|
properties:
|
||||||
mail:
|
mail:
|
||||||
smtp:
|
smtp:
|
||||||
auth: false
|
auth: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH:false}
|
||||||
starttls:
|
starttls:
|
||||||
enable: false
|
enable: ${SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE:false}
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8080
|
port: 8080
|
||||||
@@ -35,3 +37,8 @@ app:
|
|||||||
|
|
||||||
sporteasy:
|
sporteasy:
|
||||||
base-url: https://www.sporteasy.net/join/
|
base-url: https://www.sporteasy.net/join/
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.astalange: DEBUG
|
||||||
|
|
||||||
|
|||||||
@@ -327,6 +327,14 @@
|
|||||||
<td class="py-2 px-3 text-right font-semibold text-green-600" th:text="${paiement.montant + ' €'}">50.00 €</td>
|
<td class="py-2 px-3 text-right font-semibold text-green-600" th:text="${paiement.montant + ' €'}">50.00 €</td>
|
||||||
<td class="py-2 px-3 text-right pr-4">
|
<td class="py-2 px-3 text-right pr-4">
|
||||||
<div class="flex justify-end items-center space-x-2">
|
<div class="flex justify-end items-center space-x-2">
|
||||||
|
<form th:action="@{/paiements/{id}/resend-email(id=${paiement.id})}" method="post" class="inline m-0" onsubmit="return confirm('Renvoyer l\'e-mail de reçu de paiement à l\'adhérent ?');">
|
||||||
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
|
||||||
|
<button type="submit" class="text-emerald-600 hover:text-emerald-900 bg-emerald-50 hover:bg-emerald-100 p-1.5 rounded transition-colors inline-flex items-center" title="Renvoyer le reçu par e-mail">
|
||||||
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
th:data-paiement-id="${paiement.id}"
|
th:data-paiement-id="${paiement.id}"
|
||||||
th:data-montant="${paiement.montant}"
|
th:data-montant="${paiement.montant}"
|
||||||
|
|||||||
@@ -93,6 +93,15 @@
|
|||||||
<td class="py-4 px-6 text-right font-semibold text-green-600" th:text="${p.montant + ' €'}">50.00 €</td>
|
<td class="py-4 px-6 text-right font-semibold text-green-600" th:text="${p.montant + ' €'}">50.00 €</td>
|
||||||
<td class="py-4 px-6 text-right pr-6">
|
<td class="py-4 px-6 text-right pr-6">
|
||||||
<div class="flex justify-end items-center space-x-2">
|
<div class="flex justify-end items-center space-x-2">
|
||||||
|
<form th:action="@{/paiements/{id}/resend-email(id=${p.id})}" method="post" class="inline m-0" onsubmit="return confirm('Renvoyer l\'e-mail de reçu de paiement à l\'adhérent ?');">
|
||||||
|
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
|
||||||
|
<input type="hidden" name="redirect" value="/paiements" />
|
||||||
|
<button type="submit" class="text-emerald-600 hover:text-emerald-900 bg-emerald-50 hover:bg-emerald-100 p-1.5 rounded transition-colors inline-flex items-center" title="Renvoyer le reçu par e-mail">
|
||||||
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
<button type="button"
|
<button type="button"
|
||||||
th:data-paiement-id="${p.id}"
|
th:data-paiement-id="${p.id}"
|
||||||
th:data-montant="${p.montant}"
|
th:data-montant="${p.montant}"
|
||||||
|
|||||||
@@ -65,10 +65,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="sportEasyToken" class="block text-sm font-medium text-gray-700 mb-1">Token ou Lien d'invitation SportEasy</label>
|
<label for="sportEasyToken" class="block text-sm font-medium text-gray-700 mb-1">Lien d'invitation SportEasy de la catégorie</label>
|
||||||
<input type="text" id="sportEasyToken" th:field="*{sportEasyToken}" placeholder="ex: https://www.sporteasy.net/join/ABC1234 ou juste ABC1234"
|
<input type="text" id="sportEasyToken" th:field="*{sportEasyToken}" placeholder="ex: https://www.sporteasy.net/join/XXXXXX"
|
||||||
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors">
|
||||||
<p class="text-xs text-gray-500 mt-1">Saisissez le token du groupe SportEasy ou l'URL complète d'invitation.</p>
|
<p class="text-xs text-gray-500 mt-1">Saisissez le lien direct d'invitation SportEasy spécifique à cette catégorie.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pt-4 border-t border-gray-100">
|
<div class="pt-4 border-t border-gray-100">
|
||||||
|
|||||||
+36
-11
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<div class="bg-white p-6 rounded-lg border border-gray-200 shadow-sm mb-6">
|
<div class="bg-white p-6 rounded-lg border border-gray-200 shadow-sm mb-6">
|
||||||
<form th:action="@{/admin/equipements/recherche}" method="get" class="space-y-4">
|
<form th:action="@{/admin/equipements/recherche}" method="get" class="space-y-4">
|
||||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-1">Équipement</label>
|
<label class="block text-sm font-medium text-gray-700 mb-1">Équipement</label>
|
||||||
<select name="equipementId" class="w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm px-3 py-2 border">
|
<select name="equipementId" class="w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm px-3 py-2 border">
|
||||||
@@ -44,10 +44,28 @@
|
|||||||
<option value="false" th:selected="${fourni != null && !fourni}">Non</option>
|
<option value="false" th:selected="${fourni != null && !fourni}">Non</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 mb-1">Commandé</label>
|
||||||
|
<select name="commandee" class="w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm px-3 py-2 border">
|
||||||
|
<option value="">Tous</option>
|
||||||
|
<option value="false" th:selected="${commandee != null && !commandee}">Non commandé</option>
|
||||||
|
<option value="true" th:selected="${commandee != null && commandee}">Commandé</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-end space-x-3">
|
<div class="flex justify-between items-center pt-2">
|
||||||
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700">Rechercher</button>
|
<a th:href="@{/admin/equipements/export-commande}"
|
||||||
<a th:href="@{/admin/equipements/recherche/export(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni})}" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700">Exporter</a>
|
onclick="return confirm('Exporter les équipements non encore commandés et les marquer comme commandés ?');"
|
||||||
|
class="bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-indigo-700 flex items-center space-x-1 shadow-sm">
|
||||||
|
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
|
||||||
|
</svg>
|
||||||
|
Exporter Commande Équipementier (Regroupé)
|
||||||
|
</a>
|
||||||
|
<div class="flex space-x-3">
|
||||||
|
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-blue-700">Rechercher</button>
|
||||||
|
<a th:href="@{/admin/equipements/recherche/export(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee})}" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700">Exporter Recherche</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -62,12 +80,13 @@
|
|||||||
<th class="py-3 px-4 font-medium text-left">Équipement</th>
|
<th class="py-3 px-4 font-medium text-left">Équipement</th>
|
||||||
<th class="py-3 px-4 font-medium text-left">Référence</th>
|
<th class="py-3 px-4 font-medium text-left">Référence</th>
|
||||||
<th class="py-3 px-4 font-medium text-left">Taille / Floc.</th>
|
<th class="py-3 px-4 font-medium text-left">Taille / Floc.</th>
|
||||||
|
<th class="py-3 px-4 font-medium text-center">Commandé</th>
|
||||||
<th class="py-3 px-4 font-medium text-center">Fourni</th>
|
<th class="py-3 px-4 font-medium text-center">Fourni</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-gray-200 text-sm">
|
<tbody class="divide-y divide-gray-200 text-sm">
|
||||||
<tr th:if="${#lists.isEmpty(dotations)}">
|
<tr th:if="${#lists.isEmpty(dotations)}">
|
||||||
<td colspan="7" class="py-8 text-center text-gray-500">Aucun résultat trouvé pour cette recherche.</td>
|
<td colspan="8" class="py-8 text-center text-gray-500">Aucun résultat trouvé pour cette recherche.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr th:each="dotation : ${dotations}" class="hover:bg-gray-50">
|
<tr th:each="dotation : ${dotations}" class="hover:bg-gray-50">
|
||||||
<td class="py-3 px-4 font-medium text-gray-900">
|
<td class="py-3 px-4 font-medium text-gray-900">
|
||||||
@@ -85,6 +104,12 @@
|
|||||||
<div th:if="${dotation.flocage != null && !dotation.flocage.isEmpty()}" th:text="'F: ' + ${dotation.flocage}">Flocage</div>
|
<div th:if="${dotation.flocage != null && !dotation.flocage.isEmpty()}" th:text="'F: ' + ${dotation.flocage}">Flocage</div>
|
||||||
<div th:if="${dotation.numero != null && !dotation.numero.isEmpty()}" th:text="'N: ' + ${dotation.numero}">N°</div>
|
<div th:if="${dotation.numero != null && !dotation.numero.isEmpty()}" th:text="'N: ' + ${dotation.numero}">N°</div>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="py-3 px-4 text-center">
|
||||||
|
<span th:if="${dotation.commandee}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800" th:title="${dotation.dateCommande != null ? #temporals.format(dotation.dateCommande, 'dd/MM/yyyy HH:mm') : ''}">
|
||||||
|
Oui <span th:if="${dotation.dateCommande != null}" class="ml-1 text-[10px] text-blue-600" th:text="'(' + ${#temporals.format(dotation.dateCommande, 'dd/MM')} + ')'"></span>
|
||||||
|
</span>
|
||||||
|
<span th:unless="${dotation.commandee}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-600">Non</span>
|
||||||
|
</td>
|
||||||
<td class="py-3 px-4 text-center">
|
<td class="py-3 px-4 text-center">
|
||||||
<span th:if="${dotation.fourni}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">Oui</span>
|
<span th:if="${dotation.fourni}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">Oui</span>
|
||||||
<span th:unless="${dotation.fourni}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800">Non</span>
|
<span th:unless="${dotation.fourni}" class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800">Non</span>
|
||||||
@@ -106,12 +131,12 @@
|
|||||||
<div class="flex items-center space-x-2" th:if="${totalPages > 1}">
|
<div class="flex items-center space-x-2" th:if="${totalPages > 1}">
|
||||||
<!-- Page Précédente -->
|
<!-- Page Précédente -->
|
||||||
<a th:if="${currentPage > 0}"
|
<a th:if="${currentPage > 0}"
|
||||||
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},page=${currentPage - 1})}"
|
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee},page=${currentPage - 1})}"
|
||||||
hx-get="/admin/equipements/recherche"
|
hx-get="/admin/equipements/recherche"
|
||||||
hx-target="#equipements-table-container"
|
hx-target="#equipements-table-container"
|
||||||
hx-select="#equipements-table-container"
|
hx-select="#equipements-table-container"
|
||||||
hx-push-url="true"
|
hx-push-url="true"
|
||||||
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "page": ${currentPage - 1}}|"
|
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "commandee": "${commandee != null ? commandee : ''}", "page": ${currentPage - 1}}|"
|
||||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
Précédent
|
Précédent
|
||||||
</a>
|
</a>
|
||||||
@@ -121,12 +146,12 @@
|
|||||||
|
|
||||||
<!-- Numéros de pages -->
|
<!-- Numéros de pages -->
|
||||||
<th:block th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}" th:if="${totalPages > 0}">
|
<th:block th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}" th:if="${totalPages > 0}">
|
||||||
<a th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},page=${pageNum})}"
|
<a th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee},page=${pageNum})}"
|
||||||
hx-get="/admin/equipements/recherche"
|
hx-get="/admin/equipements/recherche"
|
||||||
hx-target="#equipements-table-container"
|
hx-target="#equipements-table-container"
|
||||||
hx-select="#equipements-table-container"
|
hx-select="#equipements-table-container"
|
||||||
hx-push-url="true"
|
hx-push-url="true"
|
||||||
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "page": ${pageNum}}|"
|
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "commandee": "${commandee != null ? commandee : ''}", "page": ${pageNum}}|"
|
||||||
th:text="${pageNum + 1}"
|
th:text="${pageNum + 1}"
|
||||||
class="px-3 py-1 rounded transition-colors"
|
class="px-3 py-1 rounded transition-colors"
|
||||||
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
th:classappend="${currentPage == pageNum ? 'bg-blue-600 text-white' : 'border border-gray-300 hover:bg-gray-100'}">
|
||||||
@@ -136,12 +161,12 @@
|
|||||||
|
|
||||||
<!-- Page Suivante -->
|
<!-- Page Suivante -->
|
||||||
<a th:if="${currentPage < totalPages - 1}"
|
<a th:if="${currentPage < totalPages - 1}"
|
||||||
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},page=${currentPage + 1})}"
|
th:href="@{/admin/equipements/recherche(equipementId=${equipementId},categorieId=${categorieId},fourni=${fourni},commandee=${commandee},page=${currentPage + 1})}"
|
||||||
hx-get="/admin/equipements/recherche"
|
hx-get="/admin/equipements/recherche"
|
||||||
hx-target="#equipements-table-container"
|
hx-target="#equipements-table-container"
|
||||||
hx-select="#equipements-table-container"
|
hx-select="#equipements-table-container"
|
||||||
hx-push-url="true"
|
hx-push-url="true"
|
||||||
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "page": ${currentPage + 1}}|"
|
th:attr="hx-vals=|{"equipementId": "${equipementId != null ? equipementId : ''}", "categorieId": "${categorieId != null ? categorieId : ''}", "fourni": "${fourni != null ? fourni : ''}", "commandee": "${commandee != null ? commandee : ''}", "page": ${currentPage + 1}}|"
|
||||||
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
class="px-3 py-1 border border-gray-300 rounded hover:bg-gray-100 transition-colors">
|
||||||
Suivant
|
Suivant
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
+6
-2
@@ -43,8 +43,12 @@ services:
|
|||||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/astalange
|
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/astalange
|
||||||
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-myuser}
|
- SPRING_DATASOURCE_USERNAME=${POSTGRES_USER:-myuser}
|
||||||
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-mypassword}
|
- SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD:-mypassword}
|
||||||
- SPRING_MAIL_HOST=mailpit
|
- SPRING_MAIL_HOST=${SPRING_MAIL_HOST:-mailpit}
|
||||||
- SPRING_MAIL_PORT=1025
|
- SPRING_MAIL_PORT=${SPRING_MAIL_PORT:-1025}
|
||||||
|
- SPRING_MAIL_USERNAME=${SPRING_MAIL_USERNAME:-}
|
||||||
|
- SPRING_MAIL_PASSWORD=${SPRING_MAIL_PASSWORD:-}
|
||||||
|
- SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=${SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH:-false}
|
||||||
|
- SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=${SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE:-false}
|
||||||
- CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-}
|
- CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-}
|
||||||
- CAPTCHA_SECRET=${CAPTCHA_SECRET:-}
|
- CAPTCHA_SECRET=${CAPTCHA_SECRET:-}
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user