Skip to content

Commit

Permalink
Merge branch '1372-implementare-la-gestione-dei-congedi-parentali-per…
Browse files Browse the repository at this point in the history
…-i-padri-e-modificare-il-comportamento-dei' into 'master'

Resolve "Implementare la gestione dei congedi parentali per i padri e modificare il comportamento dei congedi parentali precedenti"

Closes #1372

See merge request epas/epas!1605
  • Loading branch information
criluc committed Sep 21, 2022
2 parents 69a2a7d + f5b7908 commit 24df16f
Show file tree
Hide file tree
Showing 10 changed files with 690 additions and 120 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Completata la gestione delle comunicazioni ferie/riposi compensativi per i livelli I-III
nel caso il parametro generale sia configurato per non permettere approvazioni per i
livelli I-III
- Aggiunti nuovi codici di assenza per congedo parentale per il padre.
- Modificati i codici d congedo parentale al 30% secondo le linee guida dettate dalle modifiche al
regolamento del CNR.

## [2.5.5] - 2022-09-19
### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.0-rc1
2.6.0-rc2
2 changes: 1 addition & 1 deletion app/jobs/AbsencesRedefinitionsJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
*/
@Slf4j
@OnApplicationStart(async = true)
@OnApplicationStart
public class AbsencesRedefinitionsJob extends Job<Void> {

@Inject
Expand Down
88 changes: 88 additions & 0 deletions app/jobs/ParentalCodesFix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package jobs;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import dao.absences.AbsenceComponentDao;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import models.Person;
import models.absences.Absence;
import org.joda.time.LocalDate;
import play.Play;
import play.jobs.Job;
import play.jobs.OnApplicationStart;

@Slf4j
@OnApplicationStart(async = true)
public class ParentalCodesFix extends Job {

@Inject
static AbsenceComponentDao absenceComponentDao;

@Override
public void doJob() {

//in modo da inibire l'esecuzione dei job in base alla configurazione
if (!"true".equals(Play.configuration.getProperty(Bootstrap.JOBS_CONF))) {
log.info("{} interrotto. Disattivato dalla configurazione.", getClass().getName());
return;
}
log.info("Start Job parental codes fix");
List<String> codes = ImmutableList.of("25O", "252O", "253O", "254O", "25MO", "252MO", "253MO",
"254MO", "25OH7", "252OH7", "253OH7", "254OH7");
List<Absence> allChildrenCodes = absenceComponentDao.absences(codes);
List<Absence> childrenCodesFiltered = allChildrenCodes.stream()
.filter(ab -> !ab.personDay.date.isBefore(new LocalDate(2022, 8, 13)))
.collect(Collectors.toList());
log.debug("Ci sono {} assenze da modificare", childrenCodesFiltered.size() );
for (Absence abs : childrenCodesFiltered) {
switch (abs.absenceType.code) {
case "25O":
abs.absenceType = absenceComponentDao.absenceTypeByCode("25").get();
break;
case "252O":
abs.absenceType = absenceComponentDao.absenceTypeByCode("252").get();
break;
case "253O":
abs.absenceType = absenceComponentDao.absenceTypeByCode("253").get();
break;
case "254O":
abs.absenceType = absenceComponentDao.absenceTypeByCode("254").get();
break;
case "25MO":
abs.absenceType = absenceComponentDao.absenceTypeByCode("25M").get();
break;
case "252MO":
abs.absenceType = absenceComponentDao.absenceTypeByCode("252M").get();
break;
case "253MO":
abs.absenceType = absenceComponentDao.absenceTypeByCode("253M").get();
break;
case "254MO":
abs.absenceType = absenceComponentDao.absenceTypeByCode("254M").get();
break;
case "25OH7":
abs.absenceType = absenceComponentDao.absenceTypeByCode("25H7").get();
break;
case "252OH7":
abs.absenceType = absenceComponentDao.absenceTypeByCode("252H7").get();
break;
case "253OH7":
abs.absenceType = absenceComponentDao.absenceTypeByCode("253H7").get();
break;
case "254OH7":
abs.absenceType = absenceComponentDao.absenceTypeByCode("254H7").get();
break;
default:
break;
}
abs.save();
}

log.info("End Job parental codes fix");

}
}
14 changes: 9 additions & 5 deletions app/manager/services/absences/AbsenceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -702,23 +702,27 @@ public List<GroupAbsenceType> groupsPermitted(Person person, boolean readOnly) {
private List<String> namesOfChildGroups() {
List<String> names = Lists.newArrayList();
names.add(DefaultGroup.G_23.name());
names.add(DefaultGroup.G_24.name());
// names.add(DefaultGroup.G_24.name());
names.add(DefaultGroup.G_25.name());
names.add(DefaultGroup.G_25A.name());
names.add(DefaultGroup.G_232.name());
names.add(DefaultGroup.G_233.name());
names.add(DefaultGroup.G_242.name());
names.add(DefaultGroup.G_243.name());
names.add(DefaultGroup.G_244.name());
// names.add(DefaultGroup.G_242.name());
// names.add(DefaultGroup.G_243.name());
// names.add(DefaultGroup.G_244.name());
names.add(DefaultGroup.G_234.name());
names.add(DefaultGroup.G_252.name());
names.add(DefaultGroup.G_253.name());
names.add(DefaultGroup.G_254.name());
names.add(DefaultGroup.G_252A.name());
names.add(DefaultGroup.G_253A.name());
names.add(DefaultGroup.G_254A.name());
names.add(DefaultGroup.MALATTIA_FIGLIO_1.name());
names.add(DefaultGroup.MALATTIA_FIGLIO_2.name());
names.add(DefaultGroup.MALATTIA_FIGLIO_3.name());
names.add(DefaultGroup.MALATTIA_FIGLIO_4.name());
names.add(DefaultGroup.G_25P.name());
names.add(DefaultGroup.G_COV50.name());
// names.add(DefaultGroup.G_COV50.name());

return names;
}
Expand Down
Loading

0 comments on commit 24df16f

Please sign in to comment.