Search in sources :

Example 1 with I_M_HU_PI_Item_Product

use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.

the class OrderLineQuickInputProcessor method createAndInitHuPackingAware.

private PlainHUPackingAware createAndInitHuPackingAware(@NonNull final I_C_Order order, @NonNull final IOrderLineQuickInput quickInput) {
    final PlainHUPackingAware huPackingAware = new PlainHUPackingAware();
    huPackingAware.setC_BPartner(order.getC_BPartner());
    huPackingAware.setDateOrdered(order.getDateOrdered());
    huPackingAware.setInDispute(false);
    final ProductAndAttributes productAndAttributes = ProductLookupDescriptor.toProductAndAttributes(quickInput.getM_Product_ID());
    final I_M_Product product = load(productAndAttributes.getProductId(), I_M_Product.class);
    huPackingAware.setM_Product_ID(product.getM_Product_ID());
    huPackingAware.setC_UOM(product.getC_UOM());
    huPackingAware.setM_AttributeSetInstance_ID(createASI(productAndAttributes));
    final I_M_HU_PI_Item_Product piItemProduct = quickInput.getM_HU_PI_Item_Product();
    huPackingAware.setM_HU_PI_Item_Product(piItemProduct);
    return huPackingAware;
}
Also used : PlainHUPackingAware(de.metas.adempiere.gui.search.impl.PlainHUPackingAware) I_M_Product(org.compiere.model.I_M_Product) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) ProductAndAttributes(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)

Example 2 with I_M_HU_PI_Item_Product

use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.

the class PackingInfoProcessParams method configureLUTUConfigTU.

private void configureLUTUConfigTU(@NonNull final I_M_HU_LUTU_Configuration lutuConfigNew, final int M_HU_PI_Item_Product_ID, @NonNull final BigDecimal qtyTU) {
    final I_M_HU_PI_Item_Product tuPIItemProduct = loadOutOfTrx(M_HU_PI_Item_Product_ID, I_M_HU_PI_Item_Product.class);
    final I_M_HU_PI tuPI = tuPIItemProduct.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
    lutuConfigNew.setM_HU_PI_Item_Product(tuPIItemProduct);
    lutuConfigNew.setM_TU_HU_PI(tuPI);
    lutuConfigNew.setQtyTU(qtyTU);
    lutuConfigNew.setIsInfiniteQtyTU(false);
}
Also used : I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI)

Example 3 with I_M_HU_PI_Item_Product

use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.

the class PackingInfoProcessParams method insertPhysicalFallbackTU.

private void insertPhysicalFallbackTU(@NonNull final I_M_HU_LUTU_Configuration defaultLUTUConfig) {
    final List<I_M_HU_PI_Item_Product> availableHUPIItemProductRecords = WEBUI_ProcessHelper.retrieveHUPIItemProductRecords(Env.getCtx(), defaultLUTUConfig.getM_Product(), defaultLUTUConfig.getC_BPartner(), // 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={}", defaultLUTUConfig.getM_Product(), defaultLUTUConfig.getC_BPartner());
    final I_M_HU_PI_Item_Product pip = availableHUPIItemProductRecords.get(0);
    defaultLUTUConfig.setM_HU_PI_Item_Product(pip);
    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, defaultLUTUConfig.getC_BPartner());
    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)

Example 4 with I_M_HU_PI_Item_Product

use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_ReceiptSchedule_ReceiveHUs_UsingConfig method createM_HU_LUTU_Configuration.

@Override
protected I_M_HU_LUTU_Configuration createM_HU_LUTU_Configuration(final I_M_HU_LUTU_Configuration template) {
    // Validate parameters
    final int M_LU_HU_PI_ID = p_M_LU_HU_PI_ID;
    final int M_HU_PI_Item_Product_ID = p_M_HU_PI_Item_Product_ID;
    final BigDecimal qtyCU = p_QtyCU;
    final BigDecimal qtyTU = p_QtyTU;
    final BigDecimal qtyLU = p_QtyLU;
    if (M_HU_PI_Item_Product_ID <= 0) {
        throw new FillMandatoryException(PARAM_M_HU_PI_Item_Product_ID);
    }
    if (qtyCU == null || qtyCU.signum() <= 0) {
        throw new FillMandatoryException(PARAM_QtyCU);
    }
    if (qtyTU == null || qtyTU.signum() <= 0) {
        throw new FillMandatoryException(PARAM_QtyTU);
    }
    final I_M_HU_LUTU_Configuration lutuConfigurationNew = InterfaceWrapperHelper.copy().setFrom(template).copyToNew(I_M_HU_LUTU_Configuration.class);
    // 
    // CU
    lutuConfigurationNew.setQtyCU(qtyCU);
    lutuConfigurationNew.setIsInfiniteQtyCU(false);
    // 
    // TU
    final I_M_HU_PI_Item_Product tuPIItemProduct = InterfaceWrapperHelper.create(getCtx(), M_HU_PI_Item_Product_ID, I_M_HU_PI_Item_Product.class, ITrx.TRXNAME_None);
    final I_M_HU_PI tuPI = tuPIItemProduct.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
    lutuConfigurationNew.setM_HU_PI_Item_Product(tuPIItemProduct);
    lutuConfigurationNew.setM_TU_HU_PI(tuPI);
    lutuConfigurationNew.setQtyTU(qtyTU);
    lutuConfigurationNew.setIsInfiniteQtyTU(false);
    // LU
    if (M_LU_HU_PI_ID > 0) {
        if (qtyLU == null || qtyLU.signum() <= 0) {
            throw new FillMandatoryException(PARAM_QtyLU);
        }
        final I_M_HU_PI luPI = InterfaceWrapperHelper.create(getCtx(), M_LU_HU_PI_ID, I_M_HU_PI.class, ITrx.TRXNAME_None);
        final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
        final I_M_HU_PI_Version luPIV = handlingUnitsDAO.retrievePICurrentVersion(luPI);
        final I_M_HU_PI_Item luPI_Item = handlingUnitsDAO.retrieveParentPIItemsForParentPI(tuPI, X_M_HU_PI_Version.HU_UNITTYPE_LoadLogistiqueUnit, lutuConfigurationNew.getC_BPartner()).stream().filter(piItem -> piItem.getM_HU_PI_Version_ID() == luPIV.getM_HU_PI_Version_ID()).findFirst().orElseThrow(() -> new AdempiereException(tuPI.getName() + " cannot be loaded to " + luPI.getName()));
        lutuConfigurationNew.setM_LU_HU_PI(luPI);
        lutuConfigurationNew.setM_LU_HU_PI_Item(luPI_Item);
        lutuConfigurationNew.setQtyLU(qtyLU);
        lutuConfigurationNew.setIsInfiniteQtyLU(false);
    } else {
        lutuConfigurationNew.setM_LU_HU_PI(null);
        lutuConfigurationNew.setM_LU_HU_PI_Item(null);
        lutuConfigurationNew.setQtyLU(BigDecimal.ZERO);
    }
    return lutuConfigurationNew;
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) AdempiereException(org.adempiere.exceptions.AdempiereException) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI) BigDecimal(java.math.BigDecimal)

Example 5 with I_M_HU_PI_Item_Product

use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.

the class WEBUI_ProcessHelper method retrieveHUPIItemProductRecords.

public List<I_M_HU_PI_Item_Product> retrieveHUPIItemProductRecords(@NonNull final Properties ctx, @NonNull final I_M_Product product, @Nullable final I_C_BPartner bPartner, final boolean includeVirtualItem) {
    final IHUPIItemProductDAO hupiItemProductDAO = Services.get(IHUPIItemProductDAO.class);
    final ISysConfigBL sysConfigBL = Services.get(ISysConfigBL.class);
    final boolean allowInfiniteCapacity = sysConfigBL.getBooleanValue(SYSCONFIG_ALLOW_INFINIT_CAPACITY_TUS, true, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
    final List<I_M_HU_PI_Item_Product> list = hupiItemProductDAO.retrieveTUs(ctx, product, bPartner, allowInfiniteCapacity);
    if (includeVirtualItem) {
        list.add(hupiItemProductDAO.retrieveVirtualPIMaterialItemProduct(ctx));
    }
    return list;
}
Also used : ISysConfigBL(org.adempiere.service.ISysConfigBL) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) IHUPIItemProductDAO(de.metas.handlingunits.IHUPIItemProductDAO)

Aggregations

I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)7 PlainHUPackingAware (de.metas.adempiere.gui.search.impl.PlainHUPackingAware)2 I_M_HU_PI (de.metas.handlingunits.model.I_M_HU_PI)2 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)2 ProductAndAttributes (de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)2 BigDecimal (java.math.BigDecimal)2 I_M_Product (org.compiere.model.I_M_Product)2 IHUPIItemProductDAO (de.metas.handlingunits.IHUPIItemProductDAO)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)1 I_M_HU_PI_Version (de.metas.handlingunits.model.I_M_HU_PI_Version)1 I_M_ShipmentSchedule (de.metas.handlingunits.model.I_M_ShipmentSchedule)1 IPackagingDAO (de.metas.inoutcandidate.api.IPackagingDAO)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)1 ISysConfigBL (org.adempiere.service.ISysConfigBL)1