Search in sources :

Example 1 with I_M_PriceList_Version

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);
}
Also used : Component(org.springframework.stereotype.Component) IHUPIItemProductDAO(de.metas.handlingunits.IHUPIItemProductDAO) NonNull(lombok.NonNull) I_M_PriceList_Version(org.compiere.model.I_M_PriceList_Version) Optional(java.util.Optional) PriceListId(de.metas.pricing.PriceListId) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) I_M_ProductPrice(de.metas.handlingunits.model.I_M_ProductPrice) IPriceListDAO(de.metas.pricing.service.IPriceListDAO) ProductPrices(de.metas.pricing.service.ProductPrices) Services(de.metas.util.Services) PriceListId(de.metas.pricing.PriceListId) I_M_ProductPrice(de.metas.handlingunits.model.I_M_ProductPrice) I_M_PriceList_Version(org.compiere.model.I_M_PriceList_Version)

Aggregations

HUPIItemProductId (de.metas.handlingunits.HUPIItemProductId)1 IHUPIItemProductDAO (de.metas.handlingunits.IHUPIItemProductDAO)1 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)1 I_M_ProductPrice (de.metas.handlingunits.model.I_M_ProductPrice)1 PriceListId (de.metas.pricing.PriceListId)1 IPriceListDAO (de.metas.pricing.service.IPriceListDAO)1 ProductPrices (de.metas.pricing.service.ProductPrices)1 Services (de.metas.util.Services)1 Optional (java.util.Optional)1 NonNull (lombok.NonNull)1 I_M_PriceList_Version (org.compiere.model.I_M_PriceList_Version)1 Component (org.springframework.stereotype.Component)1