Browse Source

回款明细增加整装工程账户回款

hu 3 weeks ago
parent
commit
5d3571509f

+ 104 - 14
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/回款明细.sql

@@ -105,79 +105,92 @@ select distinct t1.enterprisename,
                 cast(cast(t5.amount3 as float) as char)                                amount13,
                 cast(cast(t5.amount3 as float) as char)                                amount13,
                 cast(cast(t5.amount4 as float) as char)                                amount14,
                 cast(cast(t5.amount4 as float) as char)                                amount14,
                 cast(cast(t5.amount5 as float) as char)                                amount15,
                 cast(cast(t5.amount5 as float) as char)                                amount15,
+                cast(cast(t5.amount6 as float) as char)                                amount16,
                 cast(cast((t5.amount1 + t5.amount5 + t5.amount3) as float) as char)    sum1,
                 cast(cast((t5.amount1 + t5.amount5 + t5.amount3) as float) as char)    sum1,
                 cast(cast(t6.amount1 as float) as char)                                amount21,
                 cast(cast(t6.amount1 as float) as char)                                amount21,
                 cast(cast(t6.amount2 as float) as char)                                amount22,
                 cast(cast(t6.amount2 as float) as char)                                amount22,
                 cast(cast(t6.amount3 as float) as char)                                amount23,
                 cast(cast(t6.amount3 as float) as char)                                amount23,
                 cast(cast(t6.amount4 as float) as char)                                amount24,
                 cast(cast(t6.amount4 as float) as char)                                amount24,
                 cast(cast(t6.amount5 as float) as char)                                amount25,
                 cast(cast(t6.amount5 as float) as char)                                amount25,
+                cast(cast(t6.amount6 as float) as char)                                amount26,
                 cast(cast((t6.amount1 + t6.amount5 + t6.amount3) as float) as char)    sum2,
                 cast(cast((t6.amount1 + t6.amount5 + t6.amount3) as float) as char)    sum2,
                 cast(cast(t7.amount1 as float) as char)                                amount31,
                 cast(cast(t7.amount1 as float) as char)                                amount31,
                 cast(cast(t7.amount2 as float) as char)                                amount32,
                 cast(cast(t7.amount2 as float) as char)                                amount32,
                 cast(cast(t7.amount3 as float) as char)                                amount33,
                 cast(cast(t7.amount3 as float) as char)                                amount33,
                 cast(cast(t7.amount4 as float) as char)                                amount34,
                 cast(cast(t7.amount4 as float) as char)                                amount34,
                 cast(cast(t7.amount5 as float) as char)                                amount35,
                 cast(cast(t7.amount5 as float) as char)                                amount35,
+                cast(cast(t7.amount6 as float) as char)                                amount36,
                 cast(cast((t7.amount1 + t7.amount5 + t7.amount3) as float) as char)    sum3,
                 cast(cast((t7.amount1 + t7.amount5 + t7.amount3) as float) as char)    sum3,
                 cast(cast(t8.amount1 as float) as char)                                amount41,
                 cast(cast(t8.amount1 as float) as char)                                amount41,
                 cast(cast(t8.amount2 as float) as char)                                amount42,
                 cast(cast(t8.amount2 as float) as char)                                amount42,
                 cast(cast(t8.amount3 as float) as char)                                amount43,
                 cast(cast(t8.amount3 as float) as char)                                amount43,
                 cast(cast(t8.amount4 as float) as char)                                amount44,
                 cast(cast(t8.amount4 as float) as char)                                amount44,
                 cast(cast(t8.amount5 as float) as char)                                amount45,
                 cast(cast(t8.amount5 as float) as char)                                amount45,
+                cast(cast(t8.amount6 as float) as char)                                amount46,
                 cast(cast((t8.amount1 + t8.amount5 + t8.amount3) as float) as char)    sum4,
                 cast(cast((t8.amount1 + t8.amount5 + t8.amount3) as float) as char)    sum4,
                 cast(cast(t9.amount1 as float) as char)                                amount51,
                 cast(cast(t9.amount1 as float) as char)                                amount51,
                 cast(cast(t9.amount2 as float) as char)                                amount52,
                 cast(cast(t9.amount2 as float) as char)                                amount52,
                 cast(cast(t9.amount3 as float) as char)                                amount53,
                 cast(cast(t9.amount3 as float) as char)                                amount53,
                 cast(cast(t9.amount4 as float) as char)                                amount54,
                 cast(cast(t9.amount4 as float) as char)                                amount54,
                 cast(cast(t9.amount5 as float) as char)                                amount55,
                 cast(cast(t9.amount5 as float) as char)                                amount55,
+                cast(cast(t9.amount6 as float) as char)                                amount56,
                 cast(cast((t9.amount1 + t9.amount5 +  t9.amount3) as float) as char)    sum5,
                 cast(cast((t9.amount1 + t9.amount5 +  t9.amount3) as float) as char)    sum5,
                 cast(cast(t10.amount1 as float) as char)                               amount61,
                 cast(cast(t10.amount1 as float) as char)                               amount61,
                 cast(cast(t10.amount2 as float) as char)                               amount62,
                 cast(cast(t10.amount2 as float) as char)                               amount62,
                 cast(cast(t10.amount3 as float) as char)                               amount63,
                 cast(cast(t10.amount3 as float) as char)                               amount63,
                 cast(cast(t10.amount4 as float) as char)                               amount64,
                 cast(cast(t10.amount4 as float) as char)                               amount64,
                 cast(cast(t10.amount5 as float) as char)                               amount65,
                 cast(cast(t10.amount5 as float) as char)                               amount65,
+                cast(cast(t10.amount6 as float) as char)                               amount66,
                 cast(cast((t10.amount1 + t10.amount5 + t10.amount3) as float) as char) sum6,
                 cast(cast((t10.amount1 + t10.amount5 + t10.amount3) as float) as char) sum6,
                 cast(cast(t11.amount1 as float) as char)                               amount71,
                 cast(cast(t11.amount1 as float) as char)                               amount71,
                 cast(cast(t11.amount2 as float) as char)                               amount72,
                 cast(cast(t11.amount2 as float) as char)                               amount72,
                 cast(cast(t11.amount3 as float) as char)                               amount73,
                 cast(cast(t11.amount3 as float) as char)                               amount73,
                 cast(cast(t11.amount4 as float) as char)                               amount74,
                 cast(cast(t11.amount4 as float) as char)                               amount74,
                 cast(cast(t11.amount5 as float) as char)                               amount75,
                 cast(cast(t11.amount5 as float) as char)                               amount75,
+                cast(cast(t11.amount6 as float) as char)                               amount76,
                 cast(cast((t11.amount1 + t11.amount5 + t11.amount3) as float) as char) sum7,
                 cast(cast((t11.amount1 + t11.amount5 + t11.amount3) as float) as char) sum7,
                 cast(cast(t12.amount1 as float) as char)                               amount81,
                 cast(cast(t12.amount1 as float) as char)                               amount81,
                 cast(cast(t12.amount2 as float) as char)                               amount82,
                 cast(cast(t12.amount2 as float) as char)                               amount82,
                 cast(cast(t12.amount3 as float) as char)                               amount83,
                 cast(cast(t12.amount3 as float) as char)                               amount83,
                 cast(cast(t12.amount4 as float) as char)                               amount84,
                 cast(cast(t12.amount4 as float) as char)                               amount84,
                 cast(cast(t12.amount5 as float) as char)                               amount85,
                 cast(cast(t12.amount5 as float) as char)                               amount85,
+                cast(cast(t12.amount6 as float) as char)                               amount86,
                 cast(cast((t12.amount1 + t12.amount5 + t12.amount3) as float) as char) sum8,
                 cast(cast((t12.amount1 + t12.amount5 + t12.amount3) as float) as char) sum8,
                 cast(cast(t13.amount1 as float) as char)                               amount91,
                 cast(cast(t13.amount1 as float) as char)                               amount91,
                 cast(cast(t13.amount2 as float) as char)                               amount92,
                 cast(cast(t13.amount2 as float) as char)                               amount92,
                 cast(cast(t13.amount3 as float) as char)                               amount93,
                 cast(cast(t13.amount3 as float) as char)                               amount93,
                 cast(cast(t13.amount4 as float) as char)                               amount94,
                 cast(cast(t13.amount4 as float) as char)                               amount94,
                 cast(cast(t13.amount5 as float) as char)                               amount95,
                 cast(cast(t13.amount5 as float) as char)                               amount95,
+                cast(cast(t13.amount6 as float) as char)                               amount96,
                 cast(cast((t13.amount1 + t13.amount5 + t13.amount3) as float) as char) sum9,
                 cast(cast((t13.amount1 + t13.amount5 + t13.amount3) as float) as char) sum9,
                 cast(cast(t14.amount1 as float) as char)                               amount101,
                 cast(cast(t14.amount1 as float) as char)                               amount101,
                 cast(cast(t14.amount2 as float) as char)                               amount102,
                 cast(cast(t14.amount2 as float) as char)                               amount102,
                 cast(cast(t14.amount3 as float) as char)                               amount103,
                 cast(cast(t14.amount3 as float) as char)                               amount103,
                 cast(cast(t14.amount4 as float) as char)                               amount104,
                 cast(cast(t14.amount4 as float) as char)                               amount104,
                 cast(cast(t14.amount5 as float) as char)                               amount105,
                 cast(cast(t14.amount5 as float) as char)                               amount105,
+                cast(cast(t14.amount6 as float) as char)                               amount106,
                 cast(cast((t14.amount1 + t14.amount5 + t14.amount3) as float) as char) sum10,
                 cast(cast((t14.amount1 + t14.amount5 + t14.amount3) as float) as char) sum10,
                 cast(cast(t15.amount1 as float) as char)                               amount111,
                 cast(cast(t15.amount1 as float) as char)                               amount111,
                 cast(cast(t15.amount2 as float) as char)                               amount112,
                 cast(cast(t15.amount2 as float) as char)                               amount112,
                 cast(cast(t15.amount3 as float) as char)                               amount113,
                 cast(cast(t15.amount3 as float) as char)                               amount113,
                 cast(cast(t15.amount4 as float) as char)                               amount114,
                 cast(cast(t15.amount4 as float) as char)                               amount114,
                 cast(cast(t15.amount5 as float) as char)                               amount115,
                 cast(cast(t15.amount5 as float) as char)                               amount115,
+                cast(cast(t15.amount6 as float) as char)                               amount116,
                 cast(cast((t15.amount1 + t15.amount5 + t15.amount3) as float) as char) sum11,
                 cast(cast((t15.amount1 + t15.amount5 + t15.amount3) as float) as char) sum11,
                 cast(cast(t16.amount1 as float) as char)                               amount121,
                 cast(cast(t16.amount1 as float) as char)                               amount121,
                 cast(cast(t16.amount2 as float) as char)                               amount122,
                 cast(cast(t16.amount2 as float) as char)                               amount122,
                 cast(cast(t16.amount3 as float) as char)                               amount123,
                 cast(cast(t16.amount3 as float) as char)                               amount123,
                 cast(cast(t16.amount4 as float) as char)                               amount124,
                 cast(cast(t16.amount4 as float) as char)                               amount124,
                 cast(cast(t16.amount5 as float) as char)                               amount125,
                 cast(cast(t16.amount5 as float) as char)                               amount125,
+                cast(cast(t16.amount6 as float) as char)                               amount126,
                 cast(cast((t16.amount1 + t16.amount5 + t16.amount3) as float) as char) sum12,
                 cast(cast((t16.amount1 + t16.amount5 + t16.amount3) as float) as char) sum12,
                 cast(cast(t17.amount1 as float) as char)                               count1,
                 cast(cast(t17.amount1 as float) as char)                               count1,
                 cast(cast(t17.amount2 as float) as char)                               count2,
                 cast(cast(t17.amount2 as float) as char)                               count2,
                 cast(cast(t17.amount3 as float) as char)                               count3,
                 cast(cast(t17.amount3 as float) as char)                               count3,
                 cast(cast(t17.amount4 as float) as char)                               count4,
                 cast(cast(t17.amount4 as float) as char)                               count4,
                 cast(cast(t17.amount5 as float) as char)                               count5,
                 cast(cast(t17.amount5 as float) as char)                               count5,
-                cast(cast((t17.amount1 + t17.amount5 + t17.amount3) as float) as char) count6
+                cast(cast(t17.amount6 as float) as char)                               count6,
+                cast(cast((t17.amount1 + t17.amount5 + t17.amount3) as float) as char) count7
 from sys_enterprise t1
 from sys_enterprise t1
          left join sa_agents t2 on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
          left join sa_agents t2 on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
          left join sys_enterprise_tradefield t3 on t1.sys_enterpriseid = t3.sys_enterpriseid and t1.siteid = t3.siteid
          left join sys_enterprise_tradefield t3 on t1.sys_enterpriseid = t3.sys_enterpriseid and t1.siteid = t3.siteid
@@ -212,7 +225,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -237,6 +251,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '01'
                                           and t1.period = '01'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '01'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t5
                     where t5.siteid = $siteid$) t5
                    on t1.sys_enterpriseid = t5.sys_enterpriseid
                    on t1.sys_enterpriseid = t5.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -244,7 +263,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -269,6 +289,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '02'
                                           and t1.period = '02'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '02'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t6
                     where t5.siteid = $siteid$) t6
                    on t1.sys_enterpriseid = t6.sys_enterpriseid
                    on t1.sys_enterpriseid = t6.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -276,7 +301,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -301,6 +327,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '03'
                                           and t1.period = '03'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '03'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t7
                     where t5.siteid = $siteid$) t7
                    on t1.sys_enterpriseid = t7.sys_enterpriseid
                    on t1.sys_enterpriseid = t7.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -308,7 +339,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -333,6 +365,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '04'
                                           and t1.period = '04'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '04'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t8
                     where t5.siteid = $siteid$) t8
                    on t1.sys_enterpriseid = t8.sys_enterpriseid
                    on t1.sys_enterpriseid = t8.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -340,7 +377,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -365,6 +403,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '05'
                                           and t1.period = '05'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '05'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t9
                     where t5.siteid = $siteid$) t9
                    on t1.sys_enterpriseid = t9.sys_enterpriseid
                    on t1.sys_enterpriseid = t9.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -372,7 +415,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -397,6 +441,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '06'
                                           and t1.period = '06'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '06'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t10
                     where t5.siteid = $siteid$) t10
                    on t1.sys_enterpriseid = t10.sys_enterpriseid
                    on t1.sys_enterpriseid = t10.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -404,7 +453,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -429,6 +479,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '07'
                                           and t1.period = '07'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '07'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t11
                     where t5.siteid = $siteid$) t11
                    on t1.sys_enterpriseid = t11.sys_enterpriseid
                    on t1.sys_enterpriseid = t11.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -436,7 +491,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -461,6 +517,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '08'
                                           and t1.period = '08'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '08'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t12
                     where t5.siteid = $siteid$) t12
                    on t1.sys_enterpriseid = t12.sys_enterpriseid
                    on t1.sys_enterpriseid = t12.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -468,7 +529,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -493,6 +555,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '09'
                                           and t1.period = '09'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '09'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t13
                     where t5.siteid = $siteid$) t13
                    on t1.sys_enterpriseid = t13.sys_enterpriseid
                    on t1.sys_enterpriseid = t13.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -500,7 +567,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -525,6 +593,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '10'
                                           and t1.period = '10'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '10'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t14
                     where t5.siteid = $siteid$) t14
                    on t1.sys_enterpriseid = t14.sys_enterpriseid
                    on t1.sys_enterpriseid = t14.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -532,7 +605,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -557,6 +631,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '11'
                                           and t1.period = '11'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '11'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t15
                     where t5.siteid = $siteid$) t15
                    on t1.sys_enterpriseid = t15.sys_enterpriseid
                    on t1.sys_enterpriseid = t15.sys_enterpriseid
          left join (select t5.sys_enterpriseid,
          left join (select t5.sys_enterpriseid,
@@ -564,7 +643,8 @@ from sys_enterprise t1
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t2.amount, 0) amount2,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t3.amount, 0) amount3,
                            ifnull(t4.amount, 0) amount4,
                            ifnull(t4.amount, 0) amount4,
-                           ifnull(t6.amount, 0) amount5
+                           ifnull(t6.amount, 0) amount5,
+                           ifnull(t7.amount, 0) amount6
                     from sys_enterprise t5
                     from sys_enterprise t5
                              left join (select sys_enterpriseid, sum(amount) amount
                              left join (select sys_enterpriseid, sum(amount) amount
                                         from cashbill t1
                                         from cashbill t1
@@ -589,6 +669,11 @@ from sys_enterprise t1
                                         where t1.sa_accountclassid = 98
                                         where t1.sa_accountclassid = 98
                                           and t1.period = '12'
                                           and t1.period = '12'
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                         group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                             left join (select sys_enterpriseid, sum(amount) amount
+                                        from cashbill t1
+                                        where t1.sa_accountclassid = 96
+                                          and t1.period = '12'
+                                        group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                     where t5.siteid = $siteid$) t16
                     where t5.siteid = $siteid$) t16
                    on t1.sys_enterpriseid = t16.sys_enterpriseid
                    on t1.sys_enterpriseid = t16.sys_enterpriseid
          inner join (select t5.sys_enterpriseid,
          inner join (select t5.sys_enterpriseid,
@@ -596,7 +681,8 @@ from sys_enterprise t1
                             ifnull(t2.amount, 0) amount2,
                             ifnull(t2.amount, 0) amount2,
                             ifnull(t3.amount, 0) amount3,
                             ifnull(t3.amount, 0) amount3,
                             ifnull(t4.amount, 0) amount4,
                             ifnull(t4.amount, 0) amount4,
-                            ifnull(t6.amount, 0) amount5
+                            ifnull(t6.amount, 0) amount5,
+                            ifnull(t7.amount, 0) amount6
                      from sys_enterprise t5
                      from sys_enterprise t5
                               left join (select sys_enterpriseid, sum(amount) amount
                               left join (select sys_enterpriseid, sum(amount) amount
                                          from cashbill t1
                                          from cashbill t1
@@ -617,6 +703,10 @@ from sys_enterprise t1
                                          from cashbill t1
                                          from cashbill t1
                                          where t1.sa_accountclassid = 98
                                          where t1.sa_accountclassid = 98
                                          group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
                                          group by sys_enterpriseid) t6 on t5.sys_enterpriseid = t6.sys_enterpriseid
+                              left join (select sys_enterpriseid, sum(amount) amount
+                                         from cashbill t1
+                                         where t1.sa_accountclassid = 96
+                                         group by sys_enterpriseid) t7 on t5.sys_enterpriseid = t7.sys_enterpriseid
                      where t5.siteid = $siteid$
                      where t5.siteid = $siteid$
                          and (t1.amount>=0 or t2.amount>= 0 or t3.amount>= 0 or
                          and (t1.amount>=0 or t2.amount>= 0 or t3.amount>= 0 or
                               t4.amount>= 0) or t6.amount>= 0) t17 on t1.sys_enterpriseid = t17.sys_enterpriseid
                               t4.amount>= 0) or t6.amount>= 0) t17 on t1.sys_enterpriseid = t17.sys_enterpriseid