A useful exercise I have run into in Excel-land for mortgage calculations.
I'll confess I had to do this in Excel first to get my thoughts straight....
- Join the two tables based on SKU
- Initialise Initial Supply and Remaining Supply (not sure if that was needed, but it helped me to think)
- Calculate the Initial Supply for each attempted order based on prior orders filled
- Calculate Remaining Supply after each attempted (or filled) order
- Calculate the number of units provided in each order that was filled
- Filter results to get rid of those orders not filled