Try this.
DECLARE @BOM TABLE
(
ItemIDINT
,neededQuantityfloat
)
INSERT INTO @BOM (ItemID, neededQuantity)
SELECT 1, 10
UNION ALL SELECT 2, 10
UNION ALL SELECT 3, 5;
DECLARE @WhareHouseMovement TABLE
(
ItemIDINT
,Quantityfloat
,DateDATETIME
)
INSERT INTO @WhareHouseMovement (ItemID, Quantity, Date)
SELECT 1, 10, '2015-03-01'
UNION ALL SELECT 1, -4, '2015-03-06'
UNION ALL SELECT 1, -4, '2015-03-08'
UNION ALL SELECT 1, 6, '2015-03-20'
UNION ALL SELECT 1, 12, '2015-03-24'
UNION ALL SELECT 2, 6, '2015-03-01'
UNION ALL SELECT 2, 6, '2015-03-04'
UNION ALL SELECT 2, -10, '2015-03-15'
UNION ALL SELECT 2, 8, '2015-03-20'
UNION ALL SELECT 3, 10, '2015-03-05'
UNION ALL SELECT 3, -4, '2015-03-15'
UNION ALL SELECT 3, -2, '2015-03-25'
UNION ALL SELECT 3, 6, '2015-03-26';
with dts as (
select date, b.ItemId, b.neededQuantity
from (select distinct date from @WhareHouseMovement ) x
cross join @bom b),
avl as (
select dts.ItemId, dts.date, neededQuantity - isnull(q,0) ds
from dts
outer apply ( select sum(Quantity) q from @WhareHouseMovement s
where s.ItemId = dts.ItemId and s.Date <= dts.date
) x
)
select min(date) readytomnfc
from (
select date, max(ds) mds
from avl
group by date
having max(ds) <=0 ) z
Concerning perfomance you may want to replace triangular join which calculates runnig totals with quirky update.