*/
private Double getRangeCostWholeDay(ProjectCalendar projectCalendar, TimescaleUnits rangeUnits, DateRange range, List<TimephasedCost> assignments, int startIndex)
{
int totalDays = 0;
double totalCost = 0;
TimephasedCost assignment = assignments.get(startIndex);
boolean done = false;
do
{
//
// Select the correct start date
//
long startDate = range.getStart().getTime();
long assignmentStart = assignment.getStart().getTime();
if (startDate < assignmentStart)
{
startDate = assignmentStart;
}
long rangeEndDate = range.getEnd().getTime();
long traEndDate = assignment.getFinish().getTime();
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(startDate);
Date calendarDate = cal.getTime();
//
// Start counting forwards
//
while (startDate < rangeEndDate && startDate < traEndDate)
{
if (projectCalendar == null || projectCalendar.isWorkingDate(calendarDate))
{
++totalDays;
}
cal.add(Calendar.DAY_OF_YEAR, 1);
startDate = cal.getTimeInMillis();
calendarDate = cal.getTime();
}
//
// If we still haven't reached the end of our range
// check to see if the next TRA can be used.
//
done = true;
totalCost += (assignment.getAmountPerDay().doubleValue() * totalDays);
if (startDate < rangeEndDate)
{
++startIndex;
if (startIndex < assignments.size())
{