Search in sources :

Example 26 with I_M_HU

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

the class WebuiHUTransformCommand method action_SplitTU_To_NewTUs.

/**
 * Split a given number of TUs from current selected TU line to new TUs.
 *
 * @param tuRow
 * @param qtyTU
 * @param tuPI
 * @return
 */
private WebuiHUTransformCommandResult action_SplitTU_To_NewTUs(final HUEditorRow tuRow, final BigDecimal qtyTU) {
    final IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
    // TODO: if qtyTU is the "maximum", then don't do anything, but show a user message
    final I_M_HU fromTU = tuRow.getM_HU();
    final I_M_HU fromTopLevelHU = handlingUnitsBL.getTopLevelParent(fromTU);
    final List<I_M_HU> createdHUs = newHUTransformation().tuToNewTUs(fromTU, qtyTU);
    final WebuiHUTransformCommandResultBuilder resultBuilder = WebuiHUTransformCommandResult.builder().huIdsToAddToView(createdHUs.stream().map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet()));
    if (handlingUnitsBL.isDestroyedRefreshFirst(fromTopLevelHU)) {
        resultBuilder.huIdToRemoveFromView(fromTopLevelHU.getM_HU_ID());
    } else {
        resultBuilder.huIdChanged(fromTopLevelHU.getM_HU_ID());
    }
    return resultBuilder.build();
}
Also used : WebuiHUTransformCommandResultBuilder(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommandResult.WebuiHUTransformCommandResultBuilder) IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Example 27 with I_M_HU

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

the class WebuiHUTransformParametersFiller method getParentHUIdOfSelectedRow.

private int getParentHUIdOfSelectedRow() {
    final HUEditorRow huRow = getSelectedRow();
    final I_M_HU hu = huRow.getM_HU();
    final int parentIdOfSelectedHU = handlingUnitsDAO.retrieveParentId(hu);
    return parentIdOfSelectedHU;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 28 with I_M_HU

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

Example 29 with I_M_HU

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

the class WEBUI_M_HU_Pick_ParametersFiller method createShipmentSchedulesValidationRule.

private static IValidationRule createShipmentSchedulesValidationRule(final int huId) {
    final StringBuilder sqlWhereClause = new StringBuilder();
    sqlWhereClause.append(I_M_ShipmentSchedule.COLUMNNAME_Processed).append("=").append(DB.TO_BOOLEAN(false));
    final int productId = getSingleProductId(huId);
    sqlWhereClause.append(" AND ").append(I_M_ShipmentSchedule.COLUMNNAME_M_Product_ID).append("=").append(productId);
    final I_M_HU hu = load(huId, I_M_HU.class);
    if (hu.getC_BPartner_ID() > 0) {
        sqlWhereClause.append(" AND COALESCE(").append(I_M_ShipmentSchedule.COLUMNNAME_C_BPartner_Override_ID).append(", ").append(I_M_ShipmentSchedule.COLUMNNAME_C_BPartner_ID).append(") = ").append(hu.getC_BPartner_ID());
    }
    return Services.get(IValidationRuleFactory.class).createSQLValidationRule(sqlWhereClause.toString());
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) IValidationRuleFactory(org.adempiere.ad.validationRule.IValidationRuleFactory)

Example 30 with I_M_HU

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

the class WEBUI_M_HU_Pick_ParametersFiller method getSingleProductId.

private static final int getSingleProductId(final int huId) {
    final I_M_HU hu = InterfaceWrapperHelper.load(huId, I_M_HU.class);
    final List<Integer> productIds = Services.get(IHUContextFactory.class).createMutableHUContext().getHUStorageFactory().getStorage(hu).getProductStorages().stream().map(IHUProductStorage::getM_Product_ID).distinct().collect(ImmutableList.toImmutableList());
    if (productIds.isEmpty()) {
        throw new AdempiereException("Empty HUs are not allowed");
    }
    if (productIds.size() > 1) {
        throw new AdempiereException("Multi product HUs are not allowed");
    }
    return productIds.get(0);
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) IHUProductStorage(de.metas.handlingunits.storage.IHUProductStorage)

Aggregations

I_M_HU (de.metas.handlingunits.model.I_M_HU)43 AdempiereException (org.adempiere.exceptions.AdempiereException)12 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)11 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)7 List (java.util.List)7 Services (org.adempiere.util.Services)6 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)5 IProcessPrecondition (de.metas.process.IProcessPrecondition)5 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ImmutableList (com.google.common.collect.ImmutableList)4 IAllocationSource (de.metas.handlingunits.allocation.IAllocationSource)4 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)4 Param (de.metas.process.Param)4 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)4 BigDecimal (java.math.BigDecimal)4 Collection (java.util.Collection)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)3