|
|
@@ -25,10 +25,10 @@
|
|
|
pi_custid,
|
|
|
pi_custcode,
|
|
|
pi_custname,
|
|
|
- sum(pd_sendprice*pi_rate) as saamount,
|
|
|
- sum(pd_price) as costamount,
|
|
|
- sum(pd_sendprice*pi_rate)-sum(pd_price) as profit,
|
|
|
- (sum(pd_sendprice*pi_rate)-sum(pd_price) )/sum(pd_sendprice*pi_rate) as profitpresent
|
|
|
+ sum(pd_sendprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0))) as saamount,
|
|
|
+ sum(pd_total) as costamount,
|
|
|
+ sum(pd_netprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0)))-sum(pd_total) as profit,
|
|
|
+ (sum(pd_netprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0)))-sum(pd_total) )/sum(pd_netprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0))) as profitpresent
|
|
|
from prodiodetail
|
|
|
left join prodinout on pd_piid=pi_Id
|
|
|
left join customer on cu_id = pi_custid
|
|
|
@@ -48,29 +48,29 @@
|
|
|
<select id="selectCalculateFields" resultType="string">
|
|
|
SELECT ${fields}
|
|
|
from(
|
|
|
- select
|
|
|
- cu_type,
|
|
|
- pi_custid,
|
|
|
- pi_custcode,
|
|
|
- pi_custname,
|
|
|
- sum(pd_sendprice*pi_rate) as saamount,
|
|
|
- sum(pd_price) as costamount,
|
|
|
- sum(pd_sendprice*pi_rate)-sum(pd_price) as profit,
|
|
|
- (sum(pd_sendprice*pi_rate)-sum(pd_price) )/sum(pd_sendprice*pi_rate) as profitpresent
|
|
|
- from prodiodetail
|
|
|
- left join prodinout on pd_piid=pi_Id
|
|
|
- left join customer on cu_id = pi_custid
|
|
|
- <where>
|
|
|
- <if test="con != null">
|
|
|
- ${con}
|
|
|
- </if>
|
|
|
- <if test="companyId != null">
|
|
|
- and prodinout.companyid = #{companyId}
|
|
|
- </if>
|
|
|
- and pi_class in('出货单','销售退货单')
|
|
|
- </where>
|
|
|
- group by pi_custid,pi_custcode,pi_custname,cu_type
|
|
|
- ORDER BY pi_custname asc
|
|
|
+ select
|
|
|
+ cu_type,
|
|
|
+ pi_custid,
|
|
|
+ pi_custcode,
|
|
|
+ pi_custname,
|
|
|
+ sum(pd_sendprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0))) as saamount,
|
|
|
+ sum(pd_total) as costamount,
|
|
|
+ sum(pd_netprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0)))-sum(pd_total) as profit,
|
|
|
+ (sum(pd_netprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0)))-sum(pd_total) )/sum(pd_netprice*pi_rate*(ifnull(pd_outqty,0)-ifnull(pd_inqty,0))) as profitpresent
|
|
|
+ from prodiodetail
|
|
|
+ left join prodinout on pd_piid=pi_Id
|
|
|
+ left join customer on cu_id = pi_custid
|
|
|
+ <where>
|
|
|
+ <if test="con != null">
|
|
|
+ ${con}
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ and prodinout.companyid = #{companyId}
|
|
|
+ </if>
|
|
|
+ and pi_class in('出货单','销售退货单')
|
|
|
+ </where>
|
|
|
+ group by pi_custid,pi_custcode,pi_custname,cu_type
|
|
|
+ ORDER BY pi_custname asc
|
|
|
) a
|
|
|
</select>
|
|
|
|