Package net.sf.mpxj

Examples of net.sf.mpxj.TimephasedCost


            Date splitFinishTime = calendar.getFinishTime(splitStart);
            splitFinish = DateUtility.setTime(splitStart, splitFinishTime);
            Duration calendarSplitWork = calendar.getWork(splitStart, splitFinish, TimeUnit.MINUTES);
            splitCost = (assignment.getTotalAmount().doubleValue() * calendarSplitWork.getDuration()) / calendarWork.getDuration();

            TimephasedCost split = new TimephasedCost();
            split.setStart(splitStart);
            split.setFinish(splitFinish);
            split.setTotalAmount(Double.valueOf(splitCost));

            result[0] = split;
         }
         else
         {
            splitFinish = assignmentStart;
            splitCost = 0;
         }

         //
         // Split the remainder
         //
         Date splitStart = calendar.getNextWorkStart(splitFinish);
         splitFinish = assignmentFinish;
         TimephasedCost split;
         if (splitStart.getTime() > splitFinish.getTime())
         {
            split = null;
         }
         else
         {
            splitCost = assignment.getTotalAmount().doubleValue() - splitCost;

            split = new TimephasedCost();
            split.setStart(splitStart);
            split.setFinish(splitFinish);
            split.setTotalAmount(Double.valueOf(splitCost));
            split.setAmountPerDay(assignment.getAmountPerDay());
         }

         result[1] = split;
      }
      return result;
View Full Code Here


    */
   private void mergeSameDay(LinkedList<TimephasedCost> list)
   {
      LinkedList<TimephasedCost> result = new LinkedList<TimephasedCost>();

      TimephasedCost previousAssignment = null;
      for (TimephasedCost assignment : list)
      {
         if (previousAssignment == null)
         {
            assignment.setAmountPerDay(assignment.getTotalAmount());
            result.add(assignment);
         }
         else
         {
            Date previousAssignmentStart = previousAssignment.getStart();
            Date previousAssignmentStartDay = DateUtility.getDayStartDate(previousAssignmentStart);
            Date assignmentStart = assignment.getStart();
            Date assignmentStartDay = DateUtility.getDayStartDate(assignmentStart);

            if (previousAssignmentStartDay.getTime() == assignmentStartDay.getTime())
            {
               result.removeLast();

               double cost = previousAssignment.getTotalAmount().doubleValue();
               cost += assignment.getTotalAmount().doubleValue();

               TimephasedCost merged = new TimephasedCost();
               merged.setStart(previousAssignment.getStart());
               merged.setFinish(assignment.getFinish());
               merged.setTotalAmount(Double.valueOf(cost));
               assignment = merged;
            }

            assignment.setAmountPerDay(assignment.getTotalAmount());
            result.add(assignment);
View Full Code Here

    */
   protected void mergeSameCost(LinkedList<TimephasedCost> list)
   {
      LinkedList<TimephasedCost> result = new LinkedList<TimephasedCost>();

      TimephasedCost previousAssignment = null;
      for (TimephasedCost assignment : list)
      {
         if (previousAssignment == null)
         {
            assignment.setAmountPerDay(assignment.getTotalAmount());
            result.add(assignment);
         }
         else
         {
            Number previousAssignmentCost = previousAssignment.getAmountPerDay();
            Number assignmentCost = assignment.getTotalAmount();

            if (NumberUtility.equals(previousAssignmentCost.doubleValue(), assignmentCost.doubleValue(), 0.01))
            {
               Date assignmentStart = previousAssignment.getStart();
               Date assignmentFinish = assignment.getFinish();
               double total = previousAssignment.getTotalAmount().doubleValue();
               total += assignmentCost.doubleValue();

               TimephasedCost merged = new TimephasedCost();
               merged.setStart(assignmentStart);
               merged.setFinish(assignmentFinish);
               merged.setAmountPerDay(assignmentCost);
               merged.setTotalAmount(Double.valueOf(total));

               result.removeLast();
               assignment = merged;
            }
            else
View Full Code Here

         {
            Date blockEndDate = MPPUtility.getTimestampFromTenths(data, index + 16);
            double currentTotalCost = ((long) MPPUtility.getDouble(data, index + 8)) / 100;
            if (previousTotalCost != currentTotalCost)
            {
               TimephasedCost cost = new TimephasedCost();
               cost.setStart(blockStartDate);
               cost.setFinish(blockEndDate);
               cost.setTotalAmount(Double.valueOf(currentTotalCost - previousTotalCost));

               if (list == null)
               {
                  list = new LinkedList<TimephasedCost>();
               }
View Full Code Here

    */
   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())
            {
View Full Code Here

TOP

Related Classes of net.sf.mpxj.TimephasedCost

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.