if (refill == null) {
long today = inventoryPlugin.getCurrentTimeMillis();  int maxLeadBucket = thePG.convertTimeToBucket(getTimeUtils(). addNDays(today, inventoryPlugin.getMaxLeadTime())); if ((refill == null) && (bucket > maxLeadBucket)) {
  protected double findCommittedRefill(int bucket, LogisticsInventoryPG thePG) {    double refillQty = 0;    ArrayList reqs = thePG.getRefillRequisitions();    Task refill = null;    if (bucket < reqs.size()) {      refill = (Task) reqs.get(bucket);    }    if (refill == null) {      refill = thePG.getRefillProjection(bucket);    }        //!!!NOTE that the inside slots of thePG.getRefillRequisitions are sometimes    // filled with null instead of a task - so make sure you really have a task!    if (refill != null) {      PlanElement pe = refill.getPlanElement();      AllocationResult ar = null;      if (pe !=null ) {        //try to use the reported result - but if its null - use the         // estimated result        if (pe.getReportedResult() != null) {          ar = pe.getReportedResult();        } else {          ar = pe.getEstimatedResult();        }        // make sure that we got atleast a valid reported OR estimated allocation result        if (ar != null) {          if (refill.getVerb().equals(Constants.Verb.PROJECTSUPPLY)) {            //demandrate            if (inventoryPlugin.getSupplyType().equals("BulkPOL")) {              //default rate for volume is days              refillQty = ar.getValue(AlpineAspectType.DEMANDRATE);            } else {              //default rate for counts is millis              refillQty = ar.getValue(AlpineAspectType.DEMANDRATE) * thePG.getBucketMillis();            }          } else {            try {              refillQty = ar.getValue(AspectType.QUANTITY);            } catch (Exception e) {              System.err.println(" Task is " + getTaskUtils().taskDesc(refill) );              e.printStackTrace();            }          }          return refillQty;	          }      }    }    // if we did not find a match return 0.0    return refillQty;  }