Browse Source

成本报表 辅料 (不)含税金额

liuchaohui 1 năm trước cách đây
mục cha
commit
d0ee2abfc4

+ 22 - 23
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationIngredientMapper.xml

@@ -111,16 +111,15 @@
 						union all
 
 						 select
-									pod.cInvCode,pod.iorderdid,max(bi.iMoney) as rmbAmount,max(bi.iOriMoney) as usdAmount
-									,max(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,max(bi.iCost) as iCost
-						 from UFDATA_902_2021.dbo.SO_SOMain so
-						 join UFDATA_902_2021.dbo.SO_SODetails sd on so.id=sd.id
+						pod.cInvCode,pod.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
+						,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
+						 from UFDATA_901_2021.dbo.PO_Pomain pom
+						 join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
+						 join UFDATA_902_2021.dbo.SO_SODetails sd on sd.cSOCode=pom.cpoid and sd.irowno=pod.ivouchrowno
 						 join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
 						 join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID  = pm.POID
 						 join UFDATA_902_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
 						 join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
-						 join UFDATA_901_2021.dbo.PO_Pomain pom on so.cSOCode = pom.cPOID
-						 join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
 						 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
 						 GROUP BY pod.cInvCode,pod.iorderdid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
@@ -184,16 +183,15 @@
 						union all
 
 						 select
-									pod.cInvCode,pod.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
-									,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
-						 from UFDATA_902_2021.dbo.SO_SOMain so
-						 join UFDATA_902_2021.dbo.SO_SODetails sd on so.id=sd.id
+						pod.cInvCode,pod.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
+						,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
+						 from UFDATA_901_2021.dbo.PO_Pomain pom
+						 join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
+						 join UFDATA_902_2021.dbo.SO_SODetails sd on sd.cSOCode=pom.cpoid and sd.irowno=pod.ivouchrowno
 						 join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
 						 join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID  = pm.POID
 						 join UFDATA_902_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
 						 join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
-						 join UFDATA_901_2021.dbo.PO_Pomain pom on so.cSOCode = pom.cPOID
-						 join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
 						 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
 						 GROUP BY pod.cInvCode,pod.iorderdid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
@@ -319,17 +317,18 @@
 
 						union all
 
-					 select pod.cInvCode,pod.iorderdid,max(bi.iCost) as iCost
-					 from UFDATA_902_2021.dbo.SO_SOMain so
-					 join UFDATA_902_2021.dbo.SO_SODetails sd on so.id=sd.id
-					 join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
-					 join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID  = pm.POID
-					 join UFDATA_902_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
-					 join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
-					 join UFDATA_901_2021.dbo.PO_Pomain pom on so.cSOCode = pom.cPOID
-					 join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
-					 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
-					 GROUP BY pod.cInvCode,pod.iorderdid
+					 select
+						pod.cInvCode,pod.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
+						,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
+						 from UFDATA_901_2021.dbo.PO_Pomain pom
+						 join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID  = pom.POID
+						 join UFDATA_902_2021.dbo.SO_SODetails sd on sd.cSOCode=pom.cpoid and sd.irowno=pod.ivouchrowno
+						 join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
+						 join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID  = pm.POID
+						 join UFDATA_902_2021.dbo.PurBillVouchs bi  on bi.iPOsID=pd.ID
+						 join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
+						 where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
+						 GROUP BY pod.cInvCode,pod.iorderdid
 				 ) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
 		WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
 					and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'