Fix another adv. inv. bug:

The calculation of the maximal amount of items in the destination seems correct, but it is not applied.

Rename max to input_amount, because that's what it is - the initial amount of item to move.
The possible amount to move is then either the initial amount, or the restricted amount, whatever is smaller (can not move more items than there actual are).