wanglang 3 päivää sitten
vanhempi
commit
7346189b3f

+ 8 - 3
trade-service/src/main/java/com/trade/service/trade/purchaseorder/service/impl/PurchaseOrderServiceImpl.java

@@ -204,6 +204,7 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
             if (purchaseContract == null) {
                 return false;
             }
+            purchaseOrder.setCurrency(purchaseContract.getContractCurrency());
             purchaseOrder.setPurchaseContractNo(purchaseContract.getContractNo());
             ContractTerms contractTerms = contractTermsService.getByContractIdAndType(purchaseContract.getId(),
                     ConstantUtil.PURCHASE_CONTRACT_CODE);
@@ -215,9 +216,13 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
                     .eq(PurchaseCommodity::getPurchaseContractId, purchaseContract.getId())
                     .eq(PurchaseCommodity::getSalesContractId, 0).eq(PurchaseCommodity::getDeleted, 0).list();
             for (PurchaseOrderCommodity commodity : commodities) {
-                purchaseCommodities.stream()
-                        .filter(p -> p.getSalesCommodityId().equals(commodity.getSalesCommodityId())).findAny()
-                        .ifPresent(purchaseCommodity -> commodity.setPriceUnit(purchaseCommodity.getPriceUnit()));
+                PurchaseCommodity purchaseCommodity  = purchaseCommodities.stream()
+                        .filter(p -> p.getSalesCommodityId().equals(commodity.getSalesCommodityId())).findAny().orElse(null);
+                if (purchaseCommodity != null) {
+                    commodity.setPriceUnit(purchaseCommodity.getPriceUnit());
+                    commodity.setAmount(purchaseCommodity.getTotalAmount());
+                    commodity.setCurrency(purchaseCommodity.getCurrency());
+                }
             }
             this.baseMapper.insert(purchaseOrder);
             commodities.forEach(commodity -> commodity.setPurchaseOrderId(purchaseOrder.getId()));