package ibase.webitm.utility.wms;

import java.util.HashMap;
import java.util.Comparator;

public class CompareAllocQty implements Comparator
{
	public int compare(Object o1,Object o2)
	{
		HashMap map1 = (HashMap)o1;
		HashMap map2 = (HashMap)o2;
		
		String allocFlag1 = (String) map1.get("allocFlag");
		String allocFlag2 = (String) map2.get("allocFlag");
		
		double dataQty1 = Double.parseDouble(String.valueOf(map1.get("allocQty")));
		
		if(dataQty1 <= 0 && "M".equalsIgnoreCase(allocFlag1))
		{
			 dataQty1 = Double.parseDouble(String.valueOf(map1.get("mannual_alloc_qty")));
		}
				
		double dataQty2 = Double.parseDouble(String.valueOf(map2.get("allocQty")));
		
		if(dataQty2 <= 0 && "M".equalsIgnoreCase(allocFlag2))
		{
			dataQty2 = Double.parseDouble(String.valueOf(map2.get("mannual_alloc_qty")));
		}
		
		
		if( dataQty1 > dataQty2)
		{
			return -1;
		}
		else if(dataQty1 < dataQty2)
		{
			return 1;
		}
		else
		{
			return 0;
		}
		
	}
	
}
