Example #1
0
  static void updateStatusFinished(
      OrderDTO order, Date startOfBillingPeriod, Date endOfBillingPeriod)
      throws SessionInternalError {

    // all one timers are done
    if (order.getOrderPeriod().getId() == Constants.ORDER_PERIOD_ONCE) {
      OrderBL orderBL = new OrderBL(order);
      orderBL.setStatus(null, Constants.ORDER_STATUS_FINISHED);
    } else { // recursive orders get more complicated
      // except those that are immortal :)
      if (order.getActiveUntil() == null) {
        return;
      }
      // see until when the incoming process will cover
      // compare if this is after the order exipres
      Logger log = Logger.getLogger(BillingProcessBL.class);
      log.debug(
          "order "
              + order.getId()
              + "end of bp "
              + endOfBillingPeriod
              + " active until "
              + order.getActiveUntil());
      if (endOfBillingPeriod.compareTo(Util.truncateDate(order.getActiveUntil())) >= 0) {
        OrderBL orderBL = new OrderBL(order);
        orderBL.setStatus(null, Constants.ORDER_STATUS_FINISHED);
      }
    }
  }
  private boolean isOrderProvisionable(OrderDTO order) {
    if (order != null) {

      Date today = new Date();

      if (order.getOrderStatus() != null
          && order.getOrderStatus().getId() == Constants.ORDER_STATUS_ACTIVE) {
        if (order.getActiveSince() != null
            && order.getActiveSince().before(today)
            && order.getActiveUntil() != null
            && order.getActiveUntil().after(today)) {

          return true;
        }
      }
    }

    return false;
  }