浏览代码

成本分配调整

zengtx 1 年之前
父节点
当前提交
98c914acd5

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationFabricMapper.xml

@@ -200,7 +200,7 @@ where trim(cSOCode) like CONCAT(#{code},'%') and cSOCode not like '%样%'
 		from UFDATA_101_2021.dbo.PO_POmain om
 		join UFDATA_101_2021.dbo.PO_PODetails od on om.poid=od.poid
 		join UFDATA_101_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
-		WHERE om.cVerifier is not null  and omi.cInvCcode like '19%'
+		WHERE om.cVerifier is not null  and (om.cCloser is null or om.cCloser!='asuser')
 		and om.cPOID like CONCAT(#{code},'%')
 		)
 		GROUP BY i.cInvName,rs.cBatch,rs.cFree1
@@ -249,7 +249,7 @@ where trim(cSOCode) like CONCAT(#{code},'%') and cSOCode not like '%样%'
 		from UFDATA_103_2021.dbo.PO_POmain om
 		join UFDATA_103_2021.dbo.PO_PODetails od on om.poid=od.poid
 		join UFDATA_103_2021.dbo.Inventory omi on omi.cInvCode=od.cInvCode
-		WHERE om.cVerifier is not null and (om.cCloser is null or om.cCloser!='asuser') and omi.cInvCcode like '19%'
+		WHERE om.cVerifier is not null and (om.cCloser is null or om.cCloser!='asuser')
 		and om.cPOID like CONCAT(#{code},'%')
 		)
 		GROUP BY i.cInvName,rs.cBatch,rs.cFree1

+ 8 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostAllocationMapper.xml

@@ -214,9 +214,15 @@ select omi.cInvName as cInvName,sum(pbs.iOriSum) as iOriSum,sum(round(pbs.iOriSu
 select t.salerIquantity from (
 select sum(iquantity) as salerIquantity from UFDATA_101_2021.dbo.SO_SODetails where csocode = #{csocode}
 union all
-select sum(iquantity) as salerIquantity from UFDATA_102_2021.dbo.SO_SODetails where csocode = #{csocode}
+select sum(iquantity) as salerIquantity from UFDATA_102_2021.dbo.SO_SODetails a
+		inner join UFDATA_102_2021.dbo.SO_SOMain b on a.ID = b.ID
+	inner JOIN UFDATA_102_2021.dbo.Customer cu ON b.cCusCode = cu.cCusCode
+ WHERE b.cCusCode not in ('0001','T020001') and a.csocode = #{csocode}
 union all
-select sum(iquantity) as salerIquantity from UFDATA_103_2021.dbo.SO_SODetails where csocode = #{csocode}
+select sum(iquantity) as salerIquantity from UFDATA_103_2021.dbo.SO_SODetails a
+		inner join UFDATA_102_2021.dbo.SO_SOMain b on a.ID = b.ID
+	inner JOIN UFDATA_102_2021.dbo.Customer cu ON b.cCusCode = cu.cCusCode
+ WHERE b.cCusCode not in ('0001','T020001') and a.csocode = #{csocode}
 ) as t where t.salerIquantity is not null
 
     </select>

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

@@ -22,11 +22,11 @@ select t.* from (
 case when max(sbv.cexch_name)='人民币' then max(pbv.iOriTaxCost) else round(max(pbv.iOriTaxCost)*max(pbv.cExchRate),4) end as procesUnitPricermb,
 			case when max(sbv.cexch_name)='人民币' then 0 else max(pbv.iOriTaxCost) end as procesUnitPriceusd,
 		sum(pbv.processCost) as processCost,
-			case when max(sbv.cexch_name)='人民币' then 0 else max(pbv.iOriTaxCost) end * sum(pbv.iQuantity) as processCostUsd,
+			case when max(sbv.cexch_name)='人民币' then 0 else sum(pbv.iOriSum) end as processCostUsd,
 			max(v.cVenName) AS processUnit
 
 from
-(select pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,sum(pbvs.iPBVQuantity) as iQuantity,ommo.ccode,max(sd.cdefine22) as cdefine22,max(sd.cdefine28) as cdefine28,max(pbvs.iOriTaxCost) as iOriTaxCost,ommo.cVenCode as cVenCode,max(pbv.cExchRate) as cExchRate,sum(pbvs.iSum) as processCost
+(select pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,sum(pbvs.iPBVQuantity) as iQuantity,ommo.ccode,max(sd.cdefine22) as cdefine22,max(sd.cdefine28) as cdefine28,max(pbvs.iOriTaxCost) as iOriTaxCost,ommo.cVenCode as cVenCode,max(pbv.cExchRate) as cExchRate,sum(pbvs.iSum) as processCost,sum(pbvs.iOriSum) as iOriSum
 from UFDATA_101_2021.dbo.PurBillVouchs pbvs left join UFDATA_101_2021.dbo.PurBillVouch pbv
 on pbv.PBVID=pbvs.PBVID
 left join UFDATA_101_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=pbvs.iPOsID
@@ -60,7 +60,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 			case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end as procesUnitPricermb,
 			case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
 				case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end * sum(shs.iQuantity) as processCost,
-			case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
+			case when max(so.cexch)='人民币' then 0 else sum(so.iOriSum) end as processCostUsd,
 			v.cVenName AS processUnit
 		FROM
 			UFDATA_102_2021.dbo.SaleBillVouch sh
@@ -69,7 +69,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 			LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 		JOIN (
 			 SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
-					max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
+					max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28,sum(o.iOriSum) as iOriSum
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
@@ -78,7 +78,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 									 max(pb.cExchRate) as cExchRate,
 									 od.csoordercode as csoordercode,
 									 max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
-									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
+									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice,sum(bi.iOriSum) as iOriSum
 									 FROM
 									 UFDATA_103_2021.dbo.OM_MOMain om
 									 inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
@@ -119,7 +119,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 		case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
 
 		case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end * sum(shs.iQuantity) as processCost,
-		case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
+		case when max(so.cexch)='人民币' then 0 else sum(so.iOriSum) end as processCostUsd,
 		v.cVenName AS processUnit
 		 FROM
 			UFDATA_101_2021.dbo.SaleBillVouch sh
@@ -128,7 +128,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 		  JOIN (
 			 SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
-					max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
+					max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28,sum(o.iOriSum) as iOriSum
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
@@ -137,7 +137,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
 									 max(pb.cExchRate) as cExchRate,
 									 od.csoordercode as csoordercode,
 									 max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
-									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
+									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice,sum(bi.iOriSum) as iOriSum
 									 FROM
 									 UFDATA_103_2021.dbo.OM_MOMain om
 									 inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
@@ -179,7 +179,7 @@ UNION ALL
 		case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
 
 		case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end * sum(shs.iQuantity) as processCost,
-		case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
+		case when max(so.cexch)='人民币' then 0 else sum(so.iOriSum)  end as processCostUsd,
 		v.cVenName AS processUnit
 		 FROM
 			UFDATA_101_2021.dbo.SaleBillVouch sh
@@ -188,7 +188,7 @@ UNION ALL
 			LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
 		  JOIN (
 			 SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s1.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
-					max(o.iNatUnitPrice) as iNatUnitPrice,max(s1.cdefine22) as cdefine22,max(s1.cDefine28) as cDefine28
+					max(o.iNatUnitPrice) as iNatUnitPrice,max(s1.cdefine22) as cdefine22,max(s1.cDefine28) as cDefine28,sum(o.iOriSum) as iOriSum
 						FROM  UFDATA_103_2021.dbo.SO_SODetails a
 						inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
 						inner JOIN (
@@ -197,7 +197,7 @@ UNION ALL
 									 max(pb.cExchRate) as cExchRate,
 									 od.csoordercode as csoordercode,
 									 max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
-									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
+									 max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice,sum(bi.iOriSum) as iOriSum
 									 FROM
 									 UFDATA_103_2021.dbo.OM_MOMain om
 									 inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID