feat: gestion type de demande, calcul dynamique du tarif et pre-selection equipement (maillot) pour inscription
This commit is contained in:
@@ -41,6 +41,12 @@ public class Adherent {
|
||||
@Column(name = "representant_legal", length = 150)
|
||||
private String representantLegal;
|
||||
|
||||
@Column(name = "type_demande", length = 50)
|
||||
private String typeDemande;
|
||||
|
||||
@Column(name = "ancien_club", length = 150)
|
||||
private String ancienClub;
|
||||
|
||||
private boolean residentTalange = true;
|
||||
|
||||
@Column(nullable = false, length = 10)
|
||||
@@ -87,6 +93,12 @@ public class Adherent {
|
||||
public String getRepresentantLegal() { return representantLegal; }
|
||||
public void setRepresentantLegal(String representantLegal) { this.representantLegal = representantLegal; }
|
||||
|
||||
public String getTypeDemande() { return typeDemande; }
|
||||
public void setTypeDemande(String typeDemande) { this.typeDemande = typeDemande; }
|
||||
|
||||
public String getAncienClub() { return ancienClub; }
|
||||
public void setAncienClub(String ancienClub) { this.ancienClub = ancienClub; }
|
||||
|
||||
public boolean isResidentTalange() { return residentTalange; }
|
||||
public void setResidentTalange(boolean residentTalange) { this.residentTalange = residentTalange; }
|
||||
|
||||
|
||||
@@ -84,4 +84,33 @@ public class Categorie {
|
||||
.map(CategorieEquipement::getPrix)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public BigDecimal getEquipementPrixByNom(String nom) {
|
||||
if (categorieEquipements == null || nom == null) return BigDecimal.ZERO;
|
||||
return categorieEquipements.stream()
|
||||
.filter(ce -> ce.getEquipement() != null && nom.equalsIgnoreCase(ce.getEquipement().getNom()))
|
||||
.findFirst()
|
||||
.map(CategorieEquipement::getPrix)
|
||||
.map(p -> p == null ? BigDecimal.ZERO : p)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public boolean isU11OrBelow() {
|
||||
if (nom == null) return false;
|
||||
String nomCat = nom.trim().toUpperCase();
|
||||
if (nomCat.startsWith("U")) {
|
||||
java.util.regex.Matcher m = java.util.regex.Pattern.compile("^U(\\d+)").matcher(nomCat);
|
||||
if (m.find()) {
|
||||
try {
|
||||
int age = Integer.parseInt(m.group(1));
|
||||
return age <= 11;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,12 @@ public class PreInscription {
|
||||
@Column(name = "consentement_rgpd", nullable = false)
|
||||
private Boolean consentementRgpd = false;
|
||||
|
||||
@Column(name = "type_demande", nullable = false, length = 50)
|
||||
private String typeDemande = "NOUVELLE";
|
||||
|
||||
@Column(name = "ancien_club", length = 150)
|
||||
private String ancienClub;
|
||||
|
||||
// Getters and Setters
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
@@ -94,4 +100,10 @@ public class PreInscription {
|
||||
|
||||
public Boolean getConsentementRgpd() { return consentementRgpd; }
|
||||
public void setConsentementRgpd(Boolean consentementRgpd) { this.consentementRgpd = consentementRgpd; }
|
||||
|
||||
public String getTypeDemande() { return typeDemande; }
|
||||
public void setTypeDemande(String typeDemande) { this.typeDemande = typeDemande; }
|
||||
|
||||
public String getAncienClub() { return ancienClub; }
|
||||
public void setAncienClub(String ancienClub) { this.ancienClub = ancienClub; }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,13 @@ import org.springframework.stereotype.Repository;
|
||||
import com.astalange.core.entity.Saison;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
@Repository
|
||||
public interface CategorieRepository extends JpaRepository<Categorie, Long> {
|
||||
List<Categorie> findBySaison(Saison saison);
|
||||
|
||||
@Query("SELECT c FROM Categorie c WHERE c.saison = :saison AND :annee BETWEEN c.anneeMin AND c.anneeMax")
|
||||
List<Categorie> findBySaisonAndAnnee(@Param("saison") Saison saison, @Param("annee") Integer annee);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,21 @@ public class CategorieService {
|
||||
Dotation newDotation = new Dotation();
|
||||
newDotation.setLicence(licence);
|
||||
newDotation.setEquipement(ce.getEquipement());
|
||||
newDotation.setChoisi(ce.getObligatoire()); // By default checked if obligatoire
|
||||
boolean isMaillot = "Maillot".equalsIgnoreCase(ce.getEquipement().getNom());
|
||||
boolean isNouvelleAndU11 = false;
|
||||
if (licence.getTypeDemande() != null &&
|
||||
(licence.getTypeDemande().equalsIgnoreCase("Nouvelle demande") || licence.getTypeDemande().equalsIgnoreCase("NOUVELLE")) &&
|
||||
licence.getCategorie() != null &&
|
||||
licence.getCategorie().isU11OrBelow()) {
|
||||
isNouvelleAndU11 = true;
|
||||
}
|
||||
newDotation.setChoisi(ce.getObligatoire() || (isMaillot && isNouvelleAndU11)); // Checked if obligatoire or if it's a new registration for U11 or below
|
||||
newDotation.setFourni(false);
|
||||
newDotation.setTaille("");
|
||||
newDotation.setNumero("");
|
||||
if (licence.getAdherent() != null) {
|
||||
newDotation.setFlocage(licence.getAdherent().getNom().toUpperCase() + " " + licence.getAdherent().getPrenom());
|
||||
}
|
||||
currentDotations.add(newDotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public class PreInscriptionService {
|
||||
adherent.setEmail(pre.getEmail());
|
||||
adherent.setTelephone(pre.getTelephone());
|
||||
adherent.setRepresentantLegal(pre.getRepresentantLegal());
|
||||
adherent.setTypeDemande(pre.getTypeDemande());
|
||||
adherent.setAncienClub(pre.getAncienClub());
|
||||
// Par défaut
|
||||
adherent.setSexe("MASCULIN");
|
||||
adherent.setTypeMaillot("JOUEUR");
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE pre_inscription
|
||||
ADD COLUMN type_demande VARCHAR(50) DEFAULT 'NOUVELLE' NOT NULL,
|
||||
ADD COLUMN ancien_club VARCHAR(150);
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE adherent
|
||||
ADD COLUMN type_demande VARCHAR(50),
|
||||
ADD COLUMN ancien_club VARCHAR(150);
|
||||
Reference in New Issue
Block a user