seems like conditions and inner logics are incorrect.
try test case for example when you haven't minimal qty to buy, but have qty increment - you'll fall to else condition and won't modify you $qty variable at all, so it won't meet qty increment step.