refactor: separer les champs d export flocage en DB entre initiales et prenom/numero
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.astalange.core.entity.Saison;
|
||||
public interface DotationRepository extends JpaRepository<Dotation, Long>, JpaSpecificationExecutor<Dotation> {
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndFourniFalse(Saison saison);
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(Saison saison);
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(Saison saison);
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageInitialesExporteFalse(Saison saison);
|
||||
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocagePrenomNumeroExporteFalse(Saison saison);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public class DotationService {
|
||||
|
||||
@Transactional
|
||||
public String genererCsvFlocageInitiales(Saison saisonActive) {
|
||||
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive);
|
||||
List<Dotation> 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<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive);
|
||||
List<Dotation> 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 "";
|
||||
|
||||
+4
-2
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user