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());
}
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);
}
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);
}
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();
}
Aggregations