use of org.compiere.model.I_M_PriceList_Version in project metasfresh-webui-api by metasfresh.
the class PackingItemProductFieldHelper method getDefaultPackingMaterialFromPriceList.
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();
}
return ProductPrices.newQuery(priceListVersion).setProductId(defaultPackingItemCriteria.getProductId()).list(I_M_ProductPrice.class).stream().map(productPrice -> HUPIItemProductId.ofRepoIdOrNone(productPrice.getM_HU_PI_Item_Product_ID())).filter(id -> HUPIItemProductId.isRegular(id)).findFirst().map(huPIItemProductsRepo::getById);
}
Aggregations