/*费用报销冲申请分录添加字段后，初始化数据*/


UPDATE t_er_writeoffapply
SET   FORGFIELD = (SELECT FENTRYCOSTDEPTID FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID )
 where FSOURCEAPPLYENTRYID is not null and FSOURCEAPPLYENTRYID <> 0 and
 (SELECT FENTRYCOSTDEPTID FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID ) is not null  ;


 UPDATE t_er_writeoffapply
SET  FDATEFIELD = (SELECT  FHAPPENDATE  FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID )
 where FSOURCEAPPLYENTRYID is not null and FSOURCEAPPLYENTRYID <> 0;


UPDATE t_er_writeoffapply
SET FEXPENSEITEMFIELD =  (SELECT   FEXPENSEITEMID   FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID )
 where FSOURCEAPPLYENTRYID is not null and FSOURCEAPPLYENTRYID <> 0
 and (SELECT   FEXPENSEITEMID   FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID ) is not null;


UPDATE t_er_pubreimwrioffapply
SET   FORGFIELD = (SELECT FENTRYCOSTDEPTID FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID )
where FSOURCEAPPLYENTRYID is not null and FSOURCEAPPLYENTRYID <> 0
and (SELECT FENTRYCOSTDEPTID FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID ) is not null ;

UPDATE t_er_pubreimwrioffapply
SET FDATEFIELD = (SELECT  FHAPPENDATE  FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID )
where FSOURCEAPPLYENTRYID is not null and FSOURCEAPPLYENTRYID <> 0;

UPDATE t_er_pubreimwrioffapply
SET FEXPENSEITEMFIELD =  (SELECT   FEXPENSEITEMID   FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID )
where FSOURCEAPPLYENTRYID is not null and FSOURCEAPPLYENTRYID <> 0
and  (SELECT   FEXPENSEITEMID   FROM t_er_dailyapplydetail WHERE FDETAILID =  FSOURCEAPPLYENTRYID ) is not null;
