Search in sources :

Example 1 with I_M_HU_PI_Item

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

the class PackingInfoProcessParams method configureLUTUConfigLU.

private void configureLUTUConfigLU(@NonNull final I_M_HU_LUTU_Configuration lutuConfigNew, final int lu_PI_Item_ID) {
    if (lu_PI_Item_ID > 0) {
        final BigDecimal qtyLU = getQtyLU();
        if (qtyLU == null || qtyLU.signum() <= 0) {
            throw new FillMandatoryException(PARAM_QtyLU);
        }
        final I_M_HU_PI_Item luPI_Item = loadOutOfTrx(lu_PI_Item_ID, I_M_HU_PI_Item.class);
        lutuConfigNew.setM_LU_HU_PI_Item(luPI_Item);
        lutuConfigNew.setM_LU_HU_PI(luPI_Item.getM_HU_PI_Version().getM_HU_PI());
        lutuConfigNew.setQtyLU(qtyLU);
        lutuConfigNew.setIsInfiniteQtyLU(false);
    } else {
        lutuConfigNew.setM_LU_HU_PI(null);
        lutuConfigNew.setM_LU_HU_PI_Item(null);
        lutuConfigNew.setQtyLU(BigDecimal.ZERO);
    }
}
Also used : I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) BigDecimal(java.math.BigDecimal)

Example 2 with I_M_HU_PI_Item

use of de.metas.handlingunits.model.I_M_HU_PI_Item 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 3 with I_M_HU_PI_Item

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

the class PackingInfoProcessParams method getAvailableLuPIItems.

private List<I_M_HU_PI_Item> getAvailableLuPIItems(@NonNull final I_M_HU_PI_Item_Product pip, @Nullable final I_C_BPartner bPartner) {
    final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
    final I_M_HU_PI piOfCurrentPip = pip.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
    final List<I_M_HU_PI_Item> luPIItems = handlingUnitsDAO.retrieveParentPIItemsForParentPI(piOfCurrentPip, // huUnitType
    null, bPartner);
    return luPIItems;
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI)

Example 4 with I_M_HU_PI_Item

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

the class WEBUIHUCreationWithSerialNumberService method createNonAggregatedTU.

private I_M_HU createNonAggregatedTU(final HUEditorRow tuRow, final HUEditorRow luRow) {
    final I_M_HU newTU = newHUTransformation().tuToNewTUs(tuRow.getM_HU(), BigDecimal.ONE).get(0);
    if (luRow != null) {
        final I_M_HU oldLU = luRow.getM_HU();
        if (handlingUnitsBL.isDestroyed(oldLU)) {
            final I_M_HU_PI_Item luPIItem = oldLU.getM_HU_LUTU_Configuration().getM_LU_HU_PI_Item();
            final List<I_M_HU> tuToNewLUs = newHUTransformation().tuToNewLUs(newTU, BigDecimal.ONE, luPIItem, false);
            huIDsToRemove.add(oldLU.getM_HU_ID());
            huIDsAdded.add(tuToNewLUs.get(0).getM_HU_ID());
        } else {
            moveTUToLU(newTU.getM_HU_ID(), luRow, tuRow);
        }
    }
    return newTU;
}
Also used : I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Example 5 with I_M_HU_PI_Item

use of de.metas.handlingunits.model.I_M_HU_PI_Item 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_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)6 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 I_M_HU (de.metas.handlingunits.model.I_M_HU)2 I_M_HU_PI (de.metas.handlingunits.model.I_M_HU_PI)2 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)2 I_M_HU_PI_Version (de.metas.handlingunits.model.I_M_HU_PI_Version)2 BigDecimal (java.math.BigDecimal)2 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)2 I_M_Product (de.metas.adempiere.model.I_M_Product)1 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)1 HUTransformService (de.metas.handlingunits.allocation.transfer.HUTransformService)1 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)1 X_M_HU (de.metas.handlingunits.model.X_M_HU)1 Check (de.metas.printing.esb.base.util.Check)1 IADProcessDAO (de.metas.process.IADProcessDAO)1 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)1 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)1 HUEditorRowFilter (de.metas.ui.web.handlingunits.HUEditorRowFilter)1 Select (de.metas.ui.web.handlingunits.HUEditorRowFilter.Select)1 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)1