Fixed problems in the algorithm when having criteria both on requirements and hours group
FEA: ItEr77S17AutomaticBudgeting
This commit is contained in:
parent
2ccb291570
commit
629f235823
1 changed files with 11 additions and 29 deletions
|
|
@ -1706,23 +1706,14 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
}
|
||||
|
||||
public BigDecimal getResourcesBudget() {
|
||||
BigDecimal result = new BigDecimal(0);
|
||||
Configuration configuration = Registry.getConfigurationDAO()
|
||||
.getConfiguration();
|
||||
if (configuration == null) {
|
||||
return result;
|
||||
}
|
||||
if (configuration.isEnabledAutomaticBudget()) {
|
||||
result = Registry.getTransactionService().runOnReadOnlyTransaction(
|
||||
new IOnTransaction<BigDecimal>() {
|
||||
return Registry.getTransactionService().runOnReadOnlyTransaction(
|
||||
new IOnTransaction<BigDecimal>() {
|
||||
|
||||
@Override
|
||||
public BigDecimal execute() {
|
||||
return calculateBudgetFromCriteriaAndCostCategories();
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
@Override
|
||||
public BigDecimal execute() {
|
||||
return calculateBudgetFromCriteriaAndCostCategories();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public BigDecimal calculateBudgetFromCriteriaAndCostCategories() {
|
||||
|
|
@ -1740,19 +1731,6 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
BigDecimal costPerHour = new BigDecimal(0);
|
||||
BigDecimal hours = new BigDecimal(0);
|
||||
|
||||
for (CriterionRequirement requirement : getCriterionRequirements()) {
|
||||
hours = new BigDecimal(getWorkHours());
|
||||
if (requirement.getCriterion().getCostCategory() != null) {
|
||||
|
||||
IHourCostDAO hourCostDAO = Registry.getHourCostDAO();
|
||||
costPerHour = hourCostDAO.getPriceCostFromCriterionAndType(
|
||||
requirement.getCriterion().getCostCategory(),
|
||||
typeofWorkHours);
|
||||
|
||||
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
||||
}
|
||||
}
|
||||
|
||||
for (HoursGroup hoursGroup : getHoursGroups()) {
|
||||
hours = new BigDecimal(hoursGroup.getWorkingHours());
|
||||
|
||||
|
|
@ -1769,6 +1747,10 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
}
|
||||
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
||||
}
|
||||
if (hoursGroup.getCriterionRequirements().size() > 1) {
|
||||
totalBudget = totalBudget.divide(new BigDecimal(hoursGroup
|
||||
.getCriterionRequirements().size()));
|
||||
}
|
||||
}
|
||||
|
||||
return totalBudget;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue