DELETE FROM t_tctb_formula WHERE FID = 1103368218732634112;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1103368218732634112,{ts'2023-02-01  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#7#ybxm',' ','增值税一般纳税人总览表#7#一般项目','1','7','1102685677520327680','draft_zzsybnsr','tcvat_zlb_ybnsr','ybxm',' ',' ','if(({C[#diff]}=1&&{C[#cekcdgBqfseHj]}!=0)||{C[#sqsbbFb3Qmye]}!=0,({S[select sum(a.fpricetaxamount) from t_tcvat_income_summary a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''13%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}-min({S[select sum(a.fpricetaxamount) from t_tcvat_income_summary a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''13%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},{S[select sum(fcurrentamount) from t_tcvat_diffdeduct where forgid=''#orgid'' and ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and fdifftypeid=859352590188589056]}+{S[select sum(a.fqmye) from t_tcvat_ybnsr_fb3 a left join t_tctb_declare_main b on a.fsbbid=CONCAT(b.fid,'''') where a.fewblxh=''1'' and b.forgid=''#orgid'' and b.fskssqq=to_date(''#prestartDate'') and b.fskssqz=to_date(''#preendDate'') and b.fnsrtype=''zzsybnsr'']}))/1.13*0.13+({S[select sum(a.fpricetaxamount) from t_tcvat_income_summary a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''9%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}-min({S[select sum(a.fpricetaxamount) from t_tcvat_income_summary a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''9%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},{S[select sum(fcurrentamount) from t_tcvat_diffdeduct where forgid=''#orgid'' and ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and fdifftypeid=859352590188589057]}+{S[select sum(a.fqmye) from t_tcvat_ybnsr_fb3 a left join t_tctb_declare_main b on a.fsbbid=CONCAT(b.fid,'''') where a.fewblxh=''2'' and b.forgid=''#orgid'' and b.fskssqq=to_date(''#prestartDate'') and b.fskssqz=to_date(''#preendDate'') and b.fnsrtype=''zzsybnsr'']}))/1.09*0.09+({S[select sum(a.fpricetaxamount) from t_tcvat_income_summary a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''6%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}-min({S[select sum(a.fpricetaxamount) from t_tcvat_income_summary a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''6%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},{S[select sum(fcurrentamount) from t_tcvat_diffdeduct where forgid=''#orgid'' and ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and fdifftypeid in(859352590188589058,859352590188589059)]}+{S[select sum(a.fqmye) from t_tcvat_ybnsr_fb3 a left join t_tctb_declare_main b on a.fsbbid=CONCAT(b.fid,'''') where a.fewblxh in(''3'', ''4'') and b.forgid=''#orgid'' and b.fskssqq=to_date(''#prestartDate'') and b.fskssqz=to_date(''#preendDate'') and b.fnsrtype=''zzsybnsr'']}))/1.06*0.06, if({C[#diff]}=0||({C[#cekcdgBqfseHj]}=0&&{C[#sqsbbFb3Qmye]}=0),{S[select sum(a.ftotaltaxamount) from t_tcvat_income_summary a inner join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate in (''6%'',''9%'',''10%'',''11%'',''13%'',''16%'',''17%'') and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},0))');
DELETE FROM t_tctb_formula WHERE FID = 1611554578313296957;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1611554578313296957,{ts'2023-02-02  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#7#ybxm',' ','增值税一般纳税人总览表#7#一般项目','1','7','1611554577046620160','draft_zzsybnsr_sjjt','tcvat_zlb_ybnsr','ybxm',' ',' ','if(({C[#diff]}=1&&{C[#cekcdgBqfseHj]}!=0)||{C[#sqsbbFb3Qmye]}!=0,({S[select sum(a.fpricetaxamount) from t_tcvat_income_sum_sjjt a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''13%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}-min({S[select sum(a.fpricetaxamount) from t_tcvat_income_sum_sjjt a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''13%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}, {S[select sum(fcurrentamount) from t_tcvat_diffdeduct_sjjt where forgid=''#orgid'' and ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and fdifftypeid=859352590188589056]}+{S[select sum(a.fqmye) from t_tcvat_ybnsr_fb3 a left join t_tctb_declare_main b on a.fsbbid=CONCAT(b.fid,'''') where a.fewblxh=''1'' and b.forgid=''#orgid'' and b.fskssqq=to_date(''#prestartDate'') and b.fskssqz=to_date(''#preendDate'') and b.fnsrtype=''zzsybnsr'']}))/1.13*0.13+({S[select sum(a.fpricetaxamount) from t_tcvat_income_sum_sjjt a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''9%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}-min({S[select sum(a.fpricetaxamount) from t_tcvat_income_sum_sjjt a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''9%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},{S[select sum(fcurrentamount) from t_tcvat_diffdeduct_sjjt where forgid=''#orgid'' and ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and fdifftypeid=859352590188589057]}+{S[select sum(a.fqmye) from t_tcvat_ybnsr_fb3 a left join t_tctb_declare_main b on a.fsbbid=CONCAT(b.fid,'''') where a.fewblxh=''2'' and b.forgid=''#orgid'' and b.fskssqq=to_date(''#prestartDate'') and b.fskssqz=to_date(''#preendDate'') and b.fnsrtype=''zzsybnsr'']}))/1.09*0.09+({S[select sum(a.fpricetaxamount) from t_tcvat_income_sum_sjjt a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''6%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]}-min({S[select sum(a.fpricetaxamount) from t_tcvat_income_sum_sjjt a left join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate=''6%'' and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},{S[select sum(fcurrentamount) from t_tcvat_diffdeduct_sjjt where forgid=''#orgid'' and ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and fdifftypeid in(859352590188589058,859352590188589059)]}+{S[select sum(a.fqmye) from t_tcvat_ybnsr_fb3 a left join t_tctb_declare_main b on a.fsbbid=CONCAT(b.fid,'''') where a.fewblxh in (''3'',''4'') and b.forgid=''#orgid'' and b.fskssqq=to_date(''#prestartDate'') and b.fskssqz=to_date(''#preendDate'') and b.fnsrtype=''zzsybnsr'']}))/1.06*0.06,if({C[#diff]}=0||({C[#cekcdgBqfseHj]}=0&&{C[#sqsbbFb3Qmye]}=0),{S[select sum(a.ftotaltaxamount) from t_tcvat_income_sum_sjjt a inner join t_tpo_taxitemrateentry b on a.fbusinesstypeid=b.fentryid where a.forgid=''#orgid'' and a.ftaxperiod in (''#sPeriod'',''#mPeriod'',''#ePeriod'') and a.fjzjt=''0'' and a.ftaxrate in (''6%'',''9%'',''10%'',''11%'',''13%'',''16%'',''17%'') and (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]},0))');
