Search in sources :

Example 1 with I_M_HU_PI_Version

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

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

the class WebuiHUTransformParametersFiller method getM_HU_PI_Item_IDs.

public LookupValuesList getM_HU_PI_Item_IDs() {
    final ActionType actionType = getActionType();
    if (actionType != ActionType.TU_To_NewLUs) {
        return LookupValuesList.EMPTY;
    }
    final HUEditorRow tuRow = getSelectedRow();
    final I_M_HU tuHU = tuRow.getM_HU();
    final I_M_HU_PI_Version effectivePIVersion = handlingUnitsBL.getEffectivePIVersion(tuHU);
    Check.errorIf(effectivePIVersion == null, "tuHU is inconsistent; hu={}", tuHU);
    final List<I_M_HU_PI_Item> luPIItems = handlingUnitsDAO.retrieveParentPIItemsForParentPI(effectivePIVersion.getM_HU_PI(), null, tuHU.getC_BPartner());
    return luPIItems.stream().filter(luPIItem -> luPIItem.getM_HU_PI_Version().isCurrent() && luPIItem.getM_HU_PI_Version().isActive() && luPIItem.getM_HU_PI_Version().getM_HU_PI().isActive()).map(luPIItem -> IntegerLookupValue.of(luPIItem.getM_HU_PI_Item_ID(), WEBUI_ProcessHelper.buildHUPIItemString(luPIItem))).sorted(Comparator.comparing(IntegerLookupValue::getDisplayName)).collect(LookupValuesList.collect());
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) LookupDataSourceFactory(de.metas.ui.web.window.model.lookup.LookupDataSourceFactory) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) Env(org.compiere.util.Env) HUEditorRowFilter(de.metas.ui.web.handlingunits.HUEditorRowFilter) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) I_AD_Process_Para(org.compiere.model.I_AD_Process_Para) HashSet(java.util.HashSet) ADRefListItem(org.adempiere.ad.service.IADReferenceDAO.ADRefListItem) Select(de.metas.ui.web.handlingunits.HUEditorRowFilter.Select) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor) DisplayType(org.compiere.util.DisplayType) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) IADReferenceDAO(org.adempiere.ad.service.IADReferenceDAO) I_M_HU(de.metas.handlingunits.model.I_M_HU) Nullable(javax.annotation.Nullable) I_C_BPartner(org.compiere.model.I_C_BPartner) IADProcessDAO(de.metas.process.IADProcessDAO) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) HUTransformService(de.metas.handlingunits.allocation.transfer.HUTransformService) Services(org.adempiere.util.Services) List(java.util.List) WEBUI_ProcessHelper(de.metas.ui.web.handlingunits.util.WEBUI_ProcessHelper) StringLookupValue(de.metas.ui.web.window.datatypes.LookupValue.StringLookupValue) X_M_HU(de.metas.handlingunits.model.X_M_HU) Builder(lombok.Builder) Check(de.metas.printing.esb.base.util.Check) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) I_M_Product(de.metas.adempiere.model.I_M_Product) ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) Comparator(java.util.Comparator) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) IntegerLookupValue(de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Aggregations

IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)2 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)2 I_M_HU_PI_Version (de.metas.handlingunits.model.I_M_HU_PI_Version)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 (de.metas.handlingunits.model.I_M_HU)1 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)1 I_M_HU_PI (de.metas.handlingunits.model.I_M_HU_PI)1 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)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 ActionType (de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType)1 WEBUI_ProcessHelper (de.metas.ui.web.handlingunits.util.WEBUI_ProcessHelper)1