code: private TimephasedCost splitCostEnd(ProjectCalendar calendar, double totalAmount, Date finish)
     {
        TimephasedCost cost = new TimephasedCost();
        cost.setStart(calendar.getStartDate(finish, Duration.getInstance(1, TimeUnit.DAYS)));
        cost.setFinish(finish);
        cost.setAmountPerDay(Double.valueOf(totalAmount));
        cost.setTotalAmount(Double.valueOf(totalAmount));
  
        return cost;
     }
docs: Used for Cost type Resources.
  
  Generates a TimphasedCost block for the total amount on the finish date. This is useful
  for Cost resources that have an AccrueAt value of End.
  
  @param calendar calendar used by this assignment
  @param totalAmount cost amount for this block
  @param finish finish date of the timephased cost block
  @return timephased cost