Search in sources :

Example 16 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow 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 17 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class WebuiHUTransformParametersFiller method getActions.

/**
 * @return the actions that are available according to which row is currently selected and to also according to whether there are already existing TUs or LUs in the context.
 */
public final LookupValuesList getActions(final int processId) {
    final Set<String> allowedActions = new HashSet<>();
    final HUEditorRow huRow = getSelectedRow();
    if (huRow.isCU()) {
        allowedActions.addAll(getActionTypesForCUs());
    } else if (huRow.isTU()) {
        allowedActions.addAll(getActionTypesForTUs());
    } else if (huRow.isLU()) {
        allowedActions.add(ActionType.LU_Set_Ownership.toString());
    }
    final IADProcessDAO adProcessDAO = Services.get(IADProcessDAO.class);
    final I_AD_Process_Para processParameter = adProcessDAO.retriveProcessParameter(Env.getCtx(), processId, WEBUI_M_HU_Transform.PARAM_Action);
    final int actionsReferenceId = processParameter.getAD_Reference_Value_ID();
    final Collection<ADRefListItem> allActiveActionItems = adReferenceDAO.retrieveListItems(actionsReferenceId);
    final String adLanguage = Env.getAD_Language();
    return allActiveActionItems.stream().filter(item -> allowedActions.contains(item.getValueName())).map(item -> StringLookupValue.of(item.getValueName(), item.getName())).sorted(Comparator.comparing(lookupValue -> lookupValue.getDisplayName(adLanguage))).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_AD_Process_Para(org.compiere.model.I_AD_Process_Para) IADProcessDAO(de.metas.process.IADProcessDAO) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) HashSet(java.util.HashSet) ADRefListItem(org.adempiere.ad.service.IADReferenceDAO.ADRefListItem)

Example 18 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow 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 19 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_ReturnTUsToVendor method checkPreconditionsApplicable.

@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
    if (!isHUEditorView()) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
    }
    final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
    if (!selectedRowIds.isSingleDocumentId()) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final DocumentId rowId = selectedRowIds.getSingleDocumentId();
    final HUEditorRow huRow = getView().getById(rowId);
    if (huRow.isLU()) {
        if (!huRow.hasIncludedTUs()) {
            return ProcessPreconditionsResolution.rejectWithInternalReason("no TUs");
        }
    } else if (huRow.isTU()) {
    // OK
    } else {
        return ProcessPreconditionsResolution.rejectWithInternalReason("not a LU or TU");
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 20 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class PickingHUsRepositoryTests method test_retrieveHUsIndexedByPickingSlotId.

private void test_retrieveHUsIndexedByPickingSlotId(@NonNull final String pickingCandidateStatus, final boolean pickingRackSystem) {
    final int pickingSlotId = createPickingSlot(pickingRackSystem).getM_PickingSlot_ID();
    final I_M_HU hu = newInstance(I_M_HU.class);
    hu.setHUStatus(X_M_HU.HUSTATUS_Active);
    save(hu);
    final int huId = hu.getM_HU_ID();
    final I_M_Picking_Candidate pickingCandidate = newInstance(I_M_Picking_Candidate.class);
    pickingCandidate.setM_ShipmentSchedule_ID(M_SHIPMENT_SCHEDULE_ID);
    pickingCandidate.setM_HU_ID(huId);
    pickingCandidate.setM_PickingSlot_ID(pickingSlotId);
    pickingCandidate.setStatus(pickingCandidateStatus);
    save(pickingCandidate);
    final HUEditorRow huEditorRow = HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofTopLevelHU(huId)).setType(HUEditorRowType.LU).setTopLevel(true).build();
    final boolean expectNoRows = X_M_Picking_Candidate.STATUS_CL.equals(pickingCandidateStatus) && pickingRackSystem;
    final MockedHUEditorViewRepository huEditorViewRepository = new MockedHUEditorViewRepository();
    if (!expectNoRows) {
        huEditorViewRepository.addRow(huEditorRow);
    }
    final PickingHURowsRepository pickingHUsRepository = new PickingHURowsRepository(huEditorViewRepository);
    final ListMultimap<Integer, PickedHUEditorRow> result = pickingHUsRepository.retrievePickedHUsIndexedByPickingSlotId(PickingSlotRepoQuery.of(M_SHIPMENT_SCHEDULE_ID));
    if (expectNoRows) {
        // if 'pickingCandidate' is "closed", then nothing shall be returned
        assertThat(result.isEmpty()).isTrue();
    } else {
        assertThat(result.size()).isEqualTo(1);
        assertThat(result.get(pickingSlotId)).hasSize(1);
        final boolean expectedProcessed = !X_M_Picking_Candidate.STATUS_IP.equals(pickingCandidateStatus);
        final PickedHUEditorRow resultRow = result.get(pickingSlotId).get(0);
        final PickedHUEditorRow expectedRow = new PickedHUEditorRow(huEditorRow, expectedProcessed);
        assertThat(resultRow).isEqualTo(expectedRow);
    }
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)

Aggregations

HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)28 I_M_HU (de.metas.handlingunits.model.I_M_HU)8 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)6 List (java.util.List)5 NonNull (lombok.NonNull)5 Services (org.adempiere.util.Services)5 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 HUTransformService (de.metas.handlingunits.allocation.transfer.HUTransformService)3 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)3 ITranslatableString (de.metas.i18n.ITranslatableString)3 Check (de.metas.printing.esb.base.util.Check)3 PickedHUEditorRow (de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)3 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)3 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)3 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)3 LookupDataSource (de.metas.ui.web.window.model.lookup.LookupDataSource)3 LookupDataSourceFactory (de.metas.ui.web.window.model.lookup.LookupDataSourceFactory)3 Comparator (java.util.Comparator)3 HashSet (java.util.HashSet)3 Nullable (javax.annotation.Nullable)3