publishRemoveTask(prev_refill);
plugin_.publishRemoveFromExpansion(prev_refill);
    protected Task orderRefillWithPrevious(Inventory inventory, int day, InventoryPG invpg, Date date,					   double currentInventory, double goal_level,					   double refill_qty){	//   		printDebug(1,"orderRefill with previous on day: "+day+	//  			   " current= "+currentInventory+ " goal_level = "+ goal_level);	Task task = null;	    	Task prev_refill = invpg.getRefillOnDay(day);	Allocation alloc =(Allocation)prev_refill.getPlanElement();	AllocationResult report = null;	if(alloc!=null) {	    report = alloc.getReportedResult();	}	if (report!=null) {	    if (!report.isSuccess()){		printLog("Known failed refill: "+TaskUtils.taskDesc(prev_refill));		return null;	    } else {		// check if the refill came too late....		if (TaskUtils.getRefillTime(prev_refill) > TaskUtils.getEndTime(prev_refill)) {		    printDebug(0,"previous refill succeeded too late: "+			       TaskUtils.taskDesc(prev_refill)+			       " to fill: " +refill_qty);		    if (TaskUtils.getQuantity(prev_refill) >= refill_qty) {				// the refill would have been enough 			printDebug(0,"NO REFILL!");			return null;		    } 		} else {		    // previous refill already added to inventory, need increase 		    // requested amount by the old plus the new 		    printDebug(0,"Previous refill already added to the inventory on the right date, still need more");		    refill_qty += TaskUtils.getQuantity(prev_refill);		}	    }	} else if (TaskUtils.getQuantity(prev_refill) >= refill_qty) {	    printDebug(0,"NEW POLICY- DON'T LOWER PREVIOUS ORDER -- NO REFILL!");	    return null;	}	// Send orders for whole items, i.e. do not order 0.5 O-rings	if (invpg.getCapacity() instanceof Count) {	    if(refill_qty<1.0){		return null;	    } else {		refill_qty=java.lang.Math.ceil(refill_qty);		if (refill_qty == 0)		    return null;	    }	}	printDebug(1, "Refill Quantity is: "+refill_qty);	task = createRefillTask(inventory, refill_qty, TimeUtils.addNDays(invpg.getStartTime(), day));	// if prev_refill!= null, and we have no reported failure, then we	//  should modify this refill task	printLog("Replacing: "+TaskUtils.taskDesc(prev_refill)+" by: "+		 TaskUtils.taskDesc(task));	publishRemoveTask(prev_refill);	invpg.removeDueIn(prev_refill);	Task parentTask = inventoryPlugIn_.findOrMakeMILTask(inventory);	plugin_.publishAddToExpansion(parentTask, task);	invpg.addDueIn(task);	return task;    }