DELETE FROM t_tctb_formula WHERE FID = 1102877010436426752;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1102877010436426752,{ts'2021-09-14  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#27#ybxm','{Q[销售额 - 免、抵、退办法出口销售额#一般项目]}','增值税一般纳税人总览表#27#一般项目','1','27','1102685677520327680','draft_zzsybnsr','tcvat_zlb_ybnsr','ybxm',' ',' ','if({C[#diff]} = 1,({S[select sum(t1.fpricetaxamount) from t_tcvat_income_summary t1 where t1.forgid=''#orgid'' and t1.ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and t1.fdeadline=''#deadline'' and t1.fjzjt=''0'' and t1.ftaxrate=''5%'']} - min({S[select sum(t1.fpricetaxamount) from t_tcvat_income_summary t1 where t1.forgid=''#orgid'' and t1.ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and t1.fdeadline=''#deadline'' and t1.fjzjt=''0'' and t1.ftaxrate=''5%'']}, {S[select sum(fcurrentamount) from t_tcvat_diffdeduct where forgid=''#orgid'' and ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and fdeadline=''#deadline'' and fdifftypeid=859352590188589060]} + {S[select sum(t1.fqmye) from t_tcvat_ybnsr_fb3 t1 left join t_tctb_declare_main t2 on t1.fsbbid = CONCAT(t2.fid , '''') where t1.fewblxh=''5'' and t2.forgid=''#orgid'' and t2.fskssqq=to_date(''#prestartDate'') and t2.fskssqz=to_date(''#preendDate'') and t2.fnsrtype=''zzsybnsr'']}))/1.05*0.05  +  ({S[select sum(t1.fpricetaxamount) from t_tcvat_income_summary t1 where t1.forgid=''#orgid'' and t1.ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and t1.fdeadline=''#deadline'' and t1.fjzjt=''0'' and t1.ftaxrate=''3%'']} - min({S[select sum(t1.fpricetaxamount) from t_tcvat_income_summary t1 where t1.forgid=''#orgid'' and t1.ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and t1.fdeadline=''#deadline'' and t1.fjzjt=''0'' and t1.ftaxrate=''3%'']}, {S[select sum(fcurrentamount) from t_tcvat_diffdeduct where forgid=''#orgid'' and ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and fdeadline=''#deadline'' and fdifftypeid=859352590188589061]} + {S[select sum(t1.fqmye) from t_tcvat_ybnsr_fb3 t1 left join t_tctb_declare_main t2 on t1.fsbbid = CONCAT(t2.fid , '''') where t1.fewblxh=''6'' and t2.forgid=''#orgid'' and t2.fskssqq=to_date(''#prestartDate'') and t2.fskssqz=to_date(''#preendDate'') and t2.fnsrtype=''zzsybnsr'']}))/1.03*0.03,{S[select sum(t1.ftotaltaxamount) from t_tcvat_income_summary t1 , t_tpo_taxitemrateentry t2  where t1.fbusinesstypeid=t2.fentryid  and  t1.forgid=''#orgid'' and t1.ftaxperiod in (''#startPeriod'',''#middlePeriod'',''#endPeriod'') and t1.fdeadline=''#deadline'' and t1.fjzjt=''0'' and t1.ftaxrate in (''3%'',''5%'') ]})'); 
