|
@@ -265,12 +265,18 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
|
|
|
@Override
|
|
|
public void updatePurchaseBomArrivalQuantity(Long purchaseId, List<InOutStorageBom> inOutStorageBomList) {
|
|
|
for (InOutStorageBom inOutStorageBom : inOutStorageBomList) {
|
|
|
- PurchaseBom bom = purchaseBomService.getOne(q -> q.eq(PurchaseBom::getPurchaseId, purchaseId).eq(PurchaseBom::getBomSpecId, inOutStorageBom.getBomSpecId()));
|
|
|
+ PurchaseBom bom = purchaseBomService.getOne(q -> q
|
|
|
+ .eq(PurchaseBom::getPurchaseId, purchaseId)
|
|
|
+ .eq(PurchaseBom::getBomSpecId, inOutStorageBom.getBomSpecId()));
|
|
|
if (ObjectUtil.isNotEmpty(bom)) {
|
|
|
- purchaseBomService.update(q -> q.eq(PurchaseBom::getId, bom.getId()).set(PurchaseBom::getArrivalQuantity, bom.getArrivalQuantity().add(inOutStorageBom.getQuantity())));
|
|
|
+ purchaseBomService.update(q -> q
|
|
|
+ .eq(PurchaseBom::getId, bom.getId())
|
|
|
+ .set(PurchaseBom::getArrivalQuantity, bom.getArrivalQuantity().add(inOutStorageBom.getQuantity())));
|
|
|
|
|
|
// 查询当前采购在途数量
|
|
|
- long count = purchaseBomService.count(q -> q.eq(PurchaseBom::getPurchaseId, purchaseId).apply("(purchase_quantity + return_quantity) > arrival_quantity"));
|
|
|
+ long count = purchaseBomService.count(q -> q
|
|
|
+ .eq(PurchaseBom::getPurchaseId, purchaseId)
|
|
|
+ .apply("(purchase_quantity + return_quantity) > arrival_quantity"));
|
|
|
if (count == 0) {
|
|
|
// 如果为0,将入库状态设置为已完成
|
|
|
this.update(q -> q.set(Purchase::getStorageStatus, StatusConstant.YES)
|
|
@@ -292,7 +298,9 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
|
|
|
this.updateById(purchase);
|
|
|
|
|
|
// 合同终止将bom到货数量设置为采购数量
|
|
|
- List<PurchaseBom> purchaseBomList = purchaseBomService.list(q -> q.eq(PurchaseBom::getPurchaseId, id).apply("(purchase_quantity + return_quantity) > arrival_quantity"));
|
|
|
+ List<PurchaseBom> purchaseBomList = purchaseBomService.list(q -> q
|
|
|
+ .eq(PurchaseBom::getPurchaseId, id)
|
|
|
+ .apply("(purchase_quantity + return_quantity) > arrival_quantity"));
|
|
|
for (PurchaseBom purchaseBom : purchaseBomList) {
|
|
|
purchaseBom.setArrivalQuantity(purchaseBom.getPurchaseQuantity().add(purchaseBom.getReturnQuantity()));
|
|
|
}
|
|
@@ -388,15 +396,16 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
|
|
|
|
|
|
purchase.setTotalAmountIncludingTax(purchase.getTotalAmountIncludingTax().add(new BigDecimal(item.getTotalAmount())));
|
|
|
// 计算不含税总金额
|
|
|
- BigDecimal totalAmountIncludingTax = purchaseBom.getUnitPrice().divide(new BigDecimal("1.1"), 4, RoundingMode.HALF_UP).multiply(purchaseBom.getPurchaseQuantity());
|
|
|
+ BigDecimal totalAmountIncludingTax = purchaseBom.getUnitPrice()
|
|
|
+ .divide(new BigDecimal("1.1"), 4, RoundingMode.HALF_UP)
|
|
|
+ .multiply(purchaseBom.getPurchaseQuantity());
|
|
|
purchase.setTotalAmountExcludingTax(purchase.getTotalAmountExcludingTax().add(totalAmountIncludingTax));
|
|
|
|
|
|
- // bom成本价为空时,默认为采购bom单价
|
|
|
- if (bomSpec.getCostPrice() == null) {
|
|
|
- bomSpec.setCostPrice(purchaseBom.getUnitPrice());
|
|
|
- bomSpec.setInternalSellingPrice(purchaseBom.getUnitPrice());
|
|
|
- bomSpecList.add(bomSpec);
|
|
|
- }
|
|
|
+ // 保存最新的合同价格
|
|
|
+ bomSpec.setCostPrice(purchaseBom.getUnitPrice());
|
|
|
+ bomSpec.setInternalSellingPrice(purchaseBom.getUnitPrice());
|
|
|
+ bomSpecList.add(bomSpec);
|
|
|
+
|
|
|
return purchaseBom;
|
|
|
}).collect(Collectors.toList());
|
|
|
purchaseList.add(purchase);
|