Browse Source

成本报表 辅料余下

liuchaohui 2 years ago
parent
commit
6d1cc076fa

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

@@ -21,7 +21,9 @@
 		case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
 		else tab2.jian-isnull(tab1.purchaseQuantity,0) end
 		as ingredientsTransferQuantity,
-				tab.usageQuantity-isnull(tab1.purchaseQuantity,0) as ingredientsRemainingQuantity,
+		case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity
+		else (tab2.jian-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end
+		as ingredientsRemainingQuantity,
 				(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,
 				case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
 				else (tab2.jian-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost
@@ -83,7 +85,9 @@
 				case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
 				else tab2.jian-isnull(tab1.purchaseQuantity,0) end
 				as ingredientsTransferQuantity,
-				tab.usageQuantity-isnull(tab1.purchaseQuantity,0) as ingredientsRemainingQuantity,
+				case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then isnull(tab1.purchaseQuantity,0)-tab.usageQuantity
+		else (tab2.jian-isnull(tab1.purchaseQuantity,0))+isnull(tab1.purchaseQuantity,0)-tab.usageQuantity end
+		as ingredientsRemainingQuantity,
 				(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,case when tab2.jian-isnull(tab1.purchaseQuantity,0) <![CDATA[<=]]> 0 then 0
 				else (tab2.jian-isnull(tab1.purchaseQuantity,0))*tab.cost end as transferCost
 		from