diff --git a/as-talange-core/src/main/java/com/astalange/core/entity/Dotation.java b/as-talange-core/src/main/java/com/astalange/core/entity/Dotation.java index 5e3de4e..5a84762 100644 --- a/as-talange-core/src/main/java/com/astalange/core/entity/Dotation.java +++ b/as-talange-core/src/main/java/com/astalange/core/entity/Dotation.java @@ -42,11 +42,17 @@ public class Dotation { @Column(name = "date_commande") private java.time.LocalDateTime dateCommande; - @Column(name = "flocage_exporte", nullable = false) - private Boolean flocageExporte = false; + @Column(name = "flocage_initiales_exporte", nullable = false) + private Boolean flocageInitialesExporte = false; - @Column(name = "date_flocage") - private java.time.LocalDateTime dateFlocage; + @Column(name = "date_flocage_initiales") + private java.time.LocalDateTime dateFlocageInitiales; + + @Column(name = "flocage_prenom_numero_exporte", nullable = false) + private Boolean flocagePrenomNumeroExporte = false; + + @Column(name = "date_flocage_prenom_numero") + private java.time.LocalDateTime dateFlocagePrenomNumero; // Getters and Setters @@ -83,11 +89,18 @@ public class Dotation { public java.time.LocalDateTime getDateCommande() { return dateCommande; } public void setDateCommande(java.time.LocalDateTime dateCommande) { this.dateCommande = dateCommande; } - public Boolean getFlocageExporte() { return flocageExporte; } - public void setFlocageExporte(Boolean flocageExporte) { this.flocageExporte = flocageExporte; } + public Boolean getFlocageInitialesExporte() { return flocageInitialesExporte; } + public void setFlocageInitialesExporte(Boolean flocageInitialesExporte) { this.flocageInitialesExporte = flocageInitialesExporte; } + + public java.time.LocalDateTime getDateFlocageInitiales() { return dateFlocageInitiales; } + public void setDateFlocageInitiales(java.time.LocalDateTime dateFlocageInitiales) { this.dateFlocageInitiales = dateFlocageInitiales; } + + public Boolean getFlocagePrenomNumeroExporte() { return flocagePrenomNumeroExporte; } + public void setFlocagePrenomNumeroExporte(Boolean flocagePrenomNumeroExporte) { this.flocagePrenomNumeroExporte = flocagePrenomNumeroExporte; } + + public java.time.LocalDateTime getDateFlocagePrenomNumero() { return dateFlocagePrenomNumero; } + public void setDateFlocagePrenomNumero(java.time.LocalDateTime dateFlocagePrenomNumero) { this.dateFlocagePrenomNumero = dateFlocagePrenomNumero; } - public java.time.LocalDateTime getDateFlocage() { return dateFlocage; } - public void setDateFlocage(java.time.LocalDateTime dateFlocage) { this.dateFlocage = dateFlocage; } public static boolean isSizeMatch(String option, String adherentSize) { diff --git a/as-talange-core/src/main/java/com/astalange/core/repository/DotationRepository.java b/as-talange-core/src/main/java/com/astalange/core/repository/DotationRepository.java index 5496705..79b8b54 100644 --- a/as-talange-core/src/main/java/com/astalange/core/repository/DotationRepository.java +++ b/as-talange-core/src/main/java/com/astalange/core/repository/DotationRepository.java @@ -12,6 +12,8 @@ import com.astalange.core.entity.Saison; public interface DotationRepository extends JpaRepository, JpaSpecificationExecutor { List findByLicence_SaisonAndChoisiTrueAndFourniFalse(Saison saison); List findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(Saison saison); - List findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(Saison saison); + List findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageInitialesExporteFalse(Saison saison); + List findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocagePrenomNumeroExporteFalse(Saison saison); } + diff --git a/as-talange-core/src/main/java/com/astalange/core/service/DotationService.java b/as-talange-core/src/main/java/com/astalange/core/service/DotationService.java index 1ee236a..a0d8f21 100644 --- a/as-talange-core/src/main/java/com/astalange/core/service/DotationService.java +++ b/as-talange-core/src/main/java/com/astalange/core/service/DotationService.java @@ -118,7 +118,7 @@ public class DotationService { @Transactional public String genererCsvFlocageInitiales(Saison saisonActive) { - List dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive); + List dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageInitialesExporteFalse(saisonActive); LocalDateTime now = LocalDateTime.now(); String dateExportFormatted = now.format(DATE_FORMATTER); @@ -153,8 +153,8 @@ public class DotationService { .append(escapeCsv(initiales)).append(";") .append(escapeCsv(dateExportFormatted)).append("\n"); - d.setFlocageExporte(true); - d.setDateFlocage(now); + d.setFlocageInitialesExporte(true); + d.setDateFlocageInitiales(now); dotationRepository.save(d); } @@ -163,7 +163,7 @@ public class DotationService { @Transactional public String genererCsvFlocagePrenomNumero(Saison saisonActive) { - List dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive); + List dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocagePrenomNumeroExporteFalse(saisonActive); LocalDateTime now = LocalDateTime.now(); String dateExportFormatted = now.format(DATE_FORMATTER); @@ -208,14 +208,15 @@ public class DotationService { .append(escapeCsv(numero)).append(";") .append(escapeCsv(dateExportFormatted)).append("\n"); - d.setFlocageExporte(true); - d.setDateFlocage(now); + d.setFlocagePrenomNumeroExporte(true); + d.setDateFlocagePrenomNumero(now); dotationRepository.save(d); } return sb.toString(); } + private String escapeCsv(String value) { if (value == null) { return ""; diff --git a/as-talange-core/src/main/resources/db/migration/V44__add_flocage_export_fields_to_dotation.sql b/as-talange-core/src/main/resources/db/migration/V44__add_flocage_export_fields_to_dotation.sql index d5ad5a8..9e422af 100644 --- a/as-talange-core/src/main/resources/db/migration/V44__add_flocage_export_fields_to_dotation.sql +++ b/as-talange-core/src/main/resources/db/migration/V44__add_flocage_export_fields_to_dotation.sql @@ -1,2 +1,4 @@ -ALTER TABLE dotation ADD COLUMN flocage_exporte BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE dotation ADD COLUMN date_flocage TIMESTAMP NULL; +ALTER TABLE dotation ADD COLUMN flocage_initiales_exporte BOOLEAN NOT NULL DEFAULT FALSE; +ALTER TABLE dotation ADD COLUMN date_flocage_initiales TIMESTAMP NULL; +ALTER TABLE dotation ADD COLUMN flocage_prenom_numero_exporte BOOLEAN NOT NULL DEFAULT FALSE; +ALTER TABLE dotation ADD COLUMN date_flocage_prenom_numero TIMESTAMP NULL; diff --git a/as-talange-core/src/test/java/com/astalange/core/service/DotationServiceTest.java b/as-talange-core/src/test/java/com/astalange/core/service/DotationServiceTest.java index 8a2d0b8..0515c74 100644 --- a/as-talange-core/src/test/java/com/astalange/core/service/DotationServiceTest.java +++ b/as-talange-core/src/test/java/com/astalange/core/service/DotationServiceTest.java @@ -70,9 +70,9 @@ public class DotationServiceTest { d1.setFlocage("JD"); d1.setChoisi(true); d1.setCommandee(true); - d1.setFlocageExporte(false); + d1.setFlocageInitialesExporte(false); - when(dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saison)) + when(dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageInitialesExporteFalse(saison)) .thenReturn(List.of(d1)); String csv = dotationService.genererCsvFlocageInitiales(saison); @@ -81,8 +81,8 @@ public class DotationServiceTest { assertTrue(csv.contains("JD")); assertTrue(csv.contains("Veste de sortie")); assertTrue(csv.contains("Dupont")); - assertTrue(d1.getFlocageExporte()); - assertNotNull(d1.getDateFlocage()); + assertTrue(d1.getFlocageInitialesExporte()); + assertNotNull(d1.getDateFlocageInitiales()); verify(dotationRepository, times(1)).save(d1); } @@ -105,9 +105,9 @@ public class DotationServiceTest { d2.setNumero("10"); d2.setChoisi(true); d2.setCommandee(true); - d2.setFlocageExporte(false); + d2.setFlocagePrenomNumeroExporte(false); - when(dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saison)) + when(dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocagePrenomNumeroExporteFalse(saison)) .thenReturn(List.of(d2)); String csv = dotationService.genererCsvFlocagePrenomNumero(saison); @@ -116,8 +116,9 @@ public class DotationServiceTest { assertTrue(csv.contains("JEAN")); assertTrue(csv.contains("10")); assertTrue(csv.contains("Maillot de match")); - assertTrue(d2.getFlocageExporte()); - assertNotNull(d2.getDateFlocage()); + assertTrue(d2.getFlocagePrenomNumeroExporte()); + assertNotNull(d2.getDateFlocagePrenomNumero()); verify(dotationRepository, times(1)).save(d2); } + }