* @param clause: SelectFrom clause to populate
* @return The functor to use to calculate cost
*/
private AssignmentFieldFunctor cost(SelectFrom clause, boolean all) {
if (detail.getCostContour().isPersonal()) { // in the case where a cost contour has already been saved, use it
ContourBucketIntervalGenerator costContour = contourGeneratorInstance(COST);
WorkFunctor workF = WorkFunctor.getInstance(this, getEffectiveWorkCalendar(), costContour, detail.calcOvertimeUnits()); // note that is is a work contour
clause.select(workF).from(costContour);
return workF;
} else {
boolean prorated = isProratedCost();
// if prorated, or if calculating a total, then treat as prorated
if (all || prorated) {
ContourBucketIntervalGenerator workContour = contourGeneratorInstance(WORK);
CollectionIntervalGenerator costRate = CollectionIntervalGenerator.getInstance(detail.getResource().getCostRateTable(detail.getCostRateIndex()).getList());
clause.from(costRate).from(workContour);
// Note that the getStart() parameter implies cost per use is applied at start
CostFunctor costF = CostFunctor.getInstance(this, getEffectiveWorkCalendar(), workContour, detail.calcOvertimeUnits(), costRate, getStart(),prorated);
clause.select(costF);