From ca72efb2e40ee49fb481ed9b5409d9fea3813758 Mon Sep 17 00:00:00 2001 From: Teo Sarca Date: Fri, 5 May 2017 17:12:40 +0300 Subject: [PATCH] WEBUI_PP_Order_IssueReceipt_BarcodeLauncher https://github.com/metasfresh/metasfresh-webui-api/issues/280 --- ...PP_Order_IssueReceipt_BarcodeLauncher.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/main/java/de/metas/ui/web/pporder/process/WEBUI_PP_Order_IssueReceipt_BarcodeLauncher.java diff --git a/src/main/java/de/metas/ui/web/pporder/process/WEBUI_PP_Order_IssueReceipt_BarcodeLauncher.java b/src/main/java/de/metas/ui/web/pporder/process/WEBUI_PP_Order_IssueReceipt_BarcodeLauncher.java new file mode 100644 index 000000000..e7f6cfdee --- /dev/null +++ b/src/main/java/de/metas/ui/web/pporder/process/WEBUI_PP_Order_IssueReceipt_BarcodeLauncher.java @@ -0,0 +1,64 @@ +package de.metas.ui.web.pporder.process; + +import org.adempiere.util.Services; +import org.adempiere.util.lang.impl.TableRecordReference; +import org.eevolution.api.IPPOrderDAO; + +import de.metas.fresh.ordercheckup.OrderCheckupBarcode; +import de.metas.process.JavaProcess; +import de.metas.process.Param; +import de.metas.process.ProcessExecutionResult.RecordsToOpen.OpenTarget; +import de.metas.ui.web.exceptions.EntityNotFoundException; +import de.metas.ui.web.pporder.WebPPOrderConfig; +import de.metas.ui.web.process.adprocess.WebuiProcess; +import de.metas.ui.web.process.descriptor.ProcessLayout.ProcessLayoutType; + +/* + * #%L + * metasfresh-webui-api + * %% + * Copyright (C) 2017 metas GmbH + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + +/** + * Accepts an {@link OrderCheckupBarcode}, searches for coresponding manufacturing order and then opens Issue/Receipt panel for it. + * + * @author metas-dev + * @task https://github.com/metasfresh/metasfresh-webui-api/issues/280 + */ +@WebuiProcess(layoutType = ProcessLayoutType.SingleOverlayField) +public class WEBUI_PP_Order_IssueReceipt_BarcodeLauncher extends JavaProcess +{ + @Param(parameterName = "Barcode", mandatory = true) + private String p_Barcode; + + @Override + protected String doIt() throws Exception + { + final int orderLineId = OrderCheckupBarcode.fromBarcodeString(p_Barcode).getC_OrderLine_ID(); + final int ppOrderId = Services.get(IPPOrderDAO.class).retrievePPOrderIdByOrderLineId(orderLineId); + if (ppOrderId <= 0) + { + throw new EntityNotFoundException("@NotFound@ @PP_Order_ID@"); + } + + final TableRecordReference ppOrderRef = TableRecordReference.of(org.eevolution.model.I_PP_Order.Table_Name, ppOrderId); + getResult().setRecordToOpen(ppOrderRef, WebPPOrderConfig.AD_WINDOW_ID_IssueReceipt.toInt(), OpenTarget.GridView); + return MSG_OK; + } +}