Search in sources :

Example 31 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_MoveToGarbage method doIt.

@Override
protected String doIt() throws Exception {
    final List<I_M_HU> husToDestroy = streamSelectedHUs(Select.ONLY_TOPLEVEL).collect(ImmutableList.toImmutableList());
    if (husToDestroy.isEmpty()) {
        throw new AdempiereException("@NoSelection@");
    }
    final Timestamp movementDate = Env.getDate(getCtx());
    huInventoryBL.moveToGarbage(husToDestroy, movementDate);
    huIdsDestroyed = husToDestroy.stream().map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet());
    return MSG_OK;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) Timestamp(java.sql.Timestamp)

Example 32 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_Transform method removeHUsIfDestroyed.

/**
 * @return true if at least one HU was removed
 */
private boolean removeHUsIfDestroyed(final Collection<Integer> huIds) {
    final ImmutableSet<Integer> destroyedHUIds = huIds.stream().distinct().map(huId -> load(huId, I_M_HU.class)).filter(Services.get(IHandlingUnitsBL.class)::isDestroyed).map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet());
    if (destroyedHUIds.isEmpty()) {
        return false;
    }
    final HUEditorView view = getView();
    final boolean changes = view.removeHUIds(destroyedHUIds);
    return changes;
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) GuavaCollectors(org.adempiere.util.GuavaCollectors) Autowired(org.springframework.beans.factory.annotation.Autowired) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) BigDecimal(java.math.BigDecimal) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU(de.metas.handlingunits.model.I_M_HU) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) IProcessDefaultParameter(de.metas.process.IProcessDefaultParameter) IProcessPrecondition(de.metas.process.IProcessPrecondition) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) ImmutableSet(com.google.common.collect.ImmutableSet) LookupSource(de.metas.ui.web.window.descriptor.DocumentLayoutElementFieldDescriptor.LookupSource) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) Collection(java.util.Collection) HUEditorProcessTemplate(de.metas.ui.web.handlingunits.HUEditorProcessTemplate) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) Profile(org.springframework.context.annotation.Profile) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) Services(org.adempiere.util.Services) List(java.util.List) Param(de.metas.process.Param) Profiles(de.metas.Profiles) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) RunOutOfTrx(de.metas.process.RunOutOfTrx) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) ActionType(de.metas.ui.web.handlingunits.process.WebuiHUTransformCommand.ActionType) ProcessParamLookupValuesProvider(de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView)

Example 33 with I_M_HU

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

Example 34 with I_M_HU

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

the class WEBUI_PickingSlotsClearingView_TakeOutTUAndAddToLU method doIt.

@Override
protected String doIt() throws Exception {
    final PickingSlotRow pickingSlotRow = getSingleSelectedPickingSlotRow();
    Check.assume(pickingSlotRow.isTU(), "Picking slot HU shall be a TU: {}", pickingSlotRow);
    final I_M_HU tuHU = InterfaceWrapperHelper.load(pickingSlotRow.getHuId(), I_M_HU.class);
    final HUEditorRow packingHURow = getSingleSelectedPackingHUsRow();
    Check.assume(packingHURow.isLU(), "Pack to HU shall be a LU: {}", packingHURow);
    final I_M_HU luHU = packingHURow.getM_HU();
    final BigDecimal qtyTU = BigDecimal.ONE;
    final List<Integer> huIdsDestroyedCollector = new ArrayList<>();
    HUTransformService.builder().emptyHUListener(EmptyHUListener.doBeforeDestroyed(hu -> huIdsDestroyedCollector.add(hu.getM_HU_ID()))).build().tuToExistingLU(tuHU, qtyTU, luHU);
    // Remove from picking slots all destroyed HUs
    pickingCandidateService.inactivateForHUIds(huIdsDestroyedCollector);
    return MSG_OK;
}
Also used : HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) EmptyHUListener(de.metas.handlingunits.storage.EmptyHUListener) Autowired(org.springframework.beans.factory.annotation.Autowired) HUTransformService(de.metas.handlingunits.allocation.transfer.HUTransformService) PickingCandidateService(de.metas.handlingunits.picking.PickingCandidateService) ArrayList(java.util.ArrayList) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) BigDecimal(java.math.BigDecimal) List(java.util.List) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) Check(org.adempiere.util.Check) I_M_HU(de.metas.handlingunits.model.I_M_HU) IProcessPrecondition(de.metas.process.IProcessPrecondition) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_HU(de.metas.handlingunits.model.I_M_HU) ArrayList(java.util.ArrayList) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) BigDecimal(java.math.BigDecimal)

Example 35 with I_M_HU

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

the class WEBUI_Picking_With_M_Source_HU_Base method checkSourceHuPrecondition.

protected final boolean checkSourceHuPrecondition() {
    final I_M_ShipmentSchedule shipmentSchedule = getView().getCurrentShipmentSchedule();
    final PickingHUsQuery query = PickingHUsQuery.builder().onlyIfAttributesMatchWithShipmentSchedules(true).shipmentSchedules(ImmutableList.of(shipmentSchedule)).onlyTopLevelHUs(true).build();
    final IHUPickingSlotBL huPickingSlotBL = Services.get(IHUPickingSlotBL.class);
    final List<I_M_HU> sourceHUs = huPickingSlotBL.retrieveAvailableSourceHUs(query);
    return !sourceHUs.isEmpty();
}
Also used : IHUPickingSlotBL(de.metas.handlingunits.picking.IHUPickingSlotBL) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_ShipmentSchedule(de.metas.inoutcandidate.model.I_M_ShipmentSchedule) PickingHUsQuery(de.metas.handlingunits.picking.IHUPickingSlotBL.PickingHUsQuery)

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