Source:
private Optional<I_M_HU_PI_Item_Product> getDefaultPackingMaterialFromPriceList(@NonNull final DefaultPackingItemCriteria defaultPackingItemCriteria) { final PriceListId priceListId = Optional.ofNullable(defaultPackingItemCriteria.getPriceListId()) .orElseGet(() -> getPriceListIdFor(defaultPackingItemCriteria)); if (priceListId == null) { return Optional.empty(); } final I_M_PriceList_Version priceListVersion = priceListsRepo .retrievePriceListVersionOrNull(priceListId, defaultPackingItemCriteria.getDate(), null); if (priceListVersion == null) { return Optional.empty(); } final boolean enforcePrecisePricePerHUItemProduct = sysConfigBL.getBooleanValue(SYSCONFIG_EnforcePrecisePricePerHUItemProduct, false); final IHUPIItemProductDAO piItemProductDAO = Services.get(IHUPIItemProductDAO.class); final IHUPIItemProductQuery queryVO = piItemProductDAO.createHUPIItemProductQuery(); queryVO.setM_Product_ID(defaultPackingItemCriteria.getProductId().getRepoId()); queryVO.setBPartnerId(defaultPackingItemCriteria.getBPartnerLocationId().getBpartnerId()); queryVO.setAllowVirtualPI(false); queryVO.setDate(defaultPackingItemCriteria.getDate()); queryVO.setAllowAnyProduct(false); queryVO.setAllowAnyPartner(false); if (enforcePrecisePricePerHUItemProduct) { queryVO.setPriceListVersionId(PriceListVersionId.ofRepoId(priceListVersion.getM_PriceList_Version_ID())); } final List<I_M_HU_PI_Item_Product> itemProducts = piItemProductDAO.retrieveHUItemProducts(Env.getCtx(), queryVO, ITrx.TRXNAME_ThreadInherited); return itemProducts.stream().findFirst(); }

Target:
private Optional<I_M_HU_PI_Item_Product> getDefaultPackingMaterialFromPriceList(@NonNull final DefaultPackingItemCriteria defaultPackingItemCriteria) { final PriceListId priceListId = Optional.ofNullable(defaultPackingItemCriteria.getPriceListId()) .orElseGet(() -> getPriceListIdFor(defaultPackingItemCriteria)); if (priceListId == null) { return Optional.empty(); } final I_M_PriceList_Version priceListVersion = priceListsRepo .retrievePriceListVersionOrNull(priceListId, defaultPackingItemCriteria.getDate(), null); if (priceListVersion == null) { return Optional.empty(); } final ClientId clientId = defaultPackingItemCriteria.getClientId(); final boolean enforcePrecisePricePerHUItemProduct = sysConfigBL.getBooleanValue(SYSCONFIG_EnforcePrecisePricePerHUItemProduct, false, clientId.getRepoId()); final IHUPIItemProductDAO piItemProductDAO = Services.get(IHUPIItemProductDAO.class); final IHUPIItemProductQuery queryVO = piItemProductDAO.createHUPIItemProductQuery(); queryVO.setM_Product_ID(defaultPackingItemCriteria.getProductId().getRepoId()); queryVO.setBPartnerId(defaultPackingItemCriteria.getBPartnerLocationId().getBpartnerId()); queryVO.setAllowVirtualPI(false); queryVO.setDate(defaultPackingItemCriteria.getDate()); queryVO.setAllowAnyProduct(false); queryVO.setAllowAnyPartner(false); if (enforcePrecisePricePerHUItemProduct) { queryVO.setPriceListVersionId(PriceListVersionId.ofRepoId(priceListVersion.getM_PriceList_Version_ID())); } final List<I_M_HU_PI_Item_Product> itemProducts = piItemProductDAO.retrieveHUItemProducts(Env.getCtx(), queryVO, ITrx.TRXNAME_ThreadInherited); return itemProducts.stream().findFirst(); }