this.costRateGenerator = costRateGenerator;
this.fixedCostDate = fixedCostDate;
this.proratedCost = proratedCost;
}
public void execute(Object object) {
HasStartAndEnd interval = (HasStartAndEnd)object;
AbstractContourBucket bucket = (AbstractContourBucket) contourBucketIntervalGenerator.current();
if (bucket != null) {
CostRate costRate = (CostRate)costRateGenerator.current();
double bucketUnits = bucket.getEffectiveUnits(assignment.getUnits());
if (bucketUnits != 0.0) { // there are never values if there is no normal cost.
// calculate regular and overtime
long bucketDuration = workCalendar.compare(interval.getEnd(),interval.getStart(), false);
//When we handle overhead, we need to have another interval generator which keeps overhead in sorted order
// The bucket duration should be multiplied by 1 - overhead. Code also needs to exist in workFunctor. maybe others too
// double overhead = overheadIntervalGenerator.current();
// bucketDuration *= (1.0 - overhead);
// might as well calculate work too
regularWork += bucketUnits * bucketDuration;
overtimeWork += overtimeUnits * bucketDuration;
work = regularWork + overtimeWork;
double bucketOvertime = costRate.getOvertimeRate().getValue() * overtimeUnits;
double bucketRegular = costRate.getStandardRate().getValue() * bucketUnits;
if (assignment.isTemporal()) { // for work resources or time based material
bucketRegular *= bucketDuration;
bucketOvertime *= bucketDuration;
}
overtimeValue += bucketOvertime;
regularValue += bucketRegular;
value += (bucketOvertime + bucketRegular);
// Below is fixed cost processing.
double costPerUse = costRate.getCostPerUse();
if (costPerUse != 0.0D) {
double fraction = 1.0D; // fraction of fixed cost to use - only relevant if prorated
if (proratedCost) { // prorated across duration
long assignmentDuration = assignment.getDuration();
if (assignmentDuration != 0) {
fraction = ((double)bucketDuration) / assignment.getDuration();
}
} else { // at a certain date - start or end
// make sure that the start or end date falls within the interval
if (interval.getStart() > fixedCostDate || interval.getEnd() < fixedCostDate)
return; // not in range
}
// Notice how the cost per use is multiplied by the assignment units, which itself is the peak units used.
double bucketFixed = fraction * costPerUse * assignment.getUnits();
fixedValue += bucketFixed;