Search in sources :

Example 11 with ProductId

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

the class MaterialCockpitRowRepository method retrieveRelevantProductIds.

private ImmutableSet<ProductId> retrieveRelevantProductIds(@NonNull final DocumentFilterList filters) {
    final OrgId orgId = OrgId.ofRepoIdOrAny(Env.getAD_Org_ID(Env.getCtx()));
    final int limit = Services.get(ISysConfigBL.class).getIntValue(SYSCONFIG_EMPTY_PRODUCTS_LIMIT, DEFAULT_EMPTY_PRODUCTS_LIMIT);
    final CacheKey cacheKey = new CacheKey(orgId, ProductFilterUtil.extractProductFilterVO(filters), limit);
    final ImmutableSet<ProductId> productIds = productFilterVOToProducts.getOrLoad(cacheKey, () -> retrieveProductsFor(cacheKey));
    return productIds;
}
Also used : OrgId(de.metas.organization.OrgId) ISysConfigBL(org.adempiere.service.ISysConfigBL) ProductId(de.metas.product.ProductId)

Example 12 with ProductId

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

the class MaterialCockpitRowRepository method retrieveProductsFor.

private static ImmutableSet<ProductId> retrieveProductsFor(@NonNull final CacheKey cacheKey) {
    final OrgId orgId = cacheKey.getOrgId();
    final ProductFilterVO productFilterVO = cacheKey.getProductFilterVO();
    final int limit = cacheKey.getLimit();
    final IQueryFilter<I_M_Product> productQueryFilter = ProductFilterUtil.createProductQueryFilterOrNull(productFilterVO, false);
    final IQueryBuilder<I_M_Product> queryBuilder = Services.get(IQueryBL.class).createQueryBuilder(I_M_Product.class).addInArrayFilter(I_M_Product.COLUMNNAME_AD_Org_ID, orgId.getRepoId(), 0).addEqualsFilter(I_M_Product.COLUMN_IsStocked, true).filter(productQueryFilter).orderBy(I_M_Product.COLUMN_Value);
    if (limit > 0) {
        queryBuilder.setLimit(limit);
    }
    return queryBuilder.create().listIds(ProductId::ofRepoId);
}
Also used : OrgId(de.metas.organization.OrgId) IQueryBL(org.adempiere.ad.dao.IQueryBL) I_M_Product(org.compiere.model.I_M_Product) ProductFilterVO(de.metas.ui.web.material.cockpit.filters.ProductFilterVO) ProductId(de.metas.product.ProductId)

Example 13 with ProductId

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

the class HUEditorRowAttributesProvider method createRowAttributes.

private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
    final I_M_HU hu = extractHU(key);
    final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
    attributesStorage.setSaveOnChange(true);
    final boolean rowAttributesReadonly = // readonly if the provider shall provide readonly attributes
    isReadonly() || // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
    !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus());
    final IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
    final IHUStorageFactory storageFactory = handlingUnitsBL.getStorageFactory();
    final IHUStorage storage = storageFactory.getStorage(hu);
    final ImmutableSet<ProductId> productIDs = storage.getProductStorages().stream().map(IHUProductStorage::getProductId).collect(ImmutableSet.toImmutableSet());
    final DocumentPath documentPath = createDocumentPath(key);
    return new HUEditorRowAttributes(documentPath, attributesStorage, productIDs, rowAttributesReadonly);
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) I_M_HU(de.metas.handlingunits.model.I_M_HU) IHUStorageFactory(de.metas.handlingunits.storage.IHUStorageFactory) IHUStorage(de.metas.handlingunits.storage.IHUStorage) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) ProductId(de.metas.product.ProductId)

Example 14 with ProductId

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

the class HUEditorRowId method fromJson.

private static HUEditorRowId fromJson(@NonNull final String json, final DocumentId documentId) {
    // 
    // Split json to parts
    final Iterator<String> partsIterator;
    {
        final List<String> parts = PARTS_SPLITTER.splitToList(json);
        if (parts.isEmpty()) {
            throw new IllegalArgumentException("Invalid HU rowId: " + json);
        }
        partsIterator = parts.iterator();
    }
    // 
    // huId and storageProductId
    final HuId huId;
    final ProductId storageProductId;
    {
        final String idStrPart = partsIterator.next();
        final List<String> idParts = ID_SPLITTER.splitToList(idStrPart);
        if (idParts.size() == 1) {
            huId = HuId.ofRepoId(Integer.parseInt(idParts.get(0)));
            storageProductId = null;
        } else if (idParts.size() == 2) {
            huId = HuId.ofRepoId(Integer.parseInt(idParts.get(0)));
            storageProductId = ProductId.ofRepoId(Integer.parseInt(idParts.get(1)));
        } else {
            throw new IllegalArgumentException("Invalid HU rowId: " + json + ". Cannot parse ID part: " + idStrPart);
        }
    }
    // 
    // Others
    HuId topLevelHUId = null;
    while (partsIterator.hasNext()) {
        final String part = partsIterator.next();
        if (part.startsWith(PREFIX_TopLevelHUId)) {
            final String topLevelHUIdStr = part.substring(PREFIX_TopLevelHUId.length());
            topLevelHUId = HuId.ofRepoId(Integer.parseInt(topLevelHUIdStr));
        } else {
            throw new IllegalArgumentException("Invalid HU rowId: " + json + ". Cannot parse part: " + part);
        }
    }
    return new HUEditorRowId(huId, storageProductId, topLevelHUId, json, documentId);
}
Also used : List(java.util.List) HuId(de.metas.handlingunits.HuId) ProductId(de.metas.product.ProductId)

Example 15 with ProductId

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

the class ProductsToPickRowsDataFactory method createRowFromExistingPickingCandidate.

private ProductsToPickRow createRowFromExistingPickingCandidate(@NonNull final AllocablePackageable packageable, @NonNull final PickingCandidate existingPickingCandidate) {
    final PickFrom pickFrom = existingPickingCandidate.getPickFrom();
    if (pickFrom.isPickFromHU()) {
        final Quantity qty;
        final HuId pickFromHUId = pickFrom.getHuId();
        if (pickFromHUId != null) {
            final ProductId productId = packageable.getProductId();
            final ReservableStorage storage = storages.getStorage(pickFromHUId, productId);
            qty = storage.reserve(packageable, existingPickingCandidate.getQtyPicked());
        } else {
            qty = existingPickingCandidate.getQtyPicked();
        }
        return prepareRow_PickFromHU(packageable).pickFromHUId(pickFromHUId).qty(qty).existingPickingCandidate(existingPickingCandidate).build();
    } else if (pickFrom.isPickFromPickingOrder()) {
        final ImmutableList<ProductsToPickRow> includedRows = existingPickingCandidate.getIssuesToPickingOrder().stream().map(issueToBOMLine -> prepareRow_IssueComponentsToPickingOrder(toBOMLineAllocablePackageable(issueToBOMLine, packageable)).pickFromHUId(issueToBOMLine.getIssueFromHUId()).qty(issueToBOMLine.getQtyToIssue()).build()).collect(ImmutableList.toImmutableList());
        return prepareRow_PickFromPickingOrder(packageable).pickFromPickingOrderId(pickFrom.getPickingOrderId()).qty(existingPickingCandidate.getQtyPicked()).existingPickingCandidate(existingPickingCandidate).includedRows(includedRows).build();
    } else {
        throw new AdempiereException("Unknown " + pickFrom);
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) AdempiereException(org.adempiere.exceptions.AdempiereException) Quantity(de.metas.quantity.Quantity) PickFrom(de.metas.handlingunits.picking.PickFrom) HuId(de.metas.handlingunits.HuId) ProductId(de.metas.product.ProductId)

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