use of de.metas.handlingunits.IMutableHUContext in project metasfresh-webui-api by metasfresh.
the class WEBUI_PickingSlotsClearingView_TakeOutCUsAndAddToTU method doIt.
@Override
protected String doIt() {
final List<I_M_HU> fromCUs = getSourceCUs();
final IAllocationSource source = HUListAllocationSourceDestination.of(fromCUs).setDestroyEmptyHUs(true);
final IAllocationDestination destination = HUListAllocationSourceDestination.of(getTargetTU());
final HULoader huLoader = HULoader.of(source, destination).setAllowPartialUnloads(false).setAllowPartialLoads(false);
//
// Unload CU/CUs and Load to selected TU
final List<Integer> huIdsDestroyedCollector = new ArrayList<>();
if (fromCUs.size() == 1) {
huLoader.load(prepareUnloadRequest(fromCUs.get(0), getQtyCU()).setForceQtyAllocation(true).addEmptyHUListener(EmptyHUListener.doBeforeDestroyed(hu -> huIdsDestroyedCollector.add(hu.getM_HU_ID()))).create());
} else {
final IHUContextFactory huContextFactory = Services.get(IHUContextFactory.class);
final IMutableHUContext huContext = huContextFactory.createMutableHUContext();
huContext.addEmptyHUListener(EmptyHUListener.doBeforeDestroyed(hu -> huIdsDestroyedCollector.add(hu.getM_HU_ID())));
huLoader.unloadAllFromSource(huContext);
}
// Remove from picking slots all destroyed HUs
pickingCandidateService.inactivateForHUIds(huIdsDestroyedCollector);
return MSG_OK;
}
use of de.metas.handlingunits.IMutableHUContext in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_ReceiveCUs method createAllocationRequest.
private final IAllocationRequest createAllocationRequest(final I_M_ReceiptSchedule rs) {
// Get Qty
final BigDecimal qty = getEffectiveQtyToReceive(rs);
if (qty.signum() <= 0) {
// nothing to do
return null;
}
final IMutableHUContext huContextInitial = Services.get(IHUContextFactory.class).createMutableHUContextForProcessing(getCtx());
final IAllocationRequest allocationRequest = AllocationUtils.createAllocationRequestBuilder().setHUContext(huContextInitial).setDateAsToday().setProduct(rs.getM_Product()).setQuantity(new Quantity(qty, rs.getC_UOM())).setFromReferencedModel(rs).setForceQtyAllocation(true).create();
return allocationRequest;
}
Aggregations