Fix bug on stock calculation for replenishment: wrong order in ifsql.