use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.
the class PickingSlotsClearingViewBasedProcess method getSingleSelectedPickingSlotTopLevelHU.
protected final I_M_HU getSingleSelectedPickingSlotTopLevelHU() {
final PickingSlotRow huRow = getSingleSelectedPickingSlotRow();
Check.assume(huRow.isTopLevelHU(), "row {} shall be a top level HU", huRow);
final I_M_HU fromHU = InterfaceWrapperHelper.load(huRow.getHuId(), I_M_HU.class);
return fromHU;
}
use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.
the class WEBUI_PickingSlotsClearingView_TakeOutHU method doIt.
@Override
protected String doIt() {
//
// Get the HU
final PickingSlotRow huRow = getSingleSelectedPickingSlotRow();
Check.assume(huRow.isTopLevelHU(), "row {} shall be a top level HU", huRow);
final I_M_HU hu = InterfaceWrapperHelper.load(huRow.getHuId(), I_M_HU.class);
final String huStatus = hu.getHUStatus();
//
// Remove the HU from it's picking slot
huPickingSlotBL.removeFromPickingSlotQueueRecursivelly(hu);
//
// Make sure the HU has the BPartner/Location of the picking slot
final PickingSlotRow pickingSlotRow = getRootRowForSelectedPickingSlotRows();
if (pickingSlotRow.getBPartnerId() > 0) {
hu.setC_BPartner_ID(pickingSlotRow.getBPartnerId());
hu.setC_BPartner_Location_ID(pickingSlotRow.getBPartnerLocationId());
InterfaceWrapperHelper.save(hu);
}
//
// Move the HU to an after picking locator
final I_M_Locator afterPickingLocator = huWarehouseDAO.suggestAfterPickingLocator(hu.getM_Locator());
if (afterPickingLocator == null) {
throw new AdempiereException("No after picking locator found for " + hu.getM_Locator());
}
if (afterPickingLocator.getM_Locator_ID() != hu.getM_Locator_ID()) {
huMovementBL.moveHUsToLocator(ImmutableList.of(hu), afterPickingLocator);
//
// FIXME: workaround to restore HU's HUStatus (i.e. which was changed from Picked to Active by the moveHUsToLocator() method, indirectly).
// See https://github.com/metasfresh/metasfresh-webui-api/issues/678#issuecomment-344876035, that's the stacktrace where the HU status was set to Active.
InterfaceWrapperHelper.refresh(hu, ITrx.TRXNAME_ThreadInherited);
if (!Objects.equal(huStatus, hu.getHUStatus())) {
final IHUContext huContext = huContextFactory.createMutableHUContext();
handlingUnitsBL.setHUStatus(huContext, hu, huStatus);
save(hu);
}
}
//
// Inactive all those picking candidates
pickingCandidateService.inactivateForHUId(hu.getM_HU_ID());
husExtractedEvents.add(HUExtractedFromPickingSlotEvent.builder().huId(hu.getM_HU_ID()).bpartnerId(hu.getC_BPartner_ID()).bpartnerLocationId(hu.getC_BPartner_Location_ID()).build());
return MSG_OK;
}
use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.
the class WEBUI_PickingSlotsClearingView_TakeOutHU method checkPreconditionsApplicable.
@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
if (selectedRowIds.isEmpty()) {
return ProcessPreconditionsResolution.rejectBecauseNoSelection();
}
if (!selectedRowIds.isSingleDocumentId()) {
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}
final PickingSlotRow row = getSingleSelectedPickingSlotRow();
if (!row.isTopLevelHU()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("select a top level HU");
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.
the class WEBUI_PickingSlotsClearingView_TakeOutMultiHUsAndAddToNewHU method checkPreconditionsApplicable.
@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
final List<PickingSlotRow> pickingSlotRows = getSelectedPickingSlotRows();
if (pickingSlotRows.size() <= 1) {
return ProcessPreconditionsResolution.rejectWithInternalReason("select more than one HU");
}
final Set<PickingSlotRowId> rootRowIds = getRootRowIdsForSelectedPickingSlotRows();
if (rootRowIds.size() > 1) {
return ProcessPreconditionsResolution.rejectWithInternalReason("all selected HU rows shall be from one picking slot");
}
for (final PickingSlotRow pickingSlotRow : pickingSlotRows) {
if (!pickingSlotRow.isPickedHURow()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("select an HU");
}
if (!pickingSlotRow.isTopLevelHU()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("select an top level HU");
}
}
//
return ProcessPreconditionsResolution.accept();
}
use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.
the class WEBUI_Picking_M_Picking_Candidate_Process method doIt.
@Override
protected String doIt() throws Exception {
final PickingSlotRow rowToProcess = getSingleSelectedRow();
pickingCandidateService.processForHUIds(ImmutableList.of(rowToProcess.getHuId()), rowToProcess.getPickingSlotId(), OptionalInt.empty());
return MSG_OK;
}
Aggregations