|
|
@@ -726,8 +726,11 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
}
|
|
|
//出库
|
|
|
else {
|
|
|
- //修改源出库信息
|
|
|
- this.updateOutboundPri(inOutRecordVOList);
|
|
|
+ //出库类型不是销退出库在反写源单出库信息
|
|
|
+ if(!Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVOList.get(0).getInventoryDocCode())){
|
|
|
+ //修改源出库信息
|
|
|
+ this.updateOutboundPri(inOutRecordVOList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1049,6 +1052,7 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
if (inventoryBatchResponseList.size() > 0) {
|
|
|
//数量
|
|
|
BigDecimal qty = inOutRecordVO.getIntoQty().abs();
|
|
|
+ BigDecimal notEnoughAmount = BigDecimal.ZERO;
|
|
|
for (InventoryBatchResponse inventoryBatchResponse : inventoryBatchResponseList) {
|
|
|
InventoryBatchVO inventoryBatchVO = new InventoryBatchVO();
|
|
|
//判断是否为最后一次扣减当前条库存
|
|
|
@@ -1063,8 +1067,6 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
//清零标识
|
|
|
inventoryBatchVO.setZeroFlag(true);
|
|
|
inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
|
|
|
- //数量
|
|
|
- inOutRecordVO.setIntoQty(qty);
|
|
|
//单价
|
|
|
inOutRecordVO.setPriceInto(inventoryBatchResponse.getCostPrice());
|
|
|
//金额
|
|
|
@@ -1084,8 +1086,6 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
//清零标识
|
|
|
inventoryBatchVO.setZeroFlag(false);
|
|
|
inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
|
|
|
- //数量
|
|
|
- inOutRecordVO.setIntoQty(qty);
|
|
|
//单价
|
|
|
inOutRecordVO.setPriceInto(inventoryBatchResponse.getCostPrice());
|
|
|
//金额
|
|
|
@@ -1105,35 +1105,35 @@ public class InventoryService extends BaseService<Inventory> {
|
|
|
inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
|
|
|
//数量、金额每次更新完要重新运算
|
|
|
qty = qty.subtract(inventoryBatchResponse.getInvQty());
|
|
|
- //数量
|
|
|
- inOutRecordVO.setIntoQty(qty);
|
|
|
- //单价
|
|
|
- inOutRecordVO.setPriceInto(inventoryBatchResponse.getCostPrice());
|
|
|
- //金额
|
|
|
- inOutRecordVO.setIntoAmt(inOutRecordVO.getIntoQty().multiply(inventoryBatchResponse.getCostPrice()));
|
|
|
+ notEnoughAmount = notEnoughAmount.add(qty.multiply(inventoryBatchResponse.getCostPrice()));
|
|
|
}
|
|
|
}
|
|
|
- //todo 2024年5月20日15:46:01 库存批次有几条出库成本就有几条
|
|
|
+
|
|
|
//region 出库成本
|
|
|
+ //todo 2024年5月20日15:46:01 库存批次有几条出库成本就有几条
|
|
|
//除了销售退货出库 其他类型出库要新建出库成本 采购退货 出库成本 正数
|
|
|
if (!Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
|
|
|
Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
|
|
|
//存货批次明细ID
|
|
|
inOutRecordVO.setBatchId(inventoryBatchResponse.getBatchId());
|
|
|
this.insertOutboundItemCost(inOutRecordVO);
|
|
|
- //region 反写本次办理出库的 出库成本金额和成本单价
|
|
|
- OutboundItem outboundItem = new OutboundItem();
|
|
|
- outboundItem.setItemId(inOutRecordVO.getBiznisItemId());
|
|
|
- outboundItem.setCostAmt(inOutRecordVO.getIntoAmt());
|
|
|
- outboundItem.setCostPrice(inOutRecordVO.getIntoAmt().divide(inOutRecordVO.getIntoQty(), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
- outboundItemMapper.update(outboundItem,
|
|
|
- new UpdateWrapper<OutboundItem>().lambda()
|
|
|
- .eq(OutboundItem::getItemId, UUID.fromString(outboundItem.getItemId()))
|
|
|
- );
|
|
|
- //endregion
|
|
|
}
|
|
|
//endregion
|
|
|
+
|
|
|
}
|
|
|
+ //region 反写本次办理出库的 出库成本金额和成本单价
|
|
|
+ if (!Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
|
|
|
+ Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
|
|
|
+ OutboundItem outboundItem = new OutboundItem();
|
|
|
+ outboundItem.setItemId(inOutRecordVO.getBiznisItemId());
|
|
|
+ outboundItem.setCostAmt(notEnoughAmount.compareTo(BigDecimal.ZERO)>0 ? notEnoughAmount : inOutRecordVO.getIntoAmt());
|
|
|
+ outboundItem.setCostPrice(outboundItem.getCostAmt().divide(inOutRecordVO.getIntoQty(), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ outboundItemMapper.update(outboundItem,
|
|
|
+ new UpdateWrapper<OutboundItem>().lambda()
|
|
|
+ .eq(OutboundItem::getItemId, UUID.fromString(outboundItem.getItemId()))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
} else {
|
|
|
if (inOutRecordVO.getSkuId() != null) {
|
|
|
List<GoodsSkuResponse> goodsSkuResponses = goodsSkuMapper.selectByCond(new GoodsSkuQuery().setSkuId(inOutRecordVO.getSkuId()));
|