Skip to content

Commit

Permalink
Merge pull request #919 from ricardorcr/fixPhdGratuityGeneration
Browse files Browse the repository at this point in the history
Corrected the way the states are checked to generate Phd gratuity debt ACDM-987 #resolve
  • Loading branch information
pedrosan7os committed Oct 29, 2015
2 parents 43bb8a6 + 6c73264 commit c88204e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract public class PhdProcessState extends PhdProcessState_Base {
static final public Comparator<PhdProcessState> COMPARATOR_BY_DATE = new Comparator<PhdProcessState>() {
@Override
public int compare(PhdProcessState o1, PhdProcessState o2) {
int result = o1.getWhenCreated().compareTo(o2.getWhenCreated());
int result = o1.getStateDate().compareTo(o2.getStateDate());
return result != 0 ? result : o1.getExternalId().compareTo(o2.getExternalId());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.fenixedu.academic.ui.struts.action.phd.academicAdminOffice;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Collections;
import java.util.TreeSet;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -119,23 +119,14 @@ public ActionForward createGratuityEvent(ActionMapping mapping, ActionForm actio
}

PhdIndividualProgramProcess process = getProcess(request);

TreeSet<PhdProgramProcessState> orderdStates =
new TreeSet<PhdProgramProcessState>(new Comparator<PhdProgramProcessState>() {

@Override
public int compare(PhdProgramProcessState o1, PhdProgramProcessState o2) {
return o1.getStateDate().compareTo(o2.getStateDate());
}
});

orderdStates.addAll(process.getStates());

int lastOpenYear = new DateTime().getYear();

int year = renderedObject.getYear();
boolean yearWithinWorkingDevelopmentPeriod = false;
for (PhdProgramProcessState state : process.getStates()) {
TreeSet<PhdProgramProcessState> orderedStates =
new TreeSet<PhdProgramProcessState>(Collections.reverseOrder(PhdProgramProcessState.COMPARATOR_BY_DATE));
orderedStates.addAll(process.getStatesSet());
for (PhdProgramProcessState state : orderedStates) {
if (state.getType().equals(PhdIndividualProgramProcessState.WORK_DEVELOPMENT)) {
if (state.getStateDate().getYear() <= year && year <= lastOpenYear) {
yearWithinWorkingDevelopmentPeriod = true;
Expand Down

0 comments on commit c88204e

Please sign in to comment.