Эх сурвалжийг харах

首页【本月收入支出】统计本位币(乘汇率)

dingyl 6 жил өмнө
parent
commit
87d7f015ed

+ 16 - 8
applications/money/money-server/src/main/resources/mapper/StatsinfoMapper.xml

@@ -39,22 +39,26 @@
                 #{si_yearmonth,jdbcType=INTEGER},
             </if>
             <if test="si_amount_pay != null" >
-                (select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
+                (select  sum(IFNULL(pd_amount,0)*(case when ifnull(pd_rate,0)=0 then 1 else pd_rate end))
+                 from paybalancedet left join paybalance on pd_pbid=pb_id
                 where paybalance.companyId= #{companyid,jdbcType=INTEGER}
                 and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED'),
             </if>
             <if test="si_amount_otherpay != null" >
-                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_osid
+                (select sum(IFNULL(os_amount,0)*(case when ifnull(os_rate,0)=0 then 1 else os_rate end))
+                from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_osid
                 where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
                 and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
             </if>
             <if test="si_amount_rec != null" >
-                (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
+                (select sum(IFNULL(rd_amount,0)*(case when ifnull(rd_rate,0)=0 then 1 else rd_rate end))
+                 from recbalancedet left join recbalance on rd_rbid=rb_id
                 where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
                 and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
             </if>
             <if test="si_amount_otherrec != null" >
-                (select  sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
+                (select  sum(IFNULL(or_amount,0)*(case when ifnull(or_rate,0)=0 then 1 else or_rate end))
+                 from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
                 where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
                 and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
             </if>
@@ -70,25 +74,29 @@
         <set >
             <if test="si_amount_pay != null" >
                 si_amount_pay =
-                (select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
+                (select sum(IFNULL(pd_amount,0)*(case when ifnull(pd_rate,0)=0 then 1 else pd_rate end))
+                from paybalancedet left join paybalance on pd_pbid=pb_id
                 where paybalance.companyId= #{companyid,jdbcType=INTEGER}
                 and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED'),
             </if>
             <if test="si_amount_otherpay != null" >
                 si_amount_otherpay =
-                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_osid
+                (select sum(IFNULL(os_amount,0)*(case when ifnull(os_rate,0)=0 then 1 else os_rate end))
+                 from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_osid
                 where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
                 and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
             </if>
             <if test="si_amount_rec != null" >
                 si_amount_rec =
-                (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
+                (select sum(IFNULL(rd_amount,0)*(case when ifnull(rd_rate,0)=0 then 1 else rd_rate end))
+                 from recbalancedet left join recbalance on rd_rbid=rb_id
                 where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
                 and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
             </if>
             <if test="si_amount_otherrec != null" >
                 si_amount_otherrec =
-                (select  sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
+                (select  sum(IFNULL(or_amount,0)*(case when ifnull(or_rate,0)=0 then 1 else or_rate end))
+                 from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
                 where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
                 and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
             </if>