Commit 912ffcd8 authored by prane's avatar prane

Changes related to forecast(salesforecast_hdr) added

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202670 ce508802-f39f-4f6c-b175-0d175dae99d5
parent bf112452
...@@ -25,7 +25,20 @@ select item_code, due_date, round(sum(demand)+ fn_get_sampleqty(item_code ,'@sit ...@@ -25,7 +25,20 @@ select item_code, due_date, round(sum(demand)+ fn_get_sampleqty(item_code ,'@sit
( dist_demand.due_date <= to_date('@todate@')) AND ( dist_demand.due_date <= to_date('@todate@')) AND
( 0 = @madetostock@ ) ( 0 = @madetostock@ )
Group By dist_demand.tran_id ,'D-DEM' ,item.item_code__plan,dist_demand.due_date ,dist_demand.site_code Group By dist_demand.tran_id ,'D-DEM' ,item.item_code__plan,dist_demand.due_date ,dist_demand.site_code
UNION ALL
SELECT h.TRAN_ID, 'S-FST' as tran_ser, item.item_code__plan as item_code,fn_get_prdfrdate(d.PRD_CODE__FOR) as due_date,
sum(fn_get_avgpotency('@itemcode@' ,'@sitecode@',case when d.quantity is null then 0 else d.quantity end )) as demand ,
0 as supply, 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr, h.SITE_CODE
FROM salesforecast_det d,salesforecast_hdr h, item
WHERE ( h.tran_id = d.tran_id ) and
( d.item_code = item.item_code ) and
( h.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( (select fr_date from period where code = d.PRD_CODE__FOR) >= to_date('@fromdate@')) AND
( (select to_date from period where code = d.PRD_CODE__FOR) <= to_date('@todate@')) AND
( 0 = @madetostock@ )
and trim(nvl((select si.mfg_type from siteitem si where si.site_code = h.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
Group By h.TRAN_ID, 'S-FST', item.item_code__plan,fn_get_prdfrdate(d.PRD_CODE__FOR),0, h.SITE_CODE
UNION ALL UNION ALL
select invtrace.tran_id||'@'||invtrace.ref_id||'@'||invtrace.ref_line tran_id,invtrace.ref_ser as tran_ser, item.item_code__plan as item_code, invtrace.tran_date as due_date, sum(invtrace.eff_qty) as demand, select invtrace.tran_id||'@'||invtrace.ref_id||'@'||invtrace.ref_line tran_id,invtrace.ref_ser as tran_ser, item.item_code__plan as item_code, invtrace.tran_date as due_date, sum(invtrace.eff_qty) as demand,
......
...@@ -23,6 +23,22 @@ ...@@ -23,6 +23,22 @@
( sales_demand.due_date <= to_date('@todate@')) AND ( sales_demand.due_date <= to_date('@todate@')) AND
( 0 = @madetostock@ ) ( 0 = @madetostock@ )
Group By item.item_code__plan,sales_demand.due_date Group By item.item_code__plan,sales_demand.due_date
UNION ALL
SELECT item.item_code__plan as item_code,fn_get_prdfrdate(d.PRD_CODE__FOR) as due_date,
sum(fn_get_avgpotency('@itemcode@' ,'@sitecode@',case when d.quantity is null then 0 else d.quantity end )) as demand ,
0 as supply
FROM salesforecast_det d,salesforecast_hdr h, item
WHERE ( h.tran_id = d.tran_id ) and
( d.item_code = item.item_code ) and
( h.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( (select fr_date from period where code = d.PRD_CODE__FOR) >= to_date('@fromdate@')) AND
( (select to_date from period where code = d.PRD_CODE__FOR) <= to_date('@todate@')) AND
( 0 = @madetostock@ )
and trim(nvl((select si.mfg_type from siteitem si where si.site_code = h.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
Group By item.item_code__plan,fn_get_prdfrdate(d.PRD_CODE__FOR),0
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date, SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand,
......
...@@ -16,6 +16,20 @@ ...@@ -16,6 +16,20 @@
( case when distorder.status is null then 'P' else distorder.status end = 'P') AND ( case when distorder.status is null then 'P' else distorder.status end = 'P') AND
( case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) > 0 ( case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) > 0
Group By item.item_code__plan,distorder_det.due_date Group By item.item_code__plan,distorder_det.due_date
UNION ALL
SELECT item.item_code__plan as item_code,fn_get_prdfrdate(d.PRD_CODE__FOR) as due_date,
sum(fn_get_avgpotency('@itemcode@' ,'@sitecode@',case when d.quantity is null then 0 else d.quantity end )) as demand ,
0 as supply, 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM salesforecast_det d,salesforecast_hdr h, item
WHERE ( h.tran_id = d.tran_id ) and
( d.item_code = item.item_code ) and
( h.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( (select fr_date from period where code = d.PRD_CODE__FOR) >= to_date('@fromdate@')) AND
( (select to_date from period where code = d.PRD_CODE__FOR) <= to_date('@todate@')) AND
( 0 = @madetostock@ )
and trim(nvl((select si.mfg_type from siteitem si where si.site_code = h.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
Group By item.item_code__plan,fn_get_prdfrdate(d.PRD_CODE__FOR),0
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date, SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date,
0 as demand, 0 as demand,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment