private void addTimesheetsProgress(OrderElement orderElement,
Date progressDate) {
AdvanceType timesheetsAdvanceType = getTimesheetsAdvanceType();
DirectAdvanceAssignment timesheetsAdvanceAssignment = orderElement
.getDirectAdvanceAssignmentByType(timesheetsAdvanceType);
if (timesheetsAdvanceAssignment == null) {
timesheetsAdvanceAssignment = DirectAdvanceAssignment.create(false,
timesheetsAdvanceType.getDefaultMaxValue());
timesheetsAdvanceAssignment.setAdvanceType(timesheetsAdvanceType);
try {
orderElement.addAdvanceAssignment(timesheetsAdvanceAssignment);
} catch (DuplicateValueTrueReportGlobalAdvanceException e) {
// This shouldn't happen as the new advanceAssignment is not
// marked as spread yet
throw new RuntimeException(e);
} catch (DuplicateAdvanceAssignmentForOrderElementException e) {
// If the same type already exists in other element we don't do
// anything
return;
}
}
DirectAdvanceAssignment spreadAdvanceAssignment = orderElement
.getReportGlobalAdvanceAssignment();
if (spreadAdvanceAssignment != null) {
spreadAdvanceAssignment.setReportGlobalAdvance(false);
}
timesheetsAdvanceAssignment.setReportGlobalAdvance(true);
timesheetsAdvanceAssignment.resetAdvanceMeasurements(AdvanceMeasurement
.create(LocalDate.fromDateFields(progressDate),