Search in sources :

Example 1 with PriceListId

use of de.metas.pricing.PriceListId in project metasfresh-webui-api by metasfresh.

the class DefaultPackingItemCriteria method of.

public static Optional<DefaultPackingItemCriteria> of(@NonNull final I_C_Invoice invoice, @NonNull final ProductId productId) {
    final BPartnerLocationId bpartnerLocationId = BPartnerLocationId.ofRepoIdOrNull(invoice.getC_BPartner_ID(), invoice.getC_BPartner_Location_ID());
    final PriceListId priceListId = PriceListId.ofRepoIdOrNull(invoice.getM_PriceList_ID());
    final ZonedDateTime date = TimeUtil.asZonedDateTime(invoice.getDateInvoiced());
    final boolean anyNull = Stream.of(bpartnerLocationId, priceListId, date, productId).anyMatch(Objects::isNull);
    if (anyNull) {
        return Optional.empty();
    }
    return Optional.of(builder().productId(productId).priceListId(priceListId).date(date).bPartnerLocationId(bpartnerLocationId).build());
}
Also used : ZonedDateTime(java.time.ZonedDateTime) PriceListId(de.metas.pricing.PriceListId) BPartnerLocationId(de.metas.bpartner.BPartnerLocationId) Objects(java.util.Objects)

Example 2 with PriceListId

use of de.metas.pricing.PriceListId in project metasfresh-webui-api by metasfresh.

the class ProductLookupDescriptor method getPriceListVersionId.

private final PriceListVersionId getPriceListVersionId(final LookupDataSourceContext evalCtx) {
    final PriceListId priceListId = PriceListId.ofRepoIdOrNull(param_M_PriceList_ID.getValueAsInteger(evalCtx));
    if (priceListId == null) {
        return null;
    }
    final ZonedDateTime date = getEffectivePricingDate(evalCtx);
    return Services.get(IPriceListDAO.class).retrievePriceListVersionIdOrNull(priceListId, date);
}
Also used : IPriceListDAO(de.metas.pricing.service.IPriceListDAO) ZonedDateTime(java.time.ZonedDateTime) PriceListId(de.metas.pricing.PriceListId)

Example 3 with PriceListId

use of de.metas.pricing.PriceListId 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)

Example 4 with PriceListId

use of de.metas.pricing.PriceListId in project metasfresh-webui-api by metasfresh.

the class OrderProductProposalsService method getOrderById.

public Order getOrderById(@NonNull final OrderId orderId) {
    final I_C_Order orderRecord = ordersRepo.getById(orderId);
    final ZonedDateTime datePromised = TimeUtil.asZonedDateTime(orderRecord.getDatePromised());
    final PriceListId priceListId = PriceListId.ofRepoId(orderRecord.getM_PriceList_ID());
    final I_M_PriceList priceList = priceListsRepo.getById(priceListId);
    final PriceListVersionId priceListVersionId = priceListsRepo.retrievePriceListVersionId(priceListId, datePromised);
    final BPartnerId bpartnerId = BPartnerId.ofRepoId(orderRecord.getC_BPartner_ID());
    final String bpartnerName = bpartnersService.getBPartnerName(bpartnerId);
    return Order.builder().orderId(orderId).soTrx(SOTrx.ofBoolean(orderRecord.isSOTrx())).datePromised(datePromised).bpartnerId(bpartnerId).bpartnerName(bpartnerName).pricingSystemId(priceListsRepo.getPricingSystemId(priceListId)).priceListId(priceListId).priceListVersionId(priceListVersionId).countryId(CountryId.ofRepoIdOrNull(priceList.getC_Country_ID())).currencyId(CurrencyId.ofRepoId(priceList.getC_Currency_ID())).lines(ordersRepo.retrieveOrderLines(orderId, I_C_OrderLine.class).stream().map(this::toOrderLine).collect(ImmutableList.toImmutableList())).build();
}
Also used : I_M_PriceList(org.compiere.model.I_M_PriceList) I_C_Order(org.compiere.model.I_C_Order) ZonedDateTime(java.time.ZonedDateTime) PriceListId(de.metas.pricing.PriceListId) BPartnerId(de.metas.bpartner.BPartnerId) I_C_OrderLine(de.metas.handlingunits.model.I_C_OrderLine) PriceListVersionId(de.metas.pricing.PriceListVersionId)

Aggregations

PriceListId (de.metas.pricing.PriceListId)4 ZonedDateTime (java.time.ZonedDateTime)3 IPriceListDAO (de.metas.pricing.service.IPriceListDAO)2 BPartnerId (de.metas.bpartner.BPartnerId)1 BPartnerLocationId (de.metas.bpartner.BPartnerLocationId)1 HUPIItemProductId (de.metas.handlingunits.HUPIItemProductId)1 IHUPIItemProductDAO (de.metas.handlingunits.IHUPIItemProductDAO)1 I_C_OrderLine (de.metas.handlingunits.model.I_C_OrderLine)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 PriceListVersionId (de.metas.pricing.PriceListVersionId)1 ProductPrices (de.metas.pricing.service.ProductPrices)1 Services (de.metas.util.Services)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 NonNull (lombok.NonNull)1 I_C_Order (org.compiere.model.I_C_Order)1 I_M_PriceList (org.compiere.model.I_M_PriceList)1 I_M_PriceList_Version (org.compiere.model.I_M_PriceList_Version)1 Component (org.springframework.stereotype.Component)1