Fix the onhand quantity query issue