use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUI_Picking_PickQtyToNewHU method doIt.
@Override
protected String doIt() throws Exception {
final PickingSlotRow pickingSlotRow = getSingleSelectedRow();
final I_M_HU hu = createAndAddHU(pickingSlotRow);
addPickedQuantity(hu, pickingSlotRow);
final HUToReportWrapper huToReport = HUToReportWrapper.of(hu);
printPickingLabel(huToReport);
invalidateView();
invalidateParentView();
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_M_Source_HU_IssueTuQty method doIt.
@Override
protected String doIt() throws Exception {
final PPOrderLineRow row = getSingleSelectedRow();
final List<I_M_Source_HU> sourceHus = retrieveActiveSourceHus(row);
if (sourceHus.isEmpty()) {
throw new AdempiereException("@NoSelection@");
}
final Map<Integer, I_M_Source_HU> huId2SourceHu = new HashMap<>();
final ImmutableList<I_M_HU> husThatAreFlaggedAsSource = sourceHus.stream().peek(sourceHu -> huId2SourceHu.put(sourceHu.getM_HU_ID(), sourceHu)).map(I_M_Source_HU::getM_HU).collect(ImmutableList.toImmutableList());
final HUsToNewTUsRequest request = HUsToNewTUsRequest.builder().sourceHUs(husThatAreFlaggedAsSource).qtyTU(qtyTU.intValue()).build();
EmptyHUListener emptyHUListener = EmptyHUListener.doBeforeDestroyed(hu -> {
if (huId2SourceHu.containsKey(hu.getM_HU_ID())) {
SourceHUsService.get().snapshotSourceHU(huId2SourceHu.get(hu.getM_HU_ID()));
}
}, "Create snapshot of source-HU before it is destroyed");
final List<I_M_HU> extractedTUs = HUTransformService.builder().emptyHUListener(emptyHUListener).build().husToNewTUs(request);
final PPOrderLinesView ppOrderView = getView();
final int ppOrderId = ppOrderView.getPP_Order_ID();
Services.get(IHUPPOrderBL.class).createIssueProducer().setTargetOrderBOMLinesByPPOrderId(ppOrderId).createDraftIssues(extractedTUs);
getView().invalidateAll();
ppOrderView.invalidateAll();
return MSG_OK;
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUI_HUsToPick_PickCU method pickCUs.
private void pickCUs() {
final I_M_Product product = getProduct();
final I_C_UOM uom = productBL.getStockingUOM(product);
final Date date = SystemTime.asDate();
final int huIdToSplit = retrieveHUIdToSplit();
final List<I_M_HU> splitHUs = HUSplitBuilderCoreEngine.builder().huToSplit(load(huIdToSplit, I_M_HU.class)).requestProvider(huContext -> AllocationUtils.createAllocationRequestBuilder().setHUContext(huContext).setProduct(product).setQuantity(getQtyCU(), uom).setDate(date).setFromReferencedModel(// N/A
null).setForceQtyAllocation(false).create()).destination(HUProducerDestination.ofVirtualPI()).build().withPropagateHUValues().withAllowPartialUnloads(// we allow partial loads and unloads so if a user enters a very large number, then that will just account to "all of it" and there will be no error
true).performSplit();
final I_M_HU splitCU = ListUtils.singleElement(splitHUs);
addHUIdToCurrentPickingSlot(splitCU.getM_HU_ID());
if (isAutoProcess) {
final PickingSlotRow rowToProcess = getPickingSlotRow();
pickingCandidateService.processForHUIds(ImmutableList.of(rowToProcess.getHuId()), rowToProcess.getPickingSlotId(), OptionalInt.empty());
}
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method createNonAggregatedTU.
private I_M_HU createNonAggregatedTU(final HUEditorRow tuRow, final HUEditorRow luRow) {
final I_M_HU newTU = newHUTransformation().tuToNewTUs(tuRow.getM_HU(), BigDecimal.ONE).get(0);
if (luRow != null) {
final I_M_HU oldLU = luRow.getM_HU();
if (handlingUnitsBL.isDestroyed(oldLU)) {
final I_M_HU_PI_Item luPIItem = oldLU.getM_HU_LUTU_Configuration().getM_LU_HU_PI_Item();
final List<I_M_HU> tuToNewLUs = newHUTransformation().tuToNewLUs(newTU, BigDecimal.ONE, luPIItem, false);
huIDsToRemove.add(oldLU.getM_HU_ID());
huIDsAdded.add(tuToNewLUs.get(0).getM_HU_ID());
} else {
moveTUToLU(newTU.getM_HU_ID(), luRow, tuRow);
}
}
return newTU;
}
use of de.metas.handlingunits.model.I_M_HU in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method moveTUToLU.
private void moveTUToLU(final int tuId, final HUEditorRow luRow, final HUEditorRow tuRow) {
final I_M_HU newTU = create(Env.getCtx(), tuId, I_M_HU.class, ITrx.TRXNAME_ThreadInherited);
newHUTransformation().tuToExistingLU(newTU, BigDecimal.ONE, luRow.getM_HU());
}
Aggregations