Search in sources :

Example 6 with I_M_HU

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;
}
Also used : HUToReportWrapper(de.metas.handlingunits.report.HUToReportWrapper) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Example 7 with I_M_HU

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;
}
Also used : IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) I_M_Source_HU(de.metas.handlingunits.model.I_M_Source_HU) HashMap(java.util.HashMap) I_M_HU(de.metas.handlingunits.model.I_M_HU) HUsToNewTUsRequest(de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest) AdempiereException(org.adempiere.exceptions.AdempiereException) EmptyHUListener(de.metas.handlingunits.storage.EmptyHUListener) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow)

Example 8 with I_M_HU

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());
    }
}
Also used : FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) GuavaCollectors(org.adempiere.util.GuavaCollectors) Date(java.util.Date) HUSplitBuilderCoreEngine(de.metas.handlingunits.allocation.transfer.impl.HUSplitBuilderCoreEngine) InterfaceWrapperHelper.loadOutOfTrx(org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx) Autowired(org.springframework.beans.factory.annotation.Autowired) OptionalInt(java.util.OptionalInt) PickingCandidateService(de.metas.handlingunits.picking.PickingCandidateService) HUProducerDestination(de.metas.handlingunits.allocation.impl.HUProducerDestination) PackageableRow(de.metas.ui.web.picking.packageable.PackageableRow) BigDecimal(java.math.BigDecimal) IProductBL(de.metas.product.IProductBL) AllocationUtils(de.metas.handlingunits.allocation.impl.AllocationUtils) ImmutableList(com.google.common.collect.ImmutableList) SystemTime(org.adempiere.util.time.SystemTime) I_M_HU(de.metas.handlingunits.model.I_M_HU) 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) MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU(de.metas.ui.web.handlingunits.WEBUI_HU_Constants.MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_C_UOM(org.compiere.model.I_C_UOM) ITranslatableString(de.metas.i18n.ITranslatableString) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) Services(org.adempiere.util.Services) List(java.util.List) Param(de.metas.process.Param) AdempiereException(org.adempiere.exceptions.AdempiereException) ListUtils(org.adempiere.util.collections.ListUtils) PickingConfigRepository(de.metas.picking.api.PickingConfigRepository) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) IMsgBL(de.metas.i18n.IMsgBL) I_M_Product(de.metas.adempiere.model.I_M_Product) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) IProcessParametersCallout(de.metas.process.IProcessParametersCallout) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_Product(de.metas.adempiere.model.I_M_Product) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_C_UOM(org.compiere.model.I_C_UOM) Date(java.util.Date)

Example 9 with I_M_HU

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;
}
Also used : I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Example 10 with I_M_HU

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());
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU)

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