Search in sources :

Example 21 with ProductId

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

the class OtherSalePricesProductsProposalViewFactory method createView.

public final ProductsProposalView createView(@NonNull final ProductsProposalView parentView, @NonNull final List<ProductsProposalRow> selectedRows) {
    final ImmutableSet<ProductId> productIds = selectedRows.stream().map(ProductsProposalRow::getProductId).collect(ImmutableSet.toImmutableSet());
    final ProductsProposalRowsData rowsData = RowsLoader.builder().bpartnerProductStatsService(bpartnerProductStatsService).moneyService(moneyService).excludeBPartnerId(parentView.getBpartnerId().orElse(null)).productIds(productIds).build().load();
    final ProductsProposalView view = ProductsProposalView.builder().windowId(getWindowId()).rowsData(rowsData).processes(getRelatedProcessDescriptors()).initialViewId(parentView.getInitialViewId()).build();
    put(view);
    return view;
}
Also used : ProductsProposalRowsData(de.metas.ui.web.order.products_proposal.model.ProductsProposalRowsData) ProductId(de.metas.product.ProductId)

Example 22 with ProductId

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

the class ProductsToPickSourceStorage method retrieveStorage.

private ReservableStorage retrieveStorage(final ReservableStorageKey key) {
    final ProductId productId = key.getProductId();
    final I_M_HU hu = getHU(key.getHuId());
    final IHUProductStorage huProductStorage = handlingUnitsBL.getStorageFactory().getStorage(hu).getProductStorageOrNull(productId);
    if (huProductStorage == null) {
        final I_C_UOM uom = productBL.getStockUOM(productId);
        return new ReservableStorage(productId, Quantity.zero(uom));
    } else {
        final Quantity qtyFreeToReserve = huProductStorage.getQty();
        return new ReservableStorage(productId, qtyFreeToReserve);
    }
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) Quantity(de.metas.quantity.Quantity) ProductId(de.metas.product.ProductId) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage) I_C_UOM(org.compiere.model.I_C_UOM)

Example 23 with ProductId

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

the class WEBUI_Picking_PickQtyToNewHU method getM_HU_PI_Item_Products.

/**
 * @return a list of PI item products that match the selected shipment schedule's product and partner, sorted by name.
 */
@ProcessParamLookupValuesProvider(parameterName = PARAM_M_HU_PI_Item_Product_ID, dependsOn = {}, numericKey = true, lookupTableName = I_M_HU_PI_Item_Product.Table_Name)
private LookupValuesList getM_HU_PI_Item_Products() {
    final Properties ctx = getCtx();
    final I_M_ShipmentSchedule shipmentSchedule = getCurrentShipmentSchedule();
    final ProductId productId = ProductId.ofRepoId(shipmentSchedule.getM_Product_ID());
    return WEBUI_ProcessHelper.retrieveHUPIItemProducts(ctx, productId, Services.get(IShipmentScheduleEffectiveBL.class).getBPartnerId(shipmentSchedule), // includeVirtualItem = true..similar case as with production
    true);
}
Also used : I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) ProductId(de.metas.product.ProductId) Properties(java.util.Properties) ProcessParamLookupValuesProvider(de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)

Example 24 with ProductId

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

the class CableSalesOrderLineQuickInputProcessor method getBOMProductId.

private ProductId getBOMProductId(ICablesOrderLineQuickInput quickInputModel) {
    final ProductId plugProduct1Id = ProductId.ofRepoId(quickInputModel.getPlug1_Product_ID());
    final ProductId plugProduct2Id = ProductId.ofRepoId(quickInputModel.getPlug2_Product_ID());
    final ProductId cableProductId = ProductId.ofRepoId(quickInputModel.getCable_Product_ID());
    final IProductBOMDAO productBOMsRepo = Services.get(IProductBOMDAO.class);
    final List<I_PP_Product_BOM> boms = productBOMsRepo.retrieveBOMsContainingExactProducts(plugProduct1Id.getRepoId(), cableProductId.getRepoId(), plugProduct2Id.getRepoId());
    if (boms.isEmpty()) {
        throw new AdempiereException("@NotFound@ @PP_Product_BOM_ID@");
    } else if (boms.size() > 1) {
        final String bomValues = boms.stream().map(I_PP_Product_BOM::getValue).collect(Collectors.joining(", "));
        throw new AdempiereException("More than one BOMs found: " + bomValues);
    } else {
        final I_PP_Product_BOM bom = boms.get(0);
        return ProductId.ofRepoId(bom.getM_Product_ID());
    }
}
Also used : I_PP_Product_BOM(org.eevolution.model.I_PP_Product_BOM) AdempiereException(org.adempiere.exceptions.AdempiereException) IProductBOMDAO(org.eevolution.api.IProductBOMDAO) ProductId(de.metas.product.ProductId)

Example 25 with ProductId

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

the class CableSalesOrderLineQuickInputProcessor method updateOrderLine_CableProduct.

private final void updateOrderLine_CableProduct(final I_C_OrderLine newOrderLine, final ICablesOrderLineQuickInput fromQuickInputModel) {
    final ProductId productId = getBOMProductId(fromQuickInputModel);
    final BigDecimal cableLength = fromQuickInputModel.getCableLength();
    if (cableLength.signum() <= 0) {
        throw new FillMandatoryException(ICablesOrderLineQuickInput.COLUMNNAME_CableLength);
    }
    final BigDecimal qty = fromQuickInputModel.getQty();
    if (qty.signum() <= 0) {
        throw new FillMandatoryException(ICablesOrderLineQuickInput.COLUMNNAME_Qty);
    }
    final I_M_AttributeSetInstance asi = asiBL.createASIWithASFromProductAndInsertAttributeSet(productId, ImmutableAttributeSet.builder().attributeValue(CablesConstants.ATTRIBUTE_CableLength, cableLength).build());
    newOrderLine.setM_Product_ID(productId.getRepoId());
    newOrderLine.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
    newOrderLine.setQtyEntered(qty);
}
Also used : ProductId(de.metas.product.ProductId) I_M_AttributeSetInstance(org.compiere.model.I_M_AttributeSetInstance) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) BigDecimal(java.math.BigDecimal)

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