Prevent NPE if there is not relationship between resource and type of hours via cost category
In that case the default price for the hours type is used. FEA: ItEr76S17MoneyCostMonitoringSystem
This commit is contained in:
parent
42ea25bd9f
commit
79573836b1
2 changed files with 12 additions and 1 deletions
|
|
@ -38,7 +38,11 @@ public interface IMoneyCostCalculator {
|
|||
* following formula:<br />
|
||||
* <tt>Sum of all the hours devoted to a task multiplied by the cost of
|
||||
* each hour according to these parameters (type of hour, cost category of
|
||||
* the resource, date of the work report)</tt>
|
||||
* the resource, date of the work report)</tt><br />
|
||||
*
|
||||
* If there is not relationship between resource and type of hour through
|
||||
* the cost categories, the price used is the default one for the type of
|
||||
* hour.
|
||||
*
|
||||
* @param The
|
||||
* {@link OrderElement} to calculate the money cost
|
||||
|
|
|
|||
|
|
@ -66,6 +66,13 @@ public class MoneyCostCalculator implements IMoneyCostCalculator {
|
|||
workReportLine.getResource(),
|
||||
workReportLine.getLocalDate(),
|
||||
workReportLine.getTypeOfWorkHours());
|
||||
|
||||
// If cost undefined via CostCategory get it from type
|
||||
if (priceCost == null) {
|
||||
priceCost = workReportLine.getTypeOfWorkHours()
|
||||
.getDefaultPrice();
|
||||
}
|
||||
|
||||
BigDecimal cost = priceCost.multiply(workReportLine.getEffort()
|
||||
.toHoursAsDecimalWithScale(2));
|
||||
result = result.add(cost);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue