Search in sources :

Example 1 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class WEBUI_C_OrderLineSO_Delete_HUReservation method checkPreconditionsApplicable.

@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final SalesOrderLine salesOrderLine = WEBUI_C_OrderLineSO_Util.retrieveSalesOrderLine(getView(), salesOrderLineRepository).orElse(null);
    if (salesOrderLine == null) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("No sales order was set");
    }
    final ProductId productId = salesOrderLine.getProductId();
    final Quantity unreservableQty = retrieveUnreservableQuantity(productId);
    if (unreservableQty.signum() <= 0) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("No unreservableQty quantity for productId=" + productId);
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : SalesOrderLine(de.metas.purchasecandidate.SalesOrderLine) Quantity(de.metas.quantity.Quantity) ProductId(de.metas.product.ProductId)

Example 2 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class WEBUI_C_OrderLineSO_Make_HUReservation method getParameterDefaultValue.

@Override
public Object getParameterDefaultValue(@NonNull final IProcessDefaultParameter parameter) {
    if (PARAMNAME_QTY_TO_RESERVE.equals(parameter.getColumnName())) {
        final SalesOrderLine salesOrderLine = WEBUI_C_OrderLineSO_Util.retrieveSalesOrderLine(getView(), salesOrderLineRepository).get();
        final ProductId productId = salesOrderLine.getProductId();
        final Quantity orderedQty = salesOrderLine.getOrderedQty();
        final Quantity reservedQty = huReservationService.retrieveReservedQty(salesOrderLine.getId().getOrderLineId()).orElse(orderedQty.toZero());
        final Quantity reservedQtyInSalesOrderUOM = uomConversionBL.convertQuantityTo(reservedQty, UOMConversionContext.of(productId), orderedQty.getUomId());
        final Quantity requiredQty = orderedQty.subtract(salesOrderLine.getDeliveredQty()).subtract(reservedQtyInSalesOrderUOM);
        final Quantity reservableQty = retrieveReservableQuantity(productId);
        final Quantity reservableQtyInSalesOrderUOM = uomConversionBL.convertQuantityTo(reservableQty, UOMConversionContext.of(productId), orderedQty.getUomId());
        return requiredQty.min(reservableQtyInSalesOrderUOM).toBigDecimal();
    }
    return null;
}
Also used : SalesOrderLine(de.metas.purchasecandidate.SalesOrderLine) Quantity(de.metas.quantity.Quantity) ProductId(de.metas.product.ProductId)

Example 3 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class OrderLinePricingConditionsViewFactory method createPricingConditionsBreakQuery.

private final PricingConditionsBreakQuery createPricingConditionsBreakQuery(final I_C_OrderLine salesOrderLine) {
    final IProductDAO productsRepo = Services.get(IProductDAO.class);
    final IAttributeDAO attributesRepo = Services.get(IAttributeDAO.class);
    final ProductId productId = ProductId.ofRepoId(salesOrderLine.getM_Product_ID());
    final ProductAndCategoryAndManufacturerId product = productsRepo.retrieveProductAndCategoryAndManufacturerByProductId(productId);
    final AttributeSetInstanceId asiId = AttributeSetInstanceId.ofRepoIdOrNone(salesOrderLine.getM_AttributeSetInstance_ID());
    final ImmutableAttributeSet attributes = attributesRepo.getImmutableAttributeSetById(asiId);
    final BigDecimal qty = salesOrderLine.getQtyOrdered();
    final BigDecimal price = salesOrderLine.getPriceActual();
    return PricingConditionsBreakQuery.builder().product(product).attributes(attributes).qty(qty).price(price).build();
}
Also used : ProductAndCategoryAndManufacturerId(de.metas.product.ProductAndCategoryAndManufacturerId) AttributeSetInstanceId(org.adempiere.mm.attributes.AttributeSetInstanceId) ImmutableAttributeSet(org.adempiere.mm.attributes.api.ImmutableAttributeSet) IProductDAO(de.metas.product.IProductDAO) ProductId(de.metas.product.ProductId) BigDecimal(java.math.BigDecimal) IAttributeDAO(org.adempiere.mm.attributes.api.IAttributeDAO)

Example 4 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class ProductsProposalRowsLoader method toProductsProposalRowOrNull.

private ProductsProposalRow toProductsProposalRowOrNull(@NonNull final I_M_ProductPrice record) {
    final ProductId productId = ProductId.ofRepoId(record.getM_Product_ID());
    final LookupValue product = productLookup.findById(productId);
    if (!product.isActive()) {
        return null;
    }
    final HUPIItemProductId packingMaterialId = HUPIItemProductId.ofRepoIdOrNull(record.getM_HU_PI_Item_Product_ID());
    final ITranslatableString packingDescription = packingMaterialId != null ? packingMaterialsService.getDisplayName(packingMaterialId) : TranslatableStrings.empty();
    return ProductsProposalRow.builder().id(nextRowIdSequence.nextDocumentId()).product(product).packingMaterialId(packingMaterialId).packingDescription(packingDescription).asiDescription(extractProductASIDescription(record)).price(extractProductProposalPrice(record)).qty(null).lastShipmentDays(// will be populated later
    null).seqNo(record.getSeqNo()).productPriceId(ProductPriceId.ofRepoId(record.getM_ProductPrice_ID())).build().withExistingOrderLine(order);
}
Also used : HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) ITranslatableString(de.metas.i18n.ITranslatableString) ProductId(de.metas.product.ProductId) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 5 with ProductId

use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.

the class ProductsProposalRowsLoader method extractProductProposalPrice.

private ProductProposalPrice extractProductProposalPrice(final I_M_ProductPrice record) {
    final PriceListVersionId priceListVersionId = PriceListVersionId.ofRepoId(record.getM_PriceList_Version_ID());
    final Amount priceListPrice = Amount.of(record.getPriceStd(), getCurrencyCode(priceListVersionId));
    final ProductId productId = ProductId.ofRepoId(record.getM_Product_ID());
    final ProductProposalCampaignPrice campaignPrice = campaignPriceProvider.getCampaignPrice(productId).orElse(null);
    return ProductProposalPrice.builder().priceListPrice(priceListPrice).campaignPrice(campaignPrice).build();
}
Also used : Amount(de.metas.currency.Amount) ProductId(de.metas.product.ProductId) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) PriceListVersionId(de.metas.pricing.PriceListVersionId)

Aggregations

ProductId (de.metas.product.ProductId)56 HUPIItemProductId (de.metas.handlingunits.HUPIItemProductId)8 BPartnerId (de.metas.bpartner.BPartnerId)7 HuId (de.metas.handlingunits.HuId)7 Quantity (de.metas.quantity.Quantity)7 AdempiereException (org.adempiere.exceptions.AdempiereException)7 I_M_HU (de.metas.handlingunits.model.I_M_HU)6 IHUProductStorage (de.metas.handlingunits.storage.IHUProductStorage)5 IHUStorage (de.metas.handlingunits.storage.IHUStorage)5 ITranslatableString (de.metas.i18n.ITranslatableString)5 BigDecimal (java.math.BigDecimal)5 I_C_UOM (org.compiere.model.I_C_UOM)5 LookupValue (de.metas.ui.web.window.datatypes.LookupValue)4 ArrayList (java.util.ArrayList)4 ImmutableAttributeSet (org.adempiere.mm.attributes.api.ImmutableAttributeSet)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ImmutableList (com.google.common.collect.ImmutableList)3 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)3 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)3 IProductBL (de.metas.product.IProductBL)3