-- 更新基本数量
update t_pur_returnentry_a set funmatchbaseqty=FBasicQty where funmatchbaseqty=0;
update t_pur_instockentry_a set funmatchbaseqty=FBasicQty where funmatchbaseqty=0;
update T_PUR_RECEIPTENTRY_a set funmatchbaseqty=FBasicQty where funmatchbaseqty=0;

--更新数量
UPDATE t_pur_returnentry_a A SET funmatchqty = (SELECT FQty FROM t_pur_returnentry WHERE Fentryid = A.Fentryid) WHERE EXISTS (SELECT 1 FROM t_pur_returnentry WHERE Fentryid = A.Fentryid);
UPDATE t_pur_instockentry_a A SET funmatchqty = (SELECT FQty FROM t_pur_instockentry WHERE Fentryid = A.Fentryid) WHERE EXISTS (SELECT 1 FROM t_pur_instockentry WHERE Fentryid = A.Fentryid);
UPDATE T_PUR_RECEIPTENTRY_a A SET funmatchqty = (SELECT FQty FROM T_PUR_RECEIPTENTRY WHERE Fentryid = A.Fentryid) WHERE EXISTS (SELECT 1 FROM T_PUR_RECEIPTENTRY WHERE Fentryid = A.Fentryid);
update T_PUR_CHECKENTRY2 set funmatchqty=FQty where funmatchqty = 0;
update T_PUR_CHECKENTRY2 set funmatchamt=factchecktaxamount where funmatchamt=0;

-- 更新开票对账标识
update t_pur_returnentry_a set fischeckorinvoice='1' where FSumCheckQty !=0 or finvoiceqty !=0;
update t_pur_instockentry_a set fischeckorinvoice='1' where FSumCheckQty !=0 or finvoiceqty !=0;
update T_PUR_RECEIPTENTRY_a set fischeckorinvoice='1' where FSumCheckQty!=0 or finvoiceqty !=0;

--预置数据
DELETE FROM t_pur_updateparamconfig WHERE FID = 1246232362174626816;
INSERT INTO t_pur_updateparamconfig(FID,FPARAMMSG,FPARAMKEY,FPARAMVALUE,FPARAMNAME) VALUES (1246232362174626816,'为N则不启用核销，为Y则启用核销','writeoffkey','N','是否启用核销');
