code: 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 = DateHelper.popCalendar(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();
           }
           DateHelper.pushCalendar(cal);
           
           //
           // 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())
              {
                 assignment = assignments.get(startIndex);
                 totalDays = 0;
                 done = false;
              }
           }
        }
        while (!done);
  
        return Double.valueOf(totalCost);
     }
docs: For a given date range, determine the cost, based on the
  timephased resource assignment data.
  
  This method deals with timescale units of one day or more.
  
  @param projectCalendar calendar used for the resource assignment calendar
  @param rangeUnits timescale units
  @param range target date range
  @param assignments timephased resource assignments
  @param startIndex index at which to start searching through the timephased resource assignments
  @return work duration