Selaa lähdekoodia

合同变更公司修改

yzc 1 vuosi sitten
vanhempi
commit
89553492fb

+ 13 - 5
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -463,12 +463,20 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
                         //计算可用库存
                         availableQuantity = availableQuantity.subtract(subtract);
                     }
-                    //后<已采购 可用=可用+(前-已采)
+                    //后<已采购
                     else if (newQuantity.compareTo(inOutBo.getInStockQuantity()) < 0) {
-                        BigDecimal subtract = inOutBo.getQuantity().subtract(inOutBo.getInStockQuantity());
-
-                        //计算可用库存
-                        availableQuantity = availableQuantity.add(subtract);
+                        //前待采购数量=0 可用=可用+(前-后)
+                        if (inOutBo.getDemandPurchaseCount().compareTo(BigDecimal.ZERO) == 0) {
+                            BigDecimal subtract1 = inOutBo.getQuantity().subtract(newQuantity);//前-后
+                            availableQuantity = availableQuantity.add(subtract1);
+                        }
+                        //前待采购数量>0 可用=可用+(前-后)+(已采购 - 前待采购数量)
+                        else if (inOutBo.getDemandPurchaseCount().compareTo(BigDecimal.ZERO) > 0) {
+                            BigDecimal subtract1 = inOutBo.getQuantity().subtract(newQuantity);//前-后
+                            BigDecimal subtract2 = inOutBo.getInStockQuantity().subtract(inOutBo.getDemandPurchaseCount());//已采购 - 前待采购数量
+                            availableQuantity = availableQuantity.add(subtract1).add(subtract2);
+                        }
+                        //-------
                     }