|
|
@@ -197,10 +197,19 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
|
|
|
if (inOutboundDetail.getProductId().longValue() == product.getId().longValue()) {
|
|
|
if (InOutBoundType.INBOUND.equals(type) || InOutBoundType.OTHER_INBOUND.equals(type) || InOutBoundType.PURCHASE_INBOUND.equals(type)) {
|
|
|
//只有入库会影响成本单价
|
|
|
- if (NumberUtil.compare(product.getPrice(), DoubleConstant.zero) < 1) {
|
|
|
- product.setPrice(DoubleConstant.zero);
|
|
|
+ Double totalQty = 0.0d;
|
|
|
+ Double price = 0.0d;
|
|
|
+ if (NumberUtil.compare(product.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) > 0) {
|
|
|
+ price = NumberUtil.add(price, NumberUtil.mul(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
|
+ totalQty = NumberUtil.add(totalQty, product.getErpReserve());
|
|
|
+ }
|
|
|
+ if (NumberUtil.compare(inOutboundDetail.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(inOutboundDetail.getQty(), DoubleConstant.zero) > 0) {
|
|
|
+ price = NumberUtil.add(price, NumberUtil.mul(inOutboundDetail.getPrice(),inOutboundDetail.getQty()));
|
|
|
+ totalQty = NumberUtil.add(totalQty, inOutboundDetail.getQty());
|
|
|
+ }
|
|
|
+ if (NumberUtil.compare(totalQty, DoubleConstant.zero) > 0) {
|
|
|
+ product.setPrice(NumberUtil.div(price, totalQty));
|
|
|
}
|
|
|
- product.setPrice(NumberUtil.div(NumberUtil.add(NumberUtil.mul(product.getPrice(), product.getErpReserve()), NumberUtil.mul(inOutboundDetail.getPrice(), inOutboundDetail.getQty())), NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty())));
|
|
|
product.setErpReserve(NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
|
productSet.add(product);
|
|
|
} else {
|