From d7b62ddf15fe1a11fe5b5aa57e967254ecbe8b6e Mon Sep 17 00:00:00 2001 From: Youssef Date: Fri, 17 Jul 2026 23:55:44 +0200 Subject: [PATCH] feat: map adherent size and shoe size to dotations --- .../core/service/CategorieService.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/as-talange-core/src/main/java/com/astalange/core/service/CategorieService.java b/as-talange-core/src/main/java/com/astalange/core/service/CategorieService.java index 2f91684..454b8ac 100644 --- a/as-talange-core/src/main/java/com/astalange/core/service/CategorieService.java +++ b/as-talange-core/src/main/java/com/astalange/core/service/CategorieService.java @@ -123,6 +123,26 @@ public class CategorieService { continue; } + String matchedTaille = ""; + if (licence.getAdherent() != null) { + String taillesDispo = ce.getEquipement().getTaillesDisponibles(); + if (taillesDispo != null && !taillesDispo.trim().isEmpty()) { + String[] dispos = taillesDispo.split(","); + String tv = licence.getAdherent().getTailleVetement(); + String pt = licence.getAdherent().getPointure(); + for (String t : dispos) { + String trimmed = t.trim(); + if (tv != null && !tv.trim().isEmpty() && trimmed.equalsIgnoreCase(tv.trim())) { + matchedTaille = tv.trim(); + break; + } else if (pt != null && !pt.trim().isEmpty() && trimmed.equalsIgnoreCase(pt.trim())) { + matchedTaille = pt.trim(); + break; + } + } + } + } + boolean found = false; for (Dotation d : currentDotations) { if (ce.getEquipement().getId().equals(d.getEquipement().getId())) { @@ -130,6 +150,9 @@ public class CategorieService { if (Boolean.TRUE.equals(ce.getObligatoire()) && !Boolean.TRUE.equals(d.getChoisi())) { d.setChoisi(true); } + if ((d.getTaille() == null || d.getTaille().trim().isEmpty()) && !matchedTaille.isEmpty()) { + d.setTaille(matchedTaille); + } break; } } @@ -146,7 +169,7 @@ public class CategorieService { } newDotation.setChoisi(ce.getObligatoire() || (isMaillot && isNouvelle)); // Checked if obligatoire or if it's a new registration newDotation.setFourni(false); - newDotation.setTaille(""); + newDotation.setTaille(matchedTaille); newDotation.setNumero(""); if (licence.getAdherent() != null) { String defaultFlocage = "";