Refactor: Move equipment price and mandatory status to Categorie relationship
- Created CategorieEquipement entity to act as a join table between Category and Equipment. - Moved 'obligatoire' and 'prix' (formerly prixContribution) fields from Equipement to the new CategorieEquipement entity. - Added Flyway migrations V14 and V15 to update the database schema and migrate existing data. - Updated Categorie UI to use a select dropdown and price input for managing category-specific equipment configurations. - Replaced 'equipement.obligatoire' and 'equipement.prixContribution' calls with their new category-level equivalents in logic and templates. - Updated pricing calculation in Licence entity to source prices dynamically from the Categorie configuration. - Updated Dotation generation logic to sync with category requirements automatically.
This commit is contained in:
@@ -6,10 +6,12 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@Transactional
|
||||
public class LicenceController {
|
||||
|
||||
private final AdherentRepository adherentRepository;
|
||||
@@ -73,18 +75,20 @@ public class LicenceController {
|
||||
|
||||
licence = licenceRepository.save(licence);
|
||||
|
||||
// Auto-initialize dotations for all configured equipments of the active season
|
||||
List<Equipement> equipements = equipementRepository.findBySaison(saisonActive);
|
||||
for (Equipement eq : equipements) {
|
||||
Dotation dotation = new Dotation();
|
||||
dotation.setLicence(licence);
|
||||
dotation.setEquipement(eq);
|
||||
dotation.setTaille("");
|
||||
dotation.setFlocage(adherent.getNom().toUpperCase() + " " + adherent.getPrenom());
|
||||
dotation.setNumero("");
|
||||
dotation.setFourni(false);
|
||||
dotation.setChoisi(eq.getObligatoire());
|
||||
dotationRepository.save(dotation);
|
||||
// Auto-initialize dotations for all configured equipments of the category
|
||||
List<CategorieEquipement> catEquipements = categorie.getCategorieEquipements();
|
||||
if (catEquipements != null) {
|
||||
for (CategorieEquipement ce : catEquipements) {
|
||||
Dotation dotation = new Dotation();
|
||||
dotation.setLicence(licence);
|
||||
dotation.setEquipement(ce.getEquipement());
|
||||
dotation.setTaille("");
|
||||
dotation.setFlocage(adherent.getNom().toUpperCase() + " " + adherent.getPrenom());
|
||||
dotation.setNumero("");
|
||||
dotation.setFourni(false);
|
||||
dotation.setChoisi(Boolean.TRUE.equals(ce.getObligatoire()));
|
||||
dotationRepository.save(dotation);
|
||||
}
|
||||
}
|
||||
|
||||
return "redirect:/adherents/" + id + "/edit";
|
||||
|
||||
Reference in New Issue
Block a user