Avoid to add subcontractor progress in a project with subcontracted tasks.
FEA: ItEr75S31PreventingSubcontractorProgresses
This commit is contained in:
parent
ddb2862794
commit
83a99b9b87
2 changed files with 36 additions and 2 deletions
|
|
@ -721,7 +721,7 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
* @param newAdvanceAssignment
|
||||
* @throws DuplicateAdvanceAssignmentForOrderElementException
|
||||
*/
|
||||
private void checkAncestorsNoOtherAssignmentWithSameAdvanceType(
|
||||
public void checkAncestorsNoOtherAssignmentWithSameAdvanceType(
|
||||
OrderElement orderElement,
|
||||
DirectAdvanceAssignment newAdvanceAssignment)
|
||||
throws DuplicateAdvanceAssignmentForOrderElementException {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import org.libreplan.business.advance.exceptions.DuplicateValueTrueReportGlobalA
|
|||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.orders.daos.IOrderElementDAO;
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.planner.entities.TaskElement;
|
||||
import org.libreplan.business.planner.entities.consolidations.CalculatedConsolidatedValue;
|
||||
import org.libreplan.business.planner.entities.consolidations.CalculatedConsolidation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -349,6 +350,14 @@ public class ManageOrderElementAdvancesModel implements
|
|||
continue;
|
||||
}
|
||||
}
|
||||
// if the associated task of the order elemement or of some its
|
||||
// children is subcontrated the advance type subcontractor is not
|
||||
// permitted
|
||||
if (advanceType.getUnitName().equals(
|
||||
PredefinedAdvancedTypes.SUBCONTRACTOR.getTypeName())
|
||||
&& hasAnySubcontratedTaskOnChildren()) {
|
||||
continue;
|
||||
}
|
||||
advanceTypes.add(advanceType);
|
||||
}
|
||||
return getSpecificOrder(advanceTypes);
|
||||
|
|
@ -407,7 +416,11 @@ public class ManageOrderElementAdvancesModel implements
|
|||
}
|
||||
}
|
||||
|
||||
return this.isIndirectAdvanceAssignment;
|
||||
if(isIndirectAdvanceAssignment){
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.hasSubcontractedAssociatedTask(this.orderElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -875,4 +888,25 @@ public class ManageOrderElementAdvancesModel implements
|
|||
|
||||
}
|
||||
|
||||
public boolean hasAnySubcontratedTaskOnChildren() {
|
||||
List<OrderElement> list = new ArrayList<OrderElement>();
|
||||
list.add(orderElement);
|
||||
list.addAll(orderElement.getAllChildren());
|
||||
for (OrderElement child : list) {
|
||||
if (hasSubcontractedAssociatedTask(child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSubcontractedAssociatedTask(OrderElement orderElement) {
|
||||
for (TaskElement task : orderElement.getTaskElements()) {
|
||||
if (task.isSubcontracted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue