Search in sources :

Example 1 with I_M_HU_LUTU_Configuration

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

the class WEBUI_PP_Order_Receipt method doIt.

@Override
@RunOutOfTrx
protected String doIt() throws Exception {
    final PPOrderLineRow selectedRow = getSingleSelectedRow();
    final IPPOrderReceiptHUProducer receiptCandidatesProducer = createReceiptCandidatesProducer(selectedRow);
    // Calculate and set the LU/TU config from packing info params and defaults
    final I_M_HU_LUTU_Configuration lutuConfig = getPackingInfoParams().createAndSaveNewLUTUConfig();
    receiptCandidatesProducer.setM_HU_LUTU_Configuration(lutuConfig);
    receiptCandidatesProducer.createReceiptCandidatesAndPlanningHUs();
    return MSG_OK;
}
Also used : I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) IPPOrderReceiptHUProducer(de.metas.handlingunits.pporder.api.IPPOrderReceiptHUProducer) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow) RunOutOfTrx(de.metas.process.RunOutOfTrx)

Example 2 with I_M_HU_LUTU_Configuration

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

the class PPOrderLinesLoader method computePackingInfo.

private String computePackingInfo(@NonNull final I_PP_Order ppOrder) {
    final IHUPPOrderBL huPPOrderBL = Services.get(IHUPPOrderBL.class);
    final I_M_HU_LUTU_Configuration lutuConfig = huPPOrderBL.createReceiptLUTUConfigurationManager(ppOrder).getCreateLUTUConfiguration();
    return extractPackingInfoString(lutuConfig);
}
Also used : IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)

Example 3 with I_M_HU_LUTU_Configuration

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

the class PackingInfoProcessParams method getDefaultLUTUConfig.

public I_M_HU_LUTU_Configuration getDefaultLUTUConfig() {
    if (_defaultLUTUConfig == null) {
        final I_M_HU_LUTU_Configuration defaultLUTUConfig = defaultLUTUConfigManager.getCreateLUTUConfiguration();
        // Apply adjustment rules to default LU/TU config
        if (enforceOneLUorTU) {
            adjustDefaultLUTUConfig_EnforceOneLUorTU(defaultLUTUConfig, enforceAvailableQtyTU);
        } else if (enforceAvailableQtyTU != null) {
            // IMPORTANT: this rule shall be applied if not enforceOneLUorTU
            adjustDefaultLUTUConfig_EnforceAvailableTUs(defaultLUTUConfig, enforceAvailableQtyTU);
        }
        if (enforcePhysicalTU) {
            // check if we need to do something
            boolean needToFallback;
            if (defaultLUTUConfig.getM_HU_PI_Item_Product_ID() <= 0) {
                // no piip specified at all
                needToFallback = true;
            } else {
                // check if the piip that we got is the virtual one. If yes, we need to fallback
                final IHUPIItemProductDAO hupiItemProductDAO = Services.get(IHUPIItemProductDAO.class);
                needToFallback = defaultLUTUConfig.getM_HU_PI_Item_Product_ID() == hupiItemProductDAO.retrieveVirtualPIMaterialItemProduct(Env.getCtx()).getM_HU_PI_Item_Product_ID();
            }
            if (needToFallback) {
                insertPhysicalFallbackTU(defaultLUTUConfig);
            }
        }
        // Make sure nobody is overriding the existing configuration
        if (defaultLUTUConfig.getM_HU_LUTU_Configuration_ID() > 0) {
            InterfaceWrapperHelper.setSaveDeleteDisabled(defaultLUTUConfig, true);
        }
        _defaultLUTUConfig = defaultLUTUConfig;
    }
    return _defaultLUTUConfig;
}
Also used : I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) IHUPIItemProductDAO(de.metas.handlingunits.IHUPIItemProductDAO)

Example 4 with I_M_HU_LUTU_Configuration

use of de.metas.handlingunits.model.I_M_HU_LUTU_Configuration 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 I_M_Product product = defaultLUTUConfig.getM_Product();
    final I_C_BPartner bPartner = defaultLUTUConfig.getC_BPartner();
    final boolean includeVirtualItem = !enforcePhysicalTU;
    final LookupValuesList huPIItemProducts = WEBUI_ProcessHelper.retrieveHUPIItemProducts(Env.getCtx(), product, bPartner, includeVirtualItem);
    return huPIItemProducts;
}
Also used : I_M_Product(org.compiere.model.I_M_Product) I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_C_BPartner(org.compiere.model.I_C_BPartner)

Example 5 with I_M_HU_LUTU_Configuration

use of de.metas.handlingunits.model.I_M_HU_LUTU_Configuration 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)

Aggregations

I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)12 I_M_ReceiptSchedule (de.metas.handlingunits.model.I_M_ReceiptSchedule)3 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)2 RunOutOfTrx (de.metas.process.RunOutOfTrx)2 BigDecimal (java.math.BigDecimal)2 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)2 TerminalException (de.metas.adempiere.form.terminal.TerminalException)1 IHUPIItemProductDAO (de.metas.handlingunits.IHUPIItemProductDAO)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 ILUTUConfigurationFactory (de.metas.handlingunits.allocation.ILUTUConfigurationFactory)1 ILUTUProducerAllocationDestination (de.metas.handlingunits.allocation.ILUTUProducerAllocationDestination)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_HU_PI (de.metas.handlingunits.model.I_M_HU_PI)1 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)1 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)1 I_M_HU_PI_Version (de.metas.handlingunits.model.I_M_HU_PI_Version)1 IPPOrderReceiptHUProducer (de.metas.handlingunits.pporder.api.IPPOrderReceiptHUProducer)1 ReceiptScheduleHUGenerator (de.metas.handlingunits.receiptschedule.impl.ReceiptScheduleHUGenerator)1 Quantity (de.metas.quantity.Quantity)1 PPOrderLineRow (de.metas.ui.web.pporder.PPOrderLineRow)1