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;
}
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;
}
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);
}
}
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;
}
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();
}
Aggregations