-- 1.初始化:关联发货数量=累计发货数量,已退补数量与已退补基本数量初始化为0
IF NOT EXISTS (SELECT 1 FROM t_pur_updateparamconfig WHERE FID = 1315884313639904256 AND FPARAMKEY = 'isupdatefiscontrolqty') 
INSERT INTO t_pur_updateparamconfig(FID,FPARAMMSG,FPARAMKEY,FPARAMVALUE,FPARAMNAME) VALUES (1315884313639904256,'协同订单不控制数量改造历史数据升级','isupdatefiscontrolqty','N','协同订单不控制数量改造历史数据升级'); 

IF NOT EXISTS (SELECT 1 FROM t_pur_updateparamconfig WHERE FPARAMKEY = 'isupdatefiscontrolqty' AND FPARAMVALUE = 'Y') 
update T_PUR_ORDERENTRY_A set fiscontrolqty = '0'  where fiscontrolqty = '1' ;

IF NOT EXISTS (SELECT 1 FROM t_pur_updateparamconfig WHERE FPARAMKEY = 'isupdatefiscontrolqty' AND FPARAMVALUE = 'Y') 
update T_PUR_ORDERENTRY_A set frelateoutstockqty = fsumoutstockqty where 1=1 ;

IF NOT EXISTS (SELECT 1 FROM t_pur_updateparamconfig WHERE FPARAMKEY = 'isupdatefiscontrolqty' AND FPARAMVALUE = 'Y') 
update T_PUR_ORDERENTRY_A set fsaloutbaseqtydown=0 ,fsaloutqtydown = 0,fsaloutbaseqtyup=0, fsaloutqtyup =0, fsaloutrateup =0, fsaloutratedown=0 where 1=1 ;

update t_pur_updateparamconfig set FPARAMVALUE='Y' WHERE  FPARAMKEY = 'isupdatefiscontrolqty';



