For EDII
This commit is contained in:
parent
47cdbe0c6a
commit
158da6483f
File diff suppressed because it is too large
Load Diff
|
|
@ -7,11 +7,13 @@ import java.util.logging.Level;
|
|||
import org.adempiere.base.IDocFactory;
|
||||
import org.compiere.acct.Doc;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
import andromedia.midsuit.doc.MID_DocInvoice;
|
||||
import andromedia.midsuit.doc.MID_DocMRPPPO;
|
||||
import andromedia.midsuit.doc.MID_DocMidRequsiition;
|
||||
import andromedia.midsuit.model.MID_MRequisitionTrx;
|
||||
|
|
@ -55,6 +57,9 @@ public class MID_DocFactory implements IDocFactory{
|
|||
return new MID_DocMidRequsiition(as,rs,trxName);
|
||||
if(tableName.equals(MID_PPO.Table_Name))
|
||||
return new MID_DocMRPPPO(as, rs, trxName);
|
||||
if(tableName.equals(MInvoice.Table_Name)) {
|
||||
s_log.log(Level.SEVERE,"IN");
|
||||
return new MID_DocInvoice(as, rs, trxName);}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>edii.midsuit.feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1 @@
|
|||
bin.includes = feature.xml
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="edii.midsuit.feature"
|
||||
label="Feature"
|
||||
version="1.0.0.qualifier">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
[Enter Feature Description here.]
|
||||
</description>
|
||||
|
||||
<copyright url="http://www.example.com/copyright">
|
||||
[Enter Copyright Description here.]
|
||||
</copyright>
|
||||
|
||||
<license url="http://www.example.com/license">
|
||||
[Enter License Description here.]
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="edii.midsuit.project"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>edii.midsuit.project</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ds.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: EDII Midsuit
|
||||
Bundle-SymbolicName: edii.midsuit.project
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: org.adempiere.base;bundle-version="5.1.0",
|
||||
org.adempiere.plugin.utils;bundle-version="5.1.0",
|
||||
org.eclipse.osgi.services;bundle-version="3.6.0",
|
||||
zk;bundle-version="8.0.2",
|
||||
zcommon;bundle-version="8.0.2",
|
||||
zul;bundle-version="8.0.2",
|
||||
org.adempiere.ui.zk,
|
||||
org.adempiere.ui;bundle-version="5.1.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Service-Component: OSGI-INF/MID_ProcessFactory.xml,OSGI-INF/MID_ModelFactory.xml,OSGI-INF/MID_CalloutFactory.xml,OSGI-INF/MID_ValidatorFactory.xml,OSGI-INF/MID_CreateFromFactory.xml,OSGI-INF/MID_FormFactory.xml,
|
||||
OSGI-INF/MID_DocFactory.xml
|
||||
Import-Package: org.compiere.apps,
|
||||
org.compiere.grid,
|
||||
org.compiere.minigrid
|
||||
Bundle-Activator: org.adempiere.plugin.utils.AdempiereActivator
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.callout">
|
||||
<implementation class="edii.midsuit.factory.MID_CalloutFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IColumnCalloutFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.createfrom">
|
||||
<implementation class="edii.midsuit.factory.MID_CreateFromFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.ICreateFromFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.doc">
|
||||
<implementation class="edii.midsuit.factory.MID_DocFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<property name="gaap" type="String" value="*"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IDocFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.form">
|
||||
<implementation class="edii.midsuit.factory.MID_FormFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.webui.factory.IFormFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.model">
|
||||
<implementation class="edii.midsuit.factory.MID_ModelFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IModelFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.process">
|
||||
<implementation class="edii.midsuit.factory.MID_ProcessFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.base.IProcessFactory"/>
|
||||
</service>
|
||||
</scr:component>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="edii.midsuit.validator">
|
||||
<implementation class="edii.midsuit.factory.MID_ValidatorFactory"/>
|
||||
<property name="service.ranking" type="Integer" value="1"/>
|
||||
<reference bind="bindEventManager" cardinality="1..1" interface="org.adempiere.base.event.IEventManager" name="IEventManager" policy="static" unbind="unbindEventManager"/>
|
||||
</scr:component>
|
||||
Binary file not shown.
|
|
@ -0,0 +1,11 @@
|
|||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
OSGI-INF/MID_ProcessFactory.xml,\
|
||||
OSGI-INF/MID_ModelFactory.xml,\
|
||||
OSGI-INF/MID_CalloutFactory.xml,\
|
||||
OSGI-INF/MID_ValidatorFactory.xml,\
|
||||
OSGI-INF/MID_CreateFromFactory.xml,\
|
||||
OSGI-INF/MID_FormFactory.xml,\
|
||||
OSGI-INF/MID_DocFactory.xml
|
||||
source.. = src/
|
||||
Binary file not shown.
|
|
@ -0,0 +1,35 @@
|
|||
package edii.midsuit.callout;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.IColumnCallout;
|
||||
import org.compiere.model.CalloutEngine;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.X_C_OrderLine;
|
||||
|
||||
public class EDI_CalloutOrderLine extends CalloutEngine implements IColumnCallout {
|
||||
|
||||
@Override
|
||||
public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
|
||||
if(mField.getColumnName().equals(X_C_OrderLine.COLUMNNAME_M_Product_ID))
|
||||
return C_Order_ID(ctx, WindowNo, mTab, mField, value, oldValue);
|
||||
return null;
|
||||
}
|
||||
|
||||
public String C_Order_ID(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
|
||||
if(value==null)
|
||||
return null;
|
||||
MOrder Order = new MOrder(ctx, (int) mTab.getValue(X_C_OrderLine.COLUMNNAME_C_Order_ID), null);
|
||||
|
||||
String retValue = Order.get_ValueAsString("NoAju1") + "/"
|
||||
+ Order.get_ValueAsString("NoAju2") + "/"
|
||||
+ Order.get_ValueAsString("NoAju3") + "/"
|
||||
+ Order.get_ValueAsString("NoAju4") + "";
|
||||
|
||||
mTab.setValue("NoAju", retValue);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IColumnCallout;
|
||||
import org.adempiere.base.IColumnCalloutFactory;
|
||||
import org.compiere.model.X_C_OrderLine;
|
||||
|
||||
import edii.midsuit.callout.EDI_CalloutOrderLine;
|
||||
|
||||
public class MID_CalloutFactory implements IColumnCalloutFactory{
|
||||
|
||||
@Override
|
||||
public IColumnCallout[] getColumnCallouts(String tableName, String columnName) {
|
||||
List<IColumnCallout> list = new ArrayList<IColumnCallout>();
|
||||
// if(tableName.equals(X_MID_RequisitionLine.Table_Name))
|
||||
// list.add(new MID_CalloutRequisitionTrxLine());
|
||||
if(tableName.equals(X_C_OrderLine.Table_Name))
|
||||
list.add(new EDI_CalloutOrderLine());
|
||||
return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import org.compiere.grid.ICreateFrom;
|
||||
import org.compiere.grid.ICreateFromFactory;
|
||||
import org.compiere.model.GridTab;
|
||||
|
||||
public class MID_CreateFromFactory implements ICreateFromFactory{
|
||||
@Override
|
||||
public ICreateFrom create(GridTab mTab) {
|
||||
String tableName = mTab.getTableName();
|
||||
// if (tableName.equals(X_M_InOut.Table_Name))
|
||||
// return new MID_WCreateFromShipment(mTab);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.IDocFactory;
|
||||
import org.compiere.acct.Doc;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
public class MID_DocFactory implements IDocFactory{
|
||||
|
||||
private final static CLogger s_log = CLogger.getCLogger(MID_DocFactory.class);
|
||||
|
||||
@Override
|
||||
public Doc getDocument(MAcctSchema as, int AD_Table_ID, int Record_ID, String trxName) {
|
||||
String tableName = MTable.getTableName(Env.getCtx(), AD_Table_ID);
|
||||
//
|
||||
Doc doc = null;
|
||||
StringBuffer sql = new StringBuffer("SELECT * FROM ").append(tableName).append(" WHERE ").append(tableName)
|
||||
.append("_ID=? AND Processed='Y'");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql.toString(), trxName);
|
||||
pstmt.setInt(1, Record_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
doc = getDocument(as, AD_Table_ID, rs, trxName);
|
||||
} else
|
||||
s_log.severe("Not Found: " + tableName + "_ID=" + Record_ID);
|
||||
} catch (Exception e) {
|
||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
@Override
|
||||
public Doc getDocument(MAcctSchema as, int AD_Table_ID, ResultSet rs, String trxName) {
|
||||
|
||||
String tableName = MTable.getTableName(Env.getCtx(), AD_Table_ID);
|
||||
// if(tableName.equals(MID_MRequisitionTrx.Table_Name))
|
||||
// return new MID_DocMidRequsiition(as,rs,trxName);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.factory.IFormFactory;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.IFormController;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
public class MID_FormFactory implements IFormFactory {
|
||||
|
||||
protected transient CLogger log = CLogger.getCLogger(getClass());
|
||||
|
||||
@Override
|
||||
public ADForm newFormInstance(String formName) {
|
||||
// TODO Auto-generated method stub
|
||||
if (formName.startsWith("andromedia.midsuit.form")) {
|
||||
Object form = null;
|
||||
Class<?> clazz = null;
|
||||
ClassLoader loader = getClass().getClassLoader();
|
||||
try {
|
||||
clazz = loader.loadClass(formName);
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Load Form Class Failed");
|
||||
}
|
||||
|
||||
if (clazz != null) {
|
||||
try {
|
||||
form = clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "Class initialized error");
|
||||
}
|
||||
}
|
||||
if (form != null) {
|
||||
if (form instanceof ADForm) {
|
||||
return (ADForm) form;
|
||||
} else if (form instanceof IFormController) {
|
||||
IFormController controller = (IFormController) form;
|
||||
ADForm adform = controller.getForm();
|
||||
adform.setICustomForm(controller);
|
||||
return adform;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.base.IModelFactory;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
public class MID_ModelFactory implements IModelFactory{
|
||||
private static HashMap<String, String> mapTableModels = new HashMap<String, String>();
|
||||
static {
|
||||
//Ex mapTableModels.put(MOrderLine.Table_Name, "org.semeru.project.model.SMT_MOrderLine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClass(String tableName) {
|
||||
if (mapTableModels.containsKey(tableName)) {
|
||||
Class<?> act = null;
|
||||
try {
|
||||
act = Class.forName(mapTableModels.get(tableName));
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return act;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PO getPO(String tableName, int Record_ID, String trxName) {
|
||||
if (mapTableModels.containsKey(tableName)) {
|
||||
Class<?> clazz = null;
|
||||
Constructor<?> ctor = null;
|
||||
PO object = null;
|
||||
try {
|
||||
clazz = Class.forName(mapTableModels.get(tableName));
|
||||
ctor = clazz.getConstructor(Properties.class, int.class, String.class);
|
||||
object = (PO) ctor.newInstance(new Object[] { Env.getCtx(), Record_ID, trxName });
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return object;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PO getPO(String tableName, ResultSet rs, String trxName) {
|
||||
if (mapTableModels.containsKey(tableName)) {
|
||||
Class<?> clazz = null;
|
||||
Constructor<?> ctor = null;
|
||||
PO object = null;
|
||||
try {
|
||||
clazz = Class.forName(mapTableModels.get(tableName));
|
||||
ctor = clazz.getConstructor(Properties.class, ResultSet.class, String.class);
|
||||
object = (PO) ctor.newInstance(new Object[] { Env.getCtx(), rs, trxName });
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return object;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import org.adempiere.base.IProcessFactory;
|
||||
import org.compiere.process.ProcessCall;
|
||||
|
||||
public class MID_ProcessFactory implements IProcessFactory {
|
||||
|
||||
@Override
|
||||
public ProcessCall newProcessInstance(String className) {
|
||||
// TODO Auto-generated method stub
|
||||
ProcessCall proses = null;
|
||||
try {
|
||||
Class<?> clazz = getClass().getClassLoader().loadClass(className);
|
||||
proses = (ProcessCall) clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return proses;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package edii.midsuit.factory;
|
||||
|
||||
import org.adempiere.base.event.AbstractEventHandler;
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
import edii.midsuit.validator.EDI_OrderValidator;
|
||||
|
||||
public class MID_ValidatorFactory extends AbstractEventHandler {
|
||||
public CLogger log = CLogger.getCLogger(MID_ValidatorFactory.class);
|
||||
|
||||
@Override
|
||||
|
||||
protected void doHandleEvent(Event event) {
|
||||
String msg = "";
|
||||
|
||||
// if (getPO(event).get_TableName().equals(MOrderLandedCostAllocation.Table_Name))
|
||||
// msg = SMT_LandedCostAllocationValidator.executeEvent(event, getPO(event));
|
||||
if (getPO(event).get_TableName().equals(MOrder.Table_Name))
|
||||
msg = EDI_OrderValidator.executeEvent(event, getPO(event));
|
||||
// if (getPO(event).get_TableName().equals(MRMA.Table_Name))
|
||||
// msg = MID_RMAValidator.executeEvent(event, getPO(event));
|
||||
// if (getPO(event).get_TableName().equals(MInOut.Table_Name))
|
||||
// msg = MID_InOutValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MInvoice.Table_Name))
|
||||
// msg = MID_InvoiceValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MPaymentAllocate.Table_Name))
|
||||
// msg = MID_PaymentAllocateValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MProductPrice.Table_Name))
|
||||
// msg = MID_ProductPriceValidator.executeEvent(event, getPO(event));
|
||||
// if(getPO(event).get_TableName().equals(MPriceList.Table_Name))
|
||||
// msg = MID_PriceListValidator.executeEvent(event, getPO(event));
|
||||
logEvent(event, getPO(event), msg);
|
||||
}
|
||||
|
||||
private void logEvent(Event event, PO po, String msg) {
|
||||
log.fine("EVENT MANAGER // " + event.getTopic() + " po =" + po + " MESSAGE=" + msg);
|
||||
if (msg.length() > 0)
|
||||
throw new AdempiereException(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
|
||||
// registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, Table_Name);
|
||||
registerTableEvent(IEventTopics.DOC_BEFORE_COMPLETE, MOrder.Table_Name);
|
||||
registerTableEvent(IEventTopics.PO_BEFORE_CHANGE, MOrder.Table_Name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package edii.midsuit.validator;
|
||||
|
||||
import org.adempiere.base.event.IEventTopics;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MAttributeSetInstance;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_M_AttributeSetInstance;
|
||||
import org.compiere.util.DB;
|
||||
import org.osgi.service.event.Event;
|
||||
|
||||
public class EDI_OrderValidator {
|
||||
public static String executeEvent(Event e, PO po) {
|
||||
MOrder Order = (MOrder) po;
|
||||
if (e.getTopic().equals(IEventTopics.DOC_BEFORE_COMPLETE))
|
||||
return beforeComplete(Order);
|
||||
else if (e.getTopic().equals(IEventTopics.PO_BEFORE_CHANGE))
|
||||
return beforeChange(Order);
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String beforeChange(MOrder order) {
|
||||
|
||||
if(order.get_ValueAsString("NoAju1").equals("") || order.get_ValueAsString("NoAju2").equals("")
|
||||
|| order.get_ValueAsString("NoAju3").equals("") || order.get_ValueAsString("NoAju4").equals("")) {
|
||||
DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?",
|
||||
new Object[] { "", order.getC_Order_ID() }, order.get_TrxName());
|
||||
}
|
||||
else if(order.is_ValueChanged("NoAju1") || order.is_ValueChanged("NoAju3") ||
|
||||
order.is_ValueChanged("NoAju2") || order.is_ValueChanged("NoAju4")) {
|
||||
String noAju = order.get_ValueAsString("NoAju1")+"/"
|
||||
+ order.get_ValueAsString("NoAju2") + "/"
|
||||
+ order.get_ValueAsString("NoAju3") + "/"
|
||||
+ order.get_ValueAsString("NoAju4");
|
||||
DB.executeUpdateEx("UPDATE C_OrderLine SET NoAju = ? WHERE C_Order_ID = ?",
|
||||
new Object[] { noAju, order.getC_Order_ID() }, order.get_TrxName());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String beforeComplete(MOrder Order) {
|
||||
MOrderLine[] lines = Order.getLines();
|
||||
for(MOrderLine line : lines) {
|
||||
String noAju = line.get_ValueAsString("NoAju");
|
||||
if(Order.get_ValueAsInt("MID_AJUDocumentType_ID")>0 && noAju==null)
|
||||
return "Silahkan isi dokumen AJU terlebih dahulu !!!";
|
||||
if(line.getM_Product().getM_AttributeSet_ID()==0)
|
||||
throw new AdempiereException("Product "+line.getM_Product().getName()+" tidak memiliki attribute set !!!");
|
||||
|
||||
int M_AttributeSetInstance_ID = new Query(Order.getCtx(), X_M_AttributeSetInstance.Table_Name
|
||||
, "M_AttributeSet_ID =? AND Lot =?", Order.get_TrxName())
|
||||
.setParameters(new Object[] { line.getM_Product().getM_AttributeSet_ID(), noAju })
|
||||
.firstId();
|
||||
|
||||
if(M_AttributeSetInstance_ID==-1) {
|
||||
MAttributeSetInstance ASI = new MAttributeSetInstance(Order.getCtx(), 0, Order.get_TrxName());
|
||||
ASI.setLot(noAju);
|
||||
ASI.setM_AttributeSet_ID(line.getM_Product().getM_AttributeSet_ID());
|
||||
ASI.setDescription(noAju);
|
||||
ASI.saveEx();
|
||||
|
||||
M_AttributeSetInstance_ID = ASI.getM_AttributeSetInstance_ID();
|
||||
}
|
||||
|
||||
line.setM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
|
||||
line.saveEx();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue