Fixes on the resources budget calculation algorithm
FEA: ItEr77S17AutomaticBudgeting
This commit is contained in:
parent
cd63d13805
commit
b65c34382f
1 changed files with 13 additions and 13 deletions
|
|
@ -1726,37 +1726,37 @@ public abstract class OrderElement extends IntegrationEntity implements
|
||||||
|
|
||||||
public BigDecimal calculateBudgetFromCriteriaAndCostCategories() {
|
public BigDecimal calculateBudgetFromCriteriaAndCostCategories() {
|
||||||
BigDecimal totalBudget = new BigDecimal(0);
|
BigDecimal totalBudget = new BigDecimal(0);
|
||||||
BigDecimal costPerHour = new BigDecimal(0);
|
|
||||||
Configuration configuration = Registry.getConfigurationDAO()
|
Configuration configuration = Registry.getConfigurationDAO()
|
||||||
.getConfiguration();
|
.getConfiguration();
|
||||||
TypeOfWorkHours typeofWorkHours = configuration
|
TypeOfWorkHours typeofWorkHours = configuration
|
||||||
.getBudgetDefaultTypeOfWorkHours();
|
.getBudgetDefaultTypeOfWorkHours();
|
||||||
|
if (!configuration.isEnabledAutomaticBudget()
|
||||||
if (typeofWorkHours == null) {
|
|| (configuration.getBudgetDefaultTypeOfWorkHours() == null)) {
|
||||||
return totalBudget;
|
return totalBudget;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This workarounds LazyException when adding new
|
// FIXME: This workarounds LazyException when adding new
|
||||||
// criteria but disables the refresh on changes
|
// criteria but disables the refresh on changes
|
||||||
for (CriterionRequirement requirement : getCriterionRequirements()) {
|
BigDecimal costPerHour = new BigDecimal(0);
|
||||||
BigDecimal hours = new BigDecimal(getWorkHours());
|
BigDecimal hours = new BigDecimal(0);
|
||||||
try {
|
|
||||||
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
|
||||||
|
|
||||||
|
for (CriterionRequirement requirement : getCriterionRequirements()) {
|
||||||
|
hours = new BigDecimal(getWorkHours());
|
||||||
|
try {
|
||||||
|
if (requirement.getCriterion().getCostCategory() != null) {
|
||||||
costPerHour = requirement.getCriterion().getCostCategory()
|
costPerHour = requirement.getCriterion().getCostCategory()
|
||||||
.getHourCostByCode(typeofWorkHours.getCode())
|
.getHourCostByCode(typeofWorkHours.getCode())
|
||||||
.getPriceCost();
|
.getPriceCost();
|
||||||
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
||||||
|
}
|
||||||
} catch (InstanceNotFoundException e) {
|
} catch (InstanceNotFoundException e) {
|
||||||
// TODO Auto-generated catch block
|
// Nothing to do, the budget is kept to 0
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (HoursGroup hoursGroup : getHoursGroups()) {
|
for (HoursGroup hoursGroup : getHoursGroups()) {
|
||||||
BigDecimal hours = new BigDecimal(hoursGroup.getWorkingHours());
|
hours = new BigDecimal(hoursGroup.getWorkingHours());
|
||||||
|
|
||||||
for (CriterionRequirement crit : hoursGroup
|
for (CriterionRequirement crit : hoursGroup
|
||||||
.getCriterionRequirements()) {
|
.getCriterionRequirements()) {
|
||||||
|
|
@ -1772,8 +1772,8 @@ public abstract class OrderElement extends IntegrationEntity implements
|
||||||
costPerHour = new BigDecimal(0);
|
costPerHour = new BigDecimal(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
||||||
}
|
}
|
||||||
totalBudget = totalBudget.add(costPerHour.multiply(hours));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalBudget;
|
return totalBudget;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue