Browse Source

首页账户余额及毛利润分析修改-按本位币统计

dingyl 7 years ago
parent
commit
0a71841c8e

+ 7 - 4
applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml

@@ -112,7 +112,9 @@
             #账户余额
             (
             select ifnull(balance_,0) balanceTotal from (
-            select sum(ifnull(bk_thisamount,0)) balance_ from bankinformation where companyid=#{componyId})d
+            select sum(thisamount*(case when ifnull(cr_rate,0)=0 then 1 else ifnull(cr_rate,0) end)) balance_ from
+            (select bk_currency,sum(ifnull(bk_thisamount,0)) thisamount from bankinformation where companyid=#{componyId}
+              group by bk_currency) t left join currencys on bk_currency=cr_name and currencys.companyId=#{componyId} )d
             )d1
             );
     </select>
@@ -122,7 +124,7 @@
       (
         #前5数据
         select group_concat('{"x":"',custname,'","y":',profit/10000,',"z":"',shortname,'"}') five_profit   from (
-        select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
+        select sum((ifnull(pd_netprice,0)*(case when ifnull(pi_rate,0)=0 then 1 else pi_rate end )- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
         pi_custcode,max(pi_custname) custname,max(ifnull(cu_shortname,'')) shortname  from prodinout left join prodiodetail on pi_id=pd_piid left join customer on cu_id=pi_custid
         where
         pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId}
@@ -133,13 +135,14 @@
 		select concat('{"z":"其它","x":"其它","y":',(all_profit - five_profit)/10000,'}') other_profit from (
         #总共
         (
-        select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) all_profit
+        select sum((ifnull(pd_netprice,0)*(case when ifnull(pi_rate,0)=0 then 1 else pi_rate end )- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) all_profit
         from prodinout left join prodiodetail on pi_id=pd_piid
         where
         pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId} )a1_,
         #前5总和
         (
-        select sum(profit) five_profit from (select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
+        select sum(profit) five_profit from (select sum((ifnull(pd_netprice,0)*(case when ifnull(pi_rate,0)=0 then 1 else pi_rate end )
+        - ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
         pi_custcode,max(pi_custname) custname,prodinout.companyid from prodinout left join prodiodetail on pi_id=pd_piid left join customer on cu_id=pi_custid
          where
         pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId}