W
WilliamGui
Unregistered / Unconfirmed
GUEST, unregistred user!
-- -- 计算本期入库、出库(平均价) update t_material_pbcategory pc set --本期财务关账的入库 CURINMONEYAVERAGE=(select nvl(( -- -- 本期入库 (select nvl(sum(io.MATERIALMONEYAVERAGE), 0) from t_material_inandoutdetail io inner join t_material_baseinfo i on i.materialguid=io.materialguid where io.periodofbursar = pc.periodofbursar and io.inorout = 1 and (io.billtype = 'PD' or io.billtype = 'RK') -- or io.billtype = 'FP' and i.categorycode like trim(pc.categorycode)||'%') -- -- 减去 对本期的退货(退库) - (select nvl(sum(io.MATERIALMONEYAVERAGE), 0) from t_material_inandoutdetail io inner join t_material_baseinfo i on i.materialguid=io.materialguid inner join t_material_OutStorageMaster tkm on tkm.outstoragemasterguid=io.billguid --and tkm.OutStorageType='01' inner join t_material_instoragemaster rkm on rkm.InStorageNo=tkm.InStorageNo where io.periodofbursar = pc.periodofbursar and io.inorout = 0 and (io.billtype = 'TK' and io.periodofbursar=rkm.periodofbursar) and i.categorycode like trim(pc.categorycode)||'%') -- -- 加上 对以前会计期的退料 + (select nvl(sum(io.MATERIALMONEYAVERAGE), 0) from t_material_inandoutdetail io inner join t_material_baseinfo i on i.materialguid=io.materialguid inner join t_material_ReStorageMaster tlm on tlm.restoragemasterguid=io.billguid --and tlm.ReStorageType='01' inner join t_material_ProvideMaster flm on flm.ProvideNO=tlm.ProvideNO where io.periodofbursar = pc.periodofbursar and io.inorout = 1 and (io.billtype = 'TL' and io.periodofbursar<>tlm.periodofbursar) and i.categorycode like trim(pc.categorycode)||'%') ),0) from dual), --本期财务关账的出库 CUROUTMONEYAVERAGE=(select nvl(( -- -- 本期发料 (select nvl(sum(io.MATERIALMONEYAVERAGE), 0) from t_material_inandoutdetail io inner join t_material_baseinfo i on i.materialguid=io.materialguid where io.periodofbursar = pc.periodofbursar and io.inorout = 0 and (io.billtype = 'PD' or io.billtype = 'FL') and i.categorycode like trim(pc.categorycode)||'%') -- -- 减去 对本期的退料 - (select nvl(sum(io.MATERIALMONEYAVERAGE), 0) from t_material_inandoutdetail io inner join t_material_baseinfo i on i.materialguid=io.materialguid inner join t_material_ReStorageMaster tlm on tlm.restoragemasterguid=io.billguid --and tlm.ReStorageType='01' inner join t_material_ProvideMaster flm on flm.ProvideNO=tlm.ProvideNO where io.periodofbursar = pc.periodofbursar and io.inorout = 1 and (io.billtype = 'TL' and io.periodofbursar=tlm.periodofbursar) and i.categorycode like trim(pc.categorycode)||'%') -- -- 加上 对以前会计期的退货(退库) + (select nvl(sum(io.MATERIALMONEYAVERAGE), 0) from t_material_inandoutdetail io inner join t_material_baseinfo i on i.materialguid=io.materialguid inner join t_material_OutStorageMaster tkm on tkm.outstoragemasterguid=io.billguid --and tkm.OutStorageType='01' inner join t_material_instoragemaster rkm on rkm.InStorageNo=tkm.InStorageNo where io.periodofbursar = pc.periodofbursar and io.inorout = 0 and (io.billtype = 'TK' and io.periodofbursar<>rkm.periodofbursar) and i.categorycode like trim(pc.categorycode)||'%') ),0) from dual) where pc.periodofbursar = '200901';