Search in sources :

Example 1 with PPOrderLineRow

use of de.metas.ui.web.pporder.PPOrderLineRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_HUEditor_Launcher method checkPreconditionsApplicable.

@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
    if (!getSelectedRowIds().isSingleDocumentId()) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final PPOrderLinesView ppOrderLineView = getView();
    if (!(ppOrderLineView.isStatusPlanning() || ppOrderLineView.isStatusReview())) {
        final String internalReason = StringUtils.formatMessage("The PP_Order of the the current ppOrderLineView is not in planning or in review; ppOrderLineView={}", ppOrderLineView);
        return ProcessPreconditionsResolution.rejectWithInternalReason(internalReason);
    }
    final PPOrderLineRow singleSelectedRow = getSingleSelectedRow();
    if (!singleSelectedRow.isIssue()) {
        final String internalReason = StringUtils.formatMessage("The selected ppOrderLineRow is not an issue row; selectedRow={}", singleSelectedRow);
        return ProcessPreconditionsResolution.rejectWithInternalReason(internalReason);
    }
    if (singleSelectedRow.isProcessed()) {
        final String internalReason = StringUtils.formatMessage("The selected ppOrderLineRow is already flagged as processed; selectedRow={}", singleSelectedRow);
        return ProcessPreconditionsResolution.rejectWithInternalReason(internalReason);
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow)

Example 2 with PPOrderLineRow

use of de.metas.ui.web.pporder.PPOrderLineRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_HUEditor_Launcher method doIt.

@Override
protected String doIt() {
    final PPOrderLineRow ppOrderLineRow = getSingleSelectedRow();
    final int ppOrderBomLineId = ppOrderLineRow.getPP_Order_BOMLine_ID();
    final ViewId ppOrderLineViewId = getView().getViewId();
    final List<Integer> availableHUsIDs = retrieveHuIdsToShowInEditor(ppOrderBomLineId);
    final IView husToPickView = viewsRepo.createView(CreateViewRequest.builder(WEBUI_HU_Constants.WEBUI_HU_Window_ID, JSONViewDataType.includedView).setParentViewId(ppOrderLineViewId).setParentRowId(ppOrderLineRow.getId()).addStickyFilters(HUIdsFilterHelper.createFilter(availableHUsIDs)).addAdditionalRelatedProcessDescriptor(createIssueTopLevelHusDescriptor()).addAdditionalRelatedProcessDescriptor(createIssueTUsDescriptor()).addAdditionalRelatedProcessDescriptor(createSelectHuAsSourceHuDescriptor()).build());
    getResult().setWebuiIncludedViewIdToOpen(husToPickView.getViewId().getViewId());
    return MSG_OK;
}
Also used : IView(de.metas.ui.web.view.IView) ViewId(de.metas.ui.web.view.ViewId) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow)

Example 3 with PPOrderLineRow

use of de.metas.ui.web.pporder.PPOrderLineRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_Receipt method doIt.

@Override
@RunOutOfTrx
protected String doIt() throws Exception {
    final PPOrderLineRow selectedRow = getSingleSelectedRow();
    final IPPOrderReceiptHUProducer receiptCandidatesProducer = createReceiptCandidatesProducer(selectedRow);
    // Calculate and set the LU/TU config from packing info params and defaults
    final I_M_HU_LUTU_Configuration lutuConfig = getPackingInfoParams().createAndSaveNewLUTUConfig();
    receiptCandidatesProducer.setM_HU_LUTU_Configuration(lutuConfig);
    receiptCandidatesProducer.createReceiptCandidatesAndPlanningHUs();
    return MSG_OK;
}
Also used : I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) IPPOrderReceiptHUProducer(de.metas.handlingunits.pporder.api.IPPOrderReceiptHUProducer) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow) RunOutOfTrx(de.metas.process.RunOutOfTrx)

Example 4 with PPOrderLineRow

use of de.metas.ui.web.pporder.PPOrderLineRow 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 5 with PPOrderLineRow

use of de.metas.ui.web.pporder.PPOrderLineRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_M_Source_HU_Delete method doIt.

@Override
protected String doIt() throws Exception {
    final PPOrderLineRow rowToProcess = getSingleSelectedRow();
    final int huId = rowToProcess.getM_HU_ID();
    // unselect the row we just deleted the record of, to avoid an 'EntityNotFoundException'
    final boolean sourceWasDeleted = SourceHUsService.get().deleteSourceHuMarker(huId);
    if (sourceWasDeleted) {
        getView().invalidateAll();
    }
    invalidateView();
    return MSG_OK;
}
Also used : PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow)

Aggregations

PPOrderLineRow (de.metas.ui.web.pporder.PPOrderLineRow)7 PPOrderLinesView (de.metas.ui.web.pporder.PPOrderLinesView)3 I_M_Source_HU (de.metas.handlingunits.model.I_M_Source_HU)2 HUsToNewTUsRequest (de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)1 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)1 IPPOrderReceiptHUProducer (de.metas.handlingunits.pporder.api.IPPOrderReceiptHUProducer)1 EmptyHUListener (de.metas.handlingunits.storage.EmptyHUListener)1 RunOutOfTrx (de.metas.process.RunOutOfTrx)1 IView (de.metas.ui.web.view.IView)1 ViewId (de.metas.ui.web.view.ViewId)1 HashMap (java.util.HashMap)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1