给销售单据存储的采购价增加移动平均价的切换

This commit is contained in:
jishenghua 2024-06-11 00:22:28 +08:00
parent b9d316d8a4
commit acd8429c81
3 changed files with 10 additions and 1 deletions

View File

@ -17,4 +17,6 @@ public interface MaterialCurrentStockMapperEx {
void updateUnitPriceByMId(
@Param("currentUnitPrice") BigDecimal currentUnitPrice,
@Param("materialId") Long materialId);
BigDecimal getCurrentUnitPriceByMId(@Param("materialId") Long materialId);
}

View File

@ -578,7 +578,10 @@ public class DepotItemService {
BusinessConstants.SUB_TYPE_SALES_RETURN.equals(depotHead.getSubType()) ||
BusinessConstants.SUB_TYPE_RETAIL.equals(depotHead.getSubType()) ||
BusinessConstants.SUB_TYPE_RETAIL_RETURN.equals(depotHead.getSubType())) {
depotItem.setPurchaseUnitPrice(materialExtend.getPurchaseDecimal());
boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
BigDecimal currentUnitPrice = materialCurrentStockMapperEx.getCurrentUnitPriceByMId(materialExtend.getMaterialId());
BigDecimal unitPrice = moveAvgPriceFlag? currentUnitPrice: materialExtend.getPurchaseDecimal();
depotItem.setPurchaseUnitPrice(unitPrice);
if(StringUtil.isNotEmpty(depotItem.getBatchNumber())) {
depotItem.setPurchaseUnitPrice(getDepotItemByBatchNumber(depotItem.getMaterialExtendId(),depotItem.getBatchNumber()).getUnitPrice());
}

View File

@ -27,4 +27,8 @@
and ifnull(delete_flag,'0') !='1'
</update>
<select id="getCurrentUnitPriceByMId" resultType="java.math.BigDecimal">
select ifnull(mcs.current_unit_price,0) as current_unit_price from jsh_material_current_stock mcs where mcs.material_id=#{materialId} limit 1
</select>
</mapper>