org.eevolution.process.CompletePrintOrder:

* fixed indentation
* use current defined Adempiere's exceptions
This commit is contained in:
teo_sarca 2008-09-03 20:41:06 +00:00
parent 164a78d163
commit be7554be13
1 changed files with 33 additions and 20 deletions

View File

@ -17,6 +17,9 @@ package org.eevolution.process;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.FillMandatoryException;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.PrintInfo; import org.compiere.model.PrintInfo;
import org.compiere.print.MPrintFormat; import org.compiere.print.MPrintFormat;
@ -40,6 +43,7 @@ public class CompletePrintOrder extends SvrProcess {
private int p_PP_Order_ID = 0; private int p_PP_Order_ID = 0;
private boolean p_IsPrintPickList = false; private boolean p_IsPrintPickList = false;
private boolean p_IsPrintWorkflow = false; private boolean p_IsPrintWorkflow = false;
@SuppressWarnings("unused")
private boolean p_IsPrintPackList = false; // for future use private boolean p_IsPrintPackList = false; // for future use
private boolean p_IsComplete = false; private boolean p_IsComplete = false;
@ -74,48 +78,57 @@ public class CompletePrintOrder extends SvrProcess {
* @throws Exception * @throws Exception
* if not successful * if not successful
*/ */
protected String doIt() throws Exception { protected String doIt() throws Exception
{
MPrintFormat format = null;
Language language = Language.getLoginLanguage(); // Base Language Language language = Language.getLoginLanguage(); // Base Language
if (p_PP_Order_ID == 0) if (p_PP_Order_ID == 0)
throw new IllegalArgumentException(Msg.translate(getCtx(),MPPOrder.COLUMNNAME_PP_Order_ID) + " == 0"); {
throw new FillMandatoryException(MPPOrder.COLUMNNAME_PP_Order_ID);
}
if (p_IsComplete) { if (p_IsComplete)
{
MPPOrder order = new MPPOrder(getCtx(), p_PP_Order_ID, get_TrxName()); MPPOrder order = new MPPOrder(getCtx(), p_PP_Order_ID, get_TrxName());
if (order.isAvailable()) { if (order.isAvailable())
order.completeIt(); {
order.setDocStatus(MPPOrder.DOCACTION_Complete); String status = order.completeIt();
order.setDocAction(MPPOrder.ACTION_Close); order.setDocStatus(status);
order.saveEx(); order.saveEx();
} else { if (!MPPOrder.DOCSTATUS_Completed.equals(status))
{
throw new AdempiereException(order.getProcessMsg());
}
}
else
{
return Msg.translate(Env.getCtx(), "NoQtyAvailable"); return Msg.translate(Env.getCtx(), "NoQtyAvailable");
} }
} }
if (p_IsPrintPickList) { if (p_IsPrintPickList)
{
// Get Format & Data // Get Format & Data
ReportEngine re = ReportEngine.get(getCtx(), ReportEngine.MANUFACTURING_ORDER,getRecord_ID()); ReportEngine re = ReportEngine.get(getCtx(), ReportEngine.MANUFACTURING_ORDER, p_PP_Order_ID);
ReportCtl.preview(re); ReportCtl.preview(re);
re.print(); re.print();
} }
if (p_IsPrintWorkflow) { if (p_IsPrintWorkflow)
{
// Get Format & Data // Get Format & Data
MPrintFormat format = MPrintFormat.get(getCtx(), MPrintFormat.getPrintFormat_ID(
format = MPrintFormat.get(getCtx(), MPrintFormat.getPrintFormat_ID(
"Manufacturing Order Workflow", MPPOrder.Table_ID, getAD_Client_ID()), "Manufacturing Order Workflow", MPPOrder.Table_ID, getAD_Client_ID()),
false); false);
format.setLanguage(language); format.setLanguage(language);
format.setTranslationLanguage(language); format.setTranslationLanguage(language);
// query // query
MQuery query = new MQuery("PP_Order"); MQuery query = new MQuery(MPPOrder.Table_Name);
query.addRestriction("PP_Order_ID", MQuery.EQUAL, p_PP_Order_ID); query.addRestriction(MPPOrder.COLUMNNAME_PP_Order_ID, MQuery.EQUAL, p_PP_Order_ID);
// Engine // Engine
PrintInfo info = new PrintInfo("PP_Order", MPPOrder.Table_ID,getRecord_ID()); PrintInfo info = new PrintInfo("PP_Order", MPPOrder.Table_ID, p_PP_Order_ID);
ReportEngine re = new ReportEngine(getCtx(), format, query, info); ReportEngine re = new ReportEngine(getCtx(), format, query, info);
ReportCtl.preview(re); ReportCtl.preview(re);
re.print(); // prints only original re.print(); // prints only original