The objective is to determine the quantity of stock (of a particular type) to be transferred from “Stock surplus” locations to “Stock deficient” ones. If all the requirements cannot be met from one location, tap other locations. The final output should show the location from where stock is being transferred. Furthermore the order of determining “Stock transfer location” is descending order of stock available in “Stock surplus” locations. Stock available in “Stock surplus” locations should be determined after setting off quantity already transferred to other locations.
You may refer to my solution in this workbook.