فهرست منبع

成本报表 102发运 人民币单价美元单价

liuchaohui 1 سال پیش
والد
کامیت
862e7c5a4d

+ 11 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationShipdetailMapper.xml

@@ -68,9 +68,9 @@
 			avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
 			sum(shs.iSum) as exportPrice,
 			sum(iNatSum) as rmbAmount,
-			max(so.iTax) as procesUnitPriceusd,
-			max(so.iTax)*sh.iExchRate as procesUnitPricermb,
-			max(so.iNatTax) * sum(shs.iQuantity) as processCost,
+			avg(so.iOriTaxCost) as procesUnitPriceusd,
+			avg(so.iOriTaxCost)*sh.iExchRate as procesUnitPricermb,
+			avg(so.iNatUnitPrice) * sum(shs.iQuantity) as processCost,
 			v.cVenName AS processUnit
 		FROM
 			UFDATA_102_2021.dbo.SaleBillVouch sh
@@ -78,19 +78,22 @@
 			LEFT JOIN UFDATA_102_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
 			LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 		JOIN (
-			 SELECT  supplierCode,s.iSOsID,s.id ,o.iTax,o.iNatTax,s.cdefine22,s.cDefine28
+			 SELECT  max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,
+					avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
 									 SELECT
-									 om.cCode AS omCode, od.csoordercode,
-									 om.MOID AS ompoId,od.MODetailsID AS ompoIdItem,
-									 om.cVenCode AS supplierCode,od.cInvCode,od.isosid,od.iQuantity ,od.iTax,od.iNatTax
+									 max(od.csoordercode) as csoordercode,
+									 max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity ,
+									 avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice
 									 FROM
 									 UFDATA_103_2021.dbo.OM_MOMain om
 									 inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
+									 left join UFDATA_103_2021.dbo.PurBillVouchs bi  on bi.iPOsID=od.MODetailsID
 									 WHERE
 									 om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%')
+									 GROUP BY od.cInvCode,od.isosid
 									 ) o ON a.isosid  = o.isosid AND a.cInvCode = o.cInvCode
 						inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
 						inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode
@@ -100,6 +103,7 @@
 						inner join UFDATA_102_2021.dbo.SO_SODetails s on s.iSOsID=g.iorderdid
 						inner join UFDATA_102_2021.dbo.so_somain ss on ss.id=s.id
 						WHERE b.cCusCode in ('T020001','0001') and ss.cCusCode not in ('T020001','0001') and c.cInvCcode like '19%'
+						GROUP BY s.iSOsID
 			) so ON so.iSOsID = rd.iorderdid
 		LEFT JOIN UFDATA_102_2021.dbo.Vendor v ON so.supplierCode= v.cVenCode
 		group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName