|  | @@ -17,13 +17,13 @@
 | 
	
		
			
				|  |  |  	</select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	<select id="queryByCostIngredient" resultType="org.jeecg.modules.cost.entity.SyCostAllocationIngredient">
 | 
	
		
			
				|  |  | -		select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,tab2.jian-isnull(tab1.purchaseQuantity,0) as ingredientsTransferQuantity,
 | 
	
		
			
				|  |  | +		select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,isnull(tab1.purchaseQuantity,0)-tab2.jian as ingredientsTransferQuantity,
 | 
	
		
			
				|  |  |  				isnull(tab1.purchaseQuantity,0)-tab.usageQuantity as ingredientsRemainingQuantity,
 | 
	
		
			
				|  |  | -				(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss
 | 
	
		
			
				|  |  | +				(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
 | 
	
		
			
				|  |  |  		from 
 | 
	
		
			
				|  |  |  		(
 | 
	
		
			
				|  |  |  				select oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iQuantity) as usageQuantity
 | 
	
		
			
				|  |  | -				 ,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax
 | 
	
		
			
				|  |  | +				 ,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax,sum(pb.iCost) as cost
 | 
	
		
			
				|  |  |  				from UFDATA_903_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  				join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
		
			
				|  |  |  				join UFDATA_903_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
 | 
	
	
		
			
				|  | @@ -74,13 +74,13 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		union all
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,tab2.jian-isnull(tab1.purchaseQuantity,0) as ingredientsTransferQuantity,
 | 
	
		
			
				|  |  | +		select tab.*,isnull(tab1.purchaseQuantity,0) as purchaseQuantity,isnull(tab1.purchaseQuantity,0)-tab2.jian as ingredientsTransferQuantity,
 | 
	
		
			
				|  |  |  				isnull(tab1.purchaseQuantity,0)-tab.usageQuantity as ingredientsRemainingQuantity,
 | 
	
		
			
				|  |  | -				(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss
 | 
	
		
			
				|  |  | +				(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
 | 
	
		
			
				|  |  |  		from
 | 
	
		
			
				|  |  |  		(
 | 
	
		
			
				|  |  |  				select oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iQuantity) as usageQuantity
 | 
	
		
			
				|  |  | -				 ,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax
 | 
	
		
			
				|  |  | +				 ,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax,sum(pb.iCost) as cost
 | 
	
		
			
				|  |  |  				from UFDATA_901_2021.dbo.om_momain om
 | 
	
		
			
				|  |  |  				join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
 | 
	
		
			
				|  |  |  				join UFDATA_901_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
 |