// Only adapt task leafs
if (!taskElement.isTask()) {
continue;
}
OrderElement orderElement = taskElement.getOrderElement();
// Reset status to allow move the task if needed while adapting the
// planning
taskElement.setUpdatedFromTimesheets(false);
if (orderElement.hasTimesheetsReportingHours()) {
setStartDateAndConstraint(taskElement,
orderElement.getFirstTimesheetDate());
Date lastTimesheetDate = orderElement.getLastTimesheetDate();
setEndDateIfNeeded(taskElement, lastTimesheetDate);
if (orderElement.isFinishedTimesheets()) {
setEndDate(taskElement, lastTimesheetDate);
addTimesheetsProgress(orderElement, lastTimesheetDate);
removeResourceAllocationsBeyondEndDate(taskElement);
} else {
removeTimesheetsProgressIfAny(orderElement);