Search in sources :

Example 16 with ProductId

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

the class ProductsToPickRowsDataFactory method allocateRowFromHU.

@Nullable
private ProductsToPickRow allocateRowFromHU(final ProductsToPickRow row, final AllocablePackageable packageable) {
    if (packageable.isAllocated()) {
        return null;
    }
    final HuId pickFromHUId = row.getPickFromHUId();
    if (pickFromHUId == null) {
        throw new AdempiereException("No pickFromHUId set for " + row);
    }
    final ProductId productId = packageable.getProductId();
    final ReservableStorage storage = storages.getStorage(pickFromHUId, productId);
    final Quantity qty = storage.reserve(packageable);
    if (qty.isZero()) {
        return null;
    }
    return row.withQty(qty);
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) Quantity(de.metas.quantity.Quantity) HuId(de.metas.handlingunits.HuId) ProductId(de.metas.product.ProductId) Nullable(javax.annotation.Nullable)

Example 17 with ProductId

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

the class OrderLineQuickInputCallout method updateM_HU_PI_Item_Product.

private void updateM_HU_PI_Item_Product(@NonNull final QuickInput quickInput) {
    if (!quickInput.hasField(IOrderLineQuickInput.COLUMNNAME_M_HU_PI_Item_Product_ID)) {
        // there are users whose systems don't have M_HU_PI_Item_Product_ID in their quick-input
        return;
    }
    final IOrderLineQuickInput quickInputModel = quickInput.getQuickInputDocumentAs(IOrderLineQuickInput.class);
    final LookupValue productLookupValue = quickInputModel.getM_Product_ID();
    if (productLookupValue == null) {
        return;
    }
    final ProductAndAttributes productAndAttributes = ProductLookupDescriptor.toProductAndAttributes(productLookupValue);
    final ProductId quickInputProductId = productAndAttributes.getProductId();
    final I_C_Order order = quickInput.getRootDocumentAs(I_C_Order.class);
    final Optional<DefaultPackingItemCriteria> defaultPackingItemCriteria = DefaultPackingItemCriteria.of(order, quickInputProductId);
    final I_M_HU_PI_Item_Product huPIItemProduct = defaultPackingItemCriteria.flatMap(packingItemProductFieldHelper::getDefaultPackingMaterial).orElse(null);
    quickInputModel.setM_HU_PI_Item_Product(huPIItemProduct);
}
Also used : DefaultPackingItemCriteria(de.metas.ui.web.quickinput.field.DefaultPackingItemCriteria) I_C_Order(de.metas.adempiere.model.I_C_Order) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) ProductId(de.metas.product.ProductId) ProductAndAttributes(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes) LookupValue(de.metas.ui.web.window.datatypes.LookupValue)

Example 18 with ProductId

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

the class OrderLineQuickInputProcessor method validateInput.

private void validateInput(final OrderLineCandidate candidate) {
    final BPartnerId bpartnerId = candidate.getBpartnerId();
    final ProductId productId = candidate.getProductId();
    final SOTrx soTrx = candidate.getSoTrx();
    final ArrayList<ITranslatableString> validationErrorMessages = new ArrayList<>();
    for (final IOrderLineInputValidator validator : validators) {
        final OrderLineInputValidatorResults validationResults = validator.validate(bpartnerId, productId, soTrx);
        if (validationResults != null && !validationResults.isValid() && validationResults.getErrorMessage() != null) {
            validationErrorMessages.add(validationResults.getErrorMessage());
        }
    }
    if (!validationErrorMessages.isEmpty()) {
        throw new AdempiereException(TranslatableStrings.joinList("\n", validationErrorMessages));
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) SOTrx(de.metas.lang.SOTrx) ITranslatableString(de.metas.i18n.ITranslatableString) ArrayList(java.util.ArrayList) ProductId(de.metas.product.ProductId) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) BPartnerId(de.metas.bpartner.BPartnerId) OrderLineInputValidatorResults(de.metas.order.OrderLineInputValidatorResults) IOrderLineInputValidator(de.metas.order.IOrderLineInputValidator)

Example 19 with ProductId

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

the class OrderLineQuickInputProcessor method explodePhantomBOM.

private List<OrderLineCandidate> explodePhantomBOM(final OrderLineCandidate initialCandidate) {
    final ProductId bomProductId = initialCandidate.getProductId();
    final I_PP_Product_BOM bom = bomsRepo.getDefaultBOMByProductId(bomProductId).orElse(null);
    if (bom == null) {
        return ImmutableList.of(initialCandidate);
    }
    final BOMUse bomUse = BOMUse.ofNullableCode(bom.getBOMUse());
    if (!BOMUse.Phantom.equals(bomUse)) {
        return ImmutableList.of(initialCandidate);
    }
    GroupId compensationGroupId = null;
    final ArrayList<OrderLineCandidate> result = new ArrayList<>();
    final List<I_PP_Product_BOMLine> bomLines = bomsRepo.retrieveLines(bom);
    for (final I_PP_Product_BOMLine bomLine : bomLines) {
        final ProductBOMLineId bomLineId = ProductBOMLineId.ofRepoId(bomLine.getPP_Product_BOMLine_ID());
        final ProductId bomLineProductId = ProductId.ofRepoId(bomLine.getM_Product_ID());
        final BigDecimal bomLineQty = bomsService.computeQtyRequired(bomLine, bomProductId, initialCandidate.getQty());
        final AttributeSetInstanceId bomLineAsiId = AttributeSetInstanceId.ofRepoIdOrNone(bomLine.getM_AttributeSetInstance_ID());
        final ImmutableAttributeSet attributes = asiBL.getImmutableAttributeSetById(bomLineAsiId);
        if (compensationGroupId == null) {
            compensationGroupId = orderGroupsRepo.createNewGroupId(GroupCreateRequest.builder().orderId(initialCandidate.getOrderId()).name(productBL.getProductName(bomProductId)).build());
        }
        result.add(initialCandidate.toBuilder().productId(bomLineProductId).attributes(attributes).qty(bomLineQty).compensationGroupId(compensationGroupId).explodedFromBOMLineId(bomLineId).build());
    }
    return result;
}
Also used : AttributeSetInstanceId(org.adempiere.mm.attributes.AttributeSetInstanceId) ArrayList(java.util.ArrayList) ProductId(de.metas.product.ProductId) HUPIItemProductId(de.metas.handlingunits.HUPIItemProductId) BigDecimal(java.math.BigDecimal) GroupId(de.metas.order.compensationGroup.GroupId) I_PP_Product_BOM(org.eevolution.model.I_PP_Product_BOM) ImmutableAttributeSet(org.adempiere.mm.attributes.api.ImmutableAttributeSet) ProductBOMLineId(org.eevolution.api.ProductBOMLineId) BOMUse(org.eevolution.api.BOMUse) I_PP_Product_BOMLine(org.eevolution.model.I_PP_Product_BOMLine)

Example 20 with ProductId

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

the class ShipmentCandidateRow method getWebuiASIEditingInfo.

@Override
public WebuiASIEditingInfo getWebuiASIEditingInfo(@NonNull final AttributeSetInstanceId asiId) {
    final ProductId productId = product.getIdAs(ProductId::ofRepoIdOrNull);
    final ASIEditingInfo info = ASIEditingInfo.builder().type(WindowType.Regular).productId(productId).attributeSetInstanceId(asiId).callerTableName(null).callerColumnId(-1).soTrx(SOTrx.SALES).build();
    return WebuiASIEditingInfo.builder(info).build();
}
Also used : ProductId(de.metas.product.ProductId) WebuiASIEditingInfo(de.metas.ui.web.pattribute.WebuiASIEditingInfo) ASIEditingInfo(org.adempiere.mm.attributes.util.ASIEditingInfo)

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