DELETE FROM t_tctb_formula WHERE FID = 1611554578313296962;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1611554578313296962,{ts'2024-06-05  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#7#jzjtxm',' ','增值税一般纳税人总览表#7#即征即退项目','1','7','1611554577046620160','draft_zzsybnsr_sjjt','tcvat_zlb_ybnsr','jzjtxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summ_sjjt WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[SELECT sum(fjzjtynse) FROM t_tcvat_sjkce_summ_sjjt WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589056,859352590188589057,859352590188589058,859352590188589059)]}, {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=''1'' and a.FTAXMETHOD = ''一般计税'' and  (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]})');
DELETE FROM t_tctb_formula WHERE FID = 1808077454846206992;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1808077454846206992,{ts'2024-06-05  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_02','tcvat_zlb_ybnsr#7#jzjtxm',' ','增值税一般纳税人总览表#7#即征即退项目','1','7','1808077452505784320','draft_zzsybnsr','tcvat_zlb_ybnsr','jzjtxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[SELECT sum(fjzjtynse) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589056,859352590188589057,859352590188589058,859352590188589059)]}, {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=''1'' and a.FTAXMETHOD = ''一般计税'' and  (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]})');
DELETE FROM t_tctb_formula WHERE FID = 1808077454846207006;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1808077454846207006,{ts'2024-06-05  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_02','tcvat_zlb_ybnsr#7#ybxm',' ','增值税一般纳税人总览表#7#一般项目','1','7','1808077452505784320','draft_zzsybnsr','tcvat_zlb_ybnsr','ybxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[SELECT sum(fynse) - sum(fjzjtynse) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589056,859352590188589057,859352590188589058,859352590188589059)]}, {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.FTAXMETHOD = ''一般计税'' 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%'')]})');
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'2024-06-05  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#7#ybxm',' ','增值税一般纳税人总览表#7#一般项目','1','7','1611554577046620160','draft_zzsybnsr_sjjt','tcvat_zlb_ybnsr','ybxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summ_sjjt WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[SELECT sum(fynse) - sum(fjzjtynse) FROM t_tcvat_sjkce_summ_sjjt WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589056,859352590188589057,859352590188589058,859352590188589059)]}, {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.FTAXMETHOD = ''一般计税'' 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%'')]})');

-- 23年的模板
DELETE FROM t_tctb_formula WHERE FID = 1230462228940064768;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1230462228940064768,{ts'2024-01-16  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#7#jzjtxm',' ','增值税一般纳税人总览表#7#即征即退项目','1','7','1102685677520327680','draft_zzsybnsr','tcvat_zlb_ybnsr','jzjtxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[SELECT sum(fjzjtynse) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589056,859352590188589057,859352590188589058,859352590188589059)]}, {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=''1'' and a.FTAXMETHOD = ''一般计税'' and  (b.flongnumber like ''3%'' or b.flongnumber like ''4%'' or b.flongnumber like ''5%'')]})');
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-11-09  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#7#ybxm',' ','增值税一般纳税人总览表#7#一般项目','1','7','1102685677520327680','draft_zzsybnsr','tcvat_zlb_ybnsr','ybxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[SELECT sum(fynse) - sum(fjzjtynse) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589056,859352590188589057,859352590188589058,859352590188589059)]}, {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.FTAXMETHOD = ''一般计税'' 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%'')]})');

-- 27-1单元格公式修改
DELETE FROM t_tctb_formula WHERE FID = 1611554578313296934;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1611554578313296934,{ts'2024-06-20  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#27#ybxm','{Q[销售额 - 免、抵、退办法出口销售额#一般项目]}','增值税一般纳税人总览表#27#一般项目','1','27','1611554577046620160','draft_zzsybnsr_sjjt','tcvat_zlb_ybnsr','ybxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summ_sjjt WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[select sum(round(t1.ftotaltaxamount,2)) from t_tcvat_income_sum_sjjt 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%'') and(t2.flongnumber like ''1%'' or t2.flongnumber like ''2%'')]} + {S[SELECT sum(round(fynse,2)) - sum(round(fjzjtynse,2)) FROM t_tcvat_sjkce_summ_sjjt WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589060,859352590188589061)]}, {S[select  sum(round(t1.ftotaltaxamount,2))  from t_tcvat_income_sum_sjjt 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%'')]})');
DELETE FROM t_tctb_formula WHERE FID = 1808077454846207002;
INSERT INTO t_tctb_formula(FID,FUPDATETIME,FCONTENT,FTITLE,FTEMPLATENUM,FFORMULAKEY,FFORMULANAME,FNAME,FFORMULATYPE,FROW,FTEMPLATEID,FTAXTYPE,FTABLE,FCOLUMN,FCELLTYPE,FDESCRIBE,FFORMULA) VALUES (1808077454846207002,{ts'2024-06-20  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_02','tcvat_zlb_ybnsr#27#ybxm','{Q[销售额 - 免、抵、退办法出口销售额#一般项目]}','增值税一般纳税人总览表#27#一般项目','1','27','1808077452505784320','draft_zzsybnsr','tcvat_zlb_ybnsr','ybxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[select sum(round(t1.ftotaltaxamount,2)) 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%'') and(t2.flongnumber like ''1%'' or t2.flongnumber like ''2%'')]} + {S[SELECT sum(round(fynse,2)) - sum(round(fjzjtynse,2)) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589060,859352590188589061)]}, {S[select sum(round(t1.ftotaltaxamount,2)) 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%'')]})');
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'2024-06-20  00:00:00'},' ',' ','VAT_DRAFT_YBNSR_01','tcvat_zlb_ybnsr#27#ybxm','{Q[销售额 - 免、抵、退办法出口销售额#一般项目]}','增值税一般纳税人总览表#27#一般项目','1','27','1102685677520327680','draft_zzsybnsr','tcvat_zlb_ybnsr','ybxm',' ',' ','if({S[SELECT count(fid) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'']} > 0,{S[select sum(round(t1.ftotaltaxamount,2)) 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%'') and(t2.flongnumber like ''1%'' or t2.flongnumber like ''2%'')]} + {S[SELECT sum(round(fynse,2)) - sum(round(fjzjtynse,2)) FROM t_tcvat_sjkce_summary WHERE forgid = ''#orgid'' AND ftaxperiod = ''#taxperiod'' and fdifftypeid in (859352590188589060,859352590188589061)]}, {S[select sum(round(t1.ftotaltaxamount,2)) 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%'')]})');

