/** * Invoke the form VCreateFromPackage * * @param ctx context * @param WindowNo window no * @param mTab tab * @param mField field * @param value value * @return null or error message */ public String createFrom( final Properties ctx, final int WindowNo, final GridTab mTab, final GridField mField, final Object value) { final I_C_Invoice invoice = InterfaceWrapperHelper.create(mTab, I_C_Invoice.class); if (invoice.getC_Invoice_ID() <= 0) { return ""; } final I_C_DocType dt = invoice.getC_DocTypeTarget(); if (!Constants.DOCBASETYPE_AEInvoice.equals(dt.getDocBaseType()) || !CommissionConstants.COMMISSON_INVOICE_DOCSUBTYPE_CORRECTION.equals( dt.getDocSubType())) { // nothing to do final IDocumentPA docPA = Services.get(IDocumentPA.class); final I_C_DocType dtCorr = docPA.retrieve( ctx, invoice.getAD_Org_ID(), Constants.DOCBASETYPE_AEInvoice, CommissionConstants.COMMISSON_INVOICE_DOCSUBTYPE_CORRECTION, true, null); if (dtCorr != null) { final String msg = Msg.getMsg( ctx, MSG_INVOICECORR_CREATEFROM_WRONG_DOCTYPE_1P, new Object[] {dtCorr.getName()}); return msg; } else { throw new AdempiereException( "Missing C_DocType with DocBaseType='" + Constants.DOCBASETYPE_AEInvoice + "' and DocSubType='" + CommissionConstants.COMMISSON_INVOICE_DOCSUBTYPE_CORRECTION + "'"); } } final String swingclassname = "de.metas.commission.form.VCreateCorrections"; final String zkclassname = "not.yet.implemented"; final String classname; if (Ini.isClient()) { classname = swingclassname; } else { classname = zkclassname; return ""; } ICreateFrom cf = null; Class cl; try { if (Ini.isClient()) { cl = Class.forName(classname); } else { cl = Thread.currentThread().getContextClassLoader().loadClass(classname); } } catch (final ClassNotFoundException e) { log.error(e.getLocalizedMessage(), e); return e.getLocalizedMessage(); } if (cl != null) { try { java.lang.reflect.Constructor<? extends ICreateFrom> ctor = cl.getConstructor(I_C_Invoice.class, int.class); cf = ctor.newInstance(invoice, WindowNo); } catch (Throwable e) { log.error(e.getLocalizedMessage(), e); return e.getLocalizedMessage(); } } if (cf != null) { if (cf.isInitOK()) { cf.showWindow(); cf.closeWindow(); mTab.dataRefresh(); } else cf.closeWindow(); } return ""; } // createShippingPackages