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

毛利润分析表数据修改

hy 6 жил өмнө
parent
commit
cb5048eb61

+ 38 - 105
applications/money/money-server/src/main/resources/mapper/ProfitdetailMapper.xml

@@ -20,125 +20,58 @@
   </sql>
 
   <select id="selectByCondition" parameterType="java.lang.Long" resultMap="BaseResultMap">
-   SELECT
-	a.pi_custcode,
-	a.pi_custname,
-	a.cu_type,
-	a.cu_sellername,
-	  IFNULL(a.saamount*a.pi_rate,0) as saamount,
-	  IFNULL(a.netamount*a.pi_rate,0) as netamount,
-	  IFNULL(a.costamount*a.pi_rate,0) as costamount,
-	  IFNULL(SUM(a.netamount*a.pi_rate - a.costamount*a.pi_rate),0) as profit,
-	  IFNULL((SUM(a.netamount*a.pi_rate - a.costamount*a.pi_rate)/IFNULL(a.netamount*a.pi_rate,SUM(a.netamount*a.pi_rate - a.costamount*a.pi_rate))),0) as profitpresent
-
-FROM
-	(
-		SELECT
-	        pi_rate,
-			pi_custcode,
-			pi_custname,
-	        cu_type,
-			cu_sellername,
-	  SUM(
-	  IFNULL(pd_sendprice,0) * (IFNULL(pd_outqty,0) - IFNULL(pd_inqty,0))
-	  ) AS saamount,
-	  SUM(
-	  IFNULL(pd_netprice,0) * (IFNULL(pd_outqty,0) - IFNULL(pd_inqty,0))
-	  ) AS netamount,
-	  SUM(
-	  IFNULL(pd_price,0) * (IFNULL(pd_outqty,0) - IFNULL(pd_inqty,0))
-	  ) AS costamount
-		FROM
-			prodinout,
-			prodiodetail,
-			customer
-    <where>
-      <if test="con != null">
-        ${con}
-      </if>
-      <if test="companyId != null">
-        and  prodinout.companyid = #{companyId}
-      </if>
-    </where>
-		and	pi_id = pd_piid
-		AND pi_custid = cu_id and pi_status = '已审核' and
-prodinout.companyid= prodiodetail.companyid
-		GROUP BY
-			pi_custcode,
-			pi_custname,
-	        cu_type,
-			cu_sellername,
-	        pi_rate
-	) a
-	  where saamount + netamount + costamount != 0
-	  GROUP BY
-	        a.pi_rate,
-			a.pi_custcode,
-			a.pi_custname,
-	        a.cu_type,
-			a.cu_sellername
-	  ORDER BY a.pi_custname asc,a.pi_custname desc
+	  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>
 
 	<select id="selectCalculateFields" resultType="string">
 		SELECT ${fields}
-		FROM
-		(
-		SELECT
-		a.pi_custcode,
-		a.pi_custname,
-		a.cu_type,
-		a.cu_sellername,
-		IFNULL(a.saamount,0) as saamount,
-		IFNULL(a.netamount,0) as netamount,
-		IFNULL(a.costamount,0) as costamount,
-		IFNULL(SUM(a.netamount - a.costamount),0) as profit,
-		IFNULL((SUM(a.netamount - a.costamount)/IFNULL(a.netamount,SUM(a.netamount - a.costamount))),0) as profitpresent
-		FROM
-		(
-		SELECT
+		from(
+		select
+		cu_type,
+		pi_custid,
 		pi_custcode,
 		pi_custname,
-		cu_type,
-		cu_sellername,
-		SUM( (IFNULL( pd_sendprice, 0 ) * ( IFNULL( pd_outqty, 0 ) - IFNULL( pd_inqty, 0 ) )) * ifnull(cr_rate,1) ) AS saamount,
-		SUM(
-		IFNULL(pd_netprice,0) * (IFNULL(pd_outqty,0) - IFNULL(pd_inqty,0))
-		) AS netamount,
-		SUM(
-		IFNULL(pd_price,0) * (IFNULL(pd_outqty,0) - IFNULL(pd_inqty,0))
-		) AS costamount
-		FROM
-		prodinout,
-		prodiodetail,
-		customer,
-		currencys
+		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}
+				and prodinout.companyid = #{companyId}
 			</if>
+			and pi_class in('出货单','销售退货单')
 		</where>
-		AND	pi_id = pd_piid
-		AND pi_custid = cu_id
-		AND pi_status = '已审核'
-		AND prodinout.companyid= prodiodetail.companyid
-		AND prodiodetail.companyid = prodinout.companyid
-		AND currencys.cr_name = prodinout.pi_currency
-		AND currencys.companyid = prodinout.companyid
-		GROUP BY
-		pi_custcode,
-		pi_custname,
-		cu_type,
-		cu_sellername
+		group by pi_custid,pi_custcode,pi_custname,cu_type
+		ORDER BY pi_custname asc
 		) a
-		GROUP BY
-		a.pi_custcode,
-		a.pi_custname,
-		a.cu_type,
-		a.cu_sellername)b
 	</select>
 
 </mapper>

+ 1 - 1
frontend/saas-web/app/model/report/PurchasePay.js

@@ -8,7 +8,7 @@ Ext.define('saas.model.report.PurchasePay', {
         { name: 'pbd_slcode', type: 'string' }, // 来源单号
         { name: 'pbd_slkind', type: 'string' }, // 业务类型
         { name: 'pi_nettotal', type: 'float' }, // 金额
-        { name: 'pd_total-pi_nettotal', type: 'float', // 税额
+        { name: 'pi_total-pi_nettotal', type: 'float', // 税额
             convert: function(v, rec) {
                 var t = (rec.get('pi_total') || 0.0) - (rec.get('pi_nettotal') || 0.0);
                 return Number(saas.util.BaseUtil.numberFormat(t, 2, false));

+ 0 - 18
frontend/saas-web/app/view/money/report/ProfitDetail.js

@@ -49,24 +49,6 @@ Ext.define('saas.view.money.report.ProfitDetail', {
         text: '客户名称',
         dataIndex: 'pi_custname',
         width: 200,
-    }, {
-        text: '金额(元)',
-        dataIndex: 'netamount',
-        exportFormat: 'Amount',
-        xtype: 'numbercolumn',
-        width: 0,
-        renderer : function(v, m, r) {
-            return saas.util.BaseUtil.numberFormat(v, 2, true);
-        },
-    }, {
-        text: '税额(元)',
-        dataIndex: 'saamount-netamount',
-        exportFormat: 'Amount',
-        xtype: 'numbercolumn',
-        width: 0,
-        renderer : function(v, m, r) {
-            return saas.util.BaseUtil.numberFormat(v, 2, true);
-        },
     }, {
         text: '销售金额(元)',
         dataIndex: 'saamount',

+ 21 - 2
frontend/saas-web/app/view/purchase/report/PurchasePay.js

@@ -61,11 +61,25 @@ Ext.define('saas.view.purchase.report.PurchasePay', {
         text: '税额(元)',
         xtype: 'numbercolumn',
         exportFormat: 'Amount',
-        dataIndex: 'pd_total-pi_nettotal',
+        dataIndex: 'pi_total-pi_nettotal',
         width: 120,
         renderer: function(v) {
             return saas.util.BaseUtil.numberFormat(v, 2, true);
         },
+        disableMySummary:true,
+        summaryType: 'sum',
+        summaryRenderer: function(v) {
+            return saas.util.BaseUtil.numberFormat(v, 2, true);
+        }
+    },{
+        hidden:true,
+        text: '税额(本位币)(元)',
+        dataIndex: '(pi_total-pi_nettotal)*pi_rate',
+        exportFormat: 'Amount',
+        xtype: 'numbercolumn',
+        width: 120,
+        summaryType: 'sum',
+        summaryLabel: '税额(本位币)'
     }, {
         text: '价税合计(元)',
         xtype: 'numbercolumn',
@@ -75,6 +89,11 @@ Ext.define('saas.view.purchase.report.PurchasePay', {
         renderer: function(v) {
             return saas.util.BaseUtil.numberFormat(v, 2, true);
         },
+        disableMySummary:true,
+        summaryType: 'sum',
+        summaryRenderer: function(v) {
+            return saas.util.BaseUtil.numberFormat(v, 2, true);
+        }
     }, {
         text: '付款金额(元)',
         dataIndex: 'pbd_nowbalance',
@@ -92,7 +111,7 @@ Ext.define('saas.view.purchase.report.PurchasePay', {
     },{
         hidden:true,
         text: '付款金额(本位币)(元)',
-        dataIndex: 'pbd_nowbalance_cr',
+        dataIndex: 'pbd_nowbalance*pi_rate',
         exportFormat: 'Amount',
         xtype: 'numbercolumn',
         width: 120,

+ 12 - 7
frontend/saas-web/app/view/sale/report/SaleRec.js

@@ -98,27 +98,32 @@ Ext.define('saas.view.sale.report.SaleRec', {
         summaryRenderer: function(v) {
             return saas.util.BaseUtil.numberFormat(v, 2, true);
         }
-    },{
-        hidden:true,
-        text: '价税合计(元)',
+    }, {
+        text: '收款金额(元)',
         xtype: 'numbercolumn',
         exportFormat: 'Amount',
-        dataIndex: 'pi_total*pi_rate',
+        dataIndex: 'rbd_nowbalance',
         renderer : function(v, m, r) {
             return saas.util.BaseUtil.numberFormat(v, 2, true);
         },
+        disableMySummary:true,
         summaryType: 'sum',
-        summaryLabel: '价税合计(本位币)',
         summaryRenderer: function(v) {
             return saas.util.BaseUtil.numberFormat(v, 2, true);
         }
-    }, {
+    },{
+        hidden:true,
         text: '收款金额(元)',
         xtype: 'numbercolumn',
         exportFormat: 'Amount',
-        dataIndex: 'rbd_nowbalance',
+        dataIndex: 'rbd_nowbalance*pi_rate',
         renderer : function(v, m, r) {
             return saas.util.BaseUtil.numberFormat(v, 2, true);
+        },
+        summaryType: 'sum',
+        summaryLabel: '收款金额(本位币)',
+        summaryRenderer: function(v) {
+            return saas.util.BaseUtil.numberFormat(v, 2, true);
         }
     }, {
         text: '币别',