Search in sources :

Example 26 with ProductId

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

the class PPOrderLinesLoader method createRowsForIssueProductSourceHUs.

private List<PPOrderLineRow> createRowsForIssueProductSourceHUs(WarehouseId warehouseId, @NonNull final List<PPOrderLineRow> bomLineRows) {
    final ImmutableSet<ProductId> issueProductIds = bomLineRows.stream().filter(PPOrderLineRow::isIssue).map(PPOrderLineRow::getProductId).collect(ImmutableSet.toImmutableSet());
    final ImmutableList.Builder<PPOrderLineRow> result = ImmutableList.builder();
    final MatchingSourceHusQuery sourceHusQuery = MatchingSourceHusQuery.builder().productIds(issueProductIds).warehouseId(warehouseId).build();
    for (final HuId sourceHUId : SourceHUsService.get().retrieveMatchingSourceHUIds(sourceHusQuery)) {
        final HUEditorRow huEditorRow = huEditorRepo.retrieveForHUId(sourceHUId);
        result.add(createRowForSourceHU(huEditorRow));
    }
    return result.build();
}
Also used : MatchingSourceHusQuery(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery) ImmutableList(com.google.common.collect.ImmutableList) ProductId(de.metas.product.ProductId) HuId(de.metas.handlingunits.HuId) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 27 with ProductId

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

the class PickingSlotsClearingViewBasedProcess method retrieveQtyCU.

protected final BigDecimal retrieveQtyCU(@NonNull final I_M_HU hu) {
    final IHUContext huContext = huContextFactory.createMutableHUContext();
    final IHUStorage fromHUStorage = huContext.getHUStorageFactory().getStorage(hu);
    final ProductId productId = fromHUStorage.getSingleProductIdOrNull();
    if (productId == null) {
        return BigDecimal.ZERO;
    }
    final IHUProductStorage productStorage = fromHUStorage.getProductStorage(productId);
    return productStorage.getQty().toBigDecimal();
}
Also used : IHUStorage(de.metas.handlingunits.storage.IHUStorage) ProductId(de.metas.product.ProductId) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage) IHUContext(de.metas.handlingunits.IHUContext)

Example 28 with ProductId

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

the class PackingInfoProcessParams method getM_HU_PI_Item_Products.

/**
 * @return a list of PI item products that match the selected CU's product and partner, sorted by name.
 */
public LookupValuesList getM_HU_PI_Item_Products() {
    final I_M_HU_LUTU_Configuration defaultLUTUConfig = getDefaultLUTUConfig();
    final ProductId productId = ProductId.ofRepoId(defaultLUTUConfig.getM_Product_ID());
    final BPartnerId bpartnerId = ILUTUConfigurationFactory.extractBPartnerIdOrNull(defaultLUTUConfig);
    final boolean includeVirtualItem = !enforcePhysicalTU;
    final LookupValuesList huPIItemProducts = WEBUI_ProcessHelper.retrieveHUPIItemProducts(Env.getCtx(), productId, bpartnerId, includeVirtualItem);
    return huPIItemProducts;
}
Also used : I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) ProductId(de.metas.product.ProductId) BPartnerId(de.metas.bpartner.BPartnerId)

Example 29 with ProductId

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

the class PackingInfoProcessParams method insertPhysicalFallbackTU.

private void insertPhysicalFallbackTU(@NonNull final I_M_HU_LUTU_Configuration defaultLUTUConfig) {
    final BPartnerId bpartnerId = ILUTUConfigurationFactory.extractBPartnerIdOrNull(defaultLUTUConfig);
    final ProductId productId = ProductId.ofRepoId(defaultLUTUConfig.getM_Product_ID());
    final List<I_M_HU_PI_Item_Product> availableHUPIItemProductRecords = WEBUI_ProcessHelper.retrieveHUPIItemProductRecords(Env.getCtx(), productId, bpartnerId, // includeVirtualItem == false
    false);
    Check.errorIf(availableHUPIItemProductRecords.isEmpty(), "There is no non-virtual M_HU_PI_Item_Product value for the given product and bPartner; product={}; bPartner={}", productId, bpartnerId);
    final I_M_HU_PI_Item_Product pip = availableHUPIItemProductRecords.get(0);
    defaultLUTUConfig.setM_HU_PI_Item_Product_ID(pip.getM_HU_PI_Item_Product_ID());
    defaultLUTUConfig.setM_TU_HU_PI_ID(pip.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI_ID());
    defaultLUTUConfig.setQtyCU(pip.getQty());
    final List<I_M_HU_PI_Item> luPIItems = getAvailableLuPIItems(pip, bpartnerId);
    if (luPIItems.isEmpty()) {
        defaultLUTUConfig.setM_LU_HU_PI_Item(null);
        defaultLUTUConfig.setM_LU_HU_PI(null);
    } else {
        final I_M_HU_PI_Item luPiItem = luPIItems.get(0);
        defaultLUTUConfig.setM_LU_HU_PI_Item(luPiItem);
        defaultLUTUConfig.setQtyTU(luPiItem.getQty());
        defaultLUTUConfig.setM_LU_HU_PI_ID(luPiItem.getM_HU_PI_Version().getM_HU_PI_ID());
    }
}
Also used : I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) ProductId(de.metas.product.ProductId) BPartnerId(de.metas.bpartner.BPartnerId)

Example 30 with ProductId

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

the class SqlHUEditorViewRepository method getSingleProductStorage.

private IHUProductStorage getSingleProductStorage(final I_M_HU hu) {
    final IHUStorage huStorage = Services.get(IHandlingUnitsBL.class).getStorageFactory().getStorage(hu);
    final ProductId productId = huStorage.getSingleProductIdOrNull();
    if (productId == null) {
        return null;
    }
    final IHUProductStorage productStorage = huStorage.getProductStorage(productId);
    return productStorage;
}
Also used : IHUStorage(de.metas.handlingunits.storage.IHUStorage) ProductId(de.metas.product.ProductId) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage)

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