diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..982aaee
Binary files /dev/null and b/.DS_Store differ
diff --git a/andromeida.midsuit.project/.project b/andromeida.midsuit.project/.project
index ddc4f2f..15a03a4 100644
--- a/andromeida.midsuit.project/.project
+++ b/andromeida.midsuit.project/.project
@@ -20,6 +20,11 @@
+
+ org.eclipse.pde.ds.core.builder
+
+
+
org.eclipse.pde.PluginNature
diff --git a/andromeida.midsuit.project/META-INF/MANIFEST.MF b/andromeida.midsuit.project/META-INF/MANIFEST.MF
index 04e4c81..e84043e 100644
--- a/andromeida.midsuit.project/META-INF/MANIFEST.MF
+++ b/andromeida.midsuit.project/META-INF/MANIFEST.MF
@@ -6,5 +6,14 @@ 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"
+ 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
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
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_CalloutFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_CalloutFactory.xml
new file mode 100644
index 0000000..0cc2620
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_CalloutFactory.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_CreateFromFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_CreateFromFactory.xml
new file mode 100644
index 0000000..49e6ce6
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_CreateFromFactory.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_DocFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_DocFactory.xml
new file mode 100644
index 0000000..4fb36c6
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_DocFactory.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_FormFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_FormFactory.xml
new file mode 100644
index 0000000..de2ee1e
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_FormFactory.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_ModelFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_ModelFactory.xml
new file mode 100644
index 0000000..e3005bf
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_ModelFactory.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_ProcessFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_ProcessFactory.xml
new file mode 100644
index 0000000..c51362d
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_ProcessFactory.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/OSGI-INF/MID_ValidatorFactory.xml b/andromeida.midsuit.project/OSGI-INF/MID_ValidatorFactory.xml
new file mode 100644
index 0000000..65e0235
--- /dev/null
+++ b/andromeida.midsuit.project/OSGI-INF/MID_ValidatorFactory.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/andromeida.midsuit.project/build.properties b/andromeida.midsuit.project/build.properties
index 34d2e4d..43bce03 100644
--- a/andromeida.midsuit.project/build.properties
+++ b/andromeida.midsuit.project/build.properties
@@ -1,4 +1,11 @@
-source.. = src/
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/
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java
new file mode 100644
index 0000000..fe512cf
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CalloutFactory.java
@@ -0,0 +1,5 @@
+package andromedia.midsuit.factory;
+
+public class MID_CalloutFactory {
+
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java
new file mode 100644
index 0000000..3029f22
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_CreateFromFactory.java
@@ -0,0 +1,18 @@
+package andromedia.midsuit.factory;
+
+import org.compiere.grid.ICreateFrom;
+import org.compiere.grid.ICreateFromFactory;
+import org.compiere.model.GridTab;
+import org.compiere.model.X_C_Order;
+
+import andromedia.midsuit.form.MID_CreateFromOrder;
+
+public class MID_CreateFromFactory implements ICreateFromFactory{
+ @Override
+ public ICreateFrom create(GridTab mTab) {
+ String tableName = mTab.getTableName();
+ if (tableName.equals(X_C_Order.Table_Name))
+ return new MID_CreateFromOrder(mTab);
+ return null;
+ }
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java
new file mode 100644
index 0000000..9df4a7a
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_DocFactory.java
@@ -0,0 +1,5 @@
+package andromedia.midsuit.factory;
+
+public class MID_DocFactory {
+
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_FormFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_FormFactory.java
new file mode 100644
index 0000000..b912b14
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_FormFactory.java
@@ -0,0 +1,5 @@
+package andromedia.midsuit.factory;
+
+public class MID_FormFactory {
+
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java
new file mode 100644
index 0000000..d9cf5bc
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ModelFactory.java
@@ -0,0 +1,73 @@
+package andromedia.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 mapTableModels = new HashMap();
+ 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;
+ }
+
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ProcessFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ProcessFactory.java
new file mode 100644
index 0000000..e4ae2cb
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ProcessFactory.java
@@ -0,0 +1,21 @@
+package andromedia.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;
+ }
+
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java
new file mode 100644
index 0000000..90f7d83
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/factory/MID_ValidatorFactory.java
@@ -0,0 +1,34 @@
+package andromedia.midsuit.factory;
+
+import org.adempiere.base.event.AbstractEventHandler;
+import org.adempiere.exceptions.AdempiereException;
+import org.compiere.model.PO;
+import org.compiere.util.CLogger;
+import org.osgi.service.event.Event;
+
+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));
+ 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);
+ }
+
+}
diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java
new file mode 100644
index 0000000..ba29923
--- /dev/null
+++ b/andromeida.midsuit.project/src/andromedia/midsuit/form/MID_CreateFromOrder.java
@@ -0,0 +1,398 @@
+package andromedia.midsuit.form;
+
+import java.math.BigDecimal;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Vector;
+import java.util.logging.Level;
+
+import org.adempiere.exceptions.AdempiereException;
+import org.compiere.apps.IStatusBar;
+import org.compiere.grid.CreateFrom;
+import org.compiere.minigrid.IMiniTable;
+import org.compiere.model.GridTab;
+import org.compiere.model.MInvoiceLine;
+import org.compiere.model.MOrder;
+import org.compiere.model.MOrderLine;
+import org.compiere.model.MPriceList;
+import org.compiere.model.MProductPricing;
+import org.compiere.model.MRequisition;
+import org.compiere.model.MRequisitionLine;
+import org.compiere.model.MTax;
+import org.compiere.model.MUOMConversion;
+import org.compiere.model.Query;
+import org.compiere.model.X_C_OrderLine;
+import org.compiere.process.DocAction;
+import org.compiere.util.DB;
+import org.compiere.util.Env;
+import org.compiere.util.KeyNamePair;
+import org.compiere.util.Msg;
+
+public class MID_CreateFromOrder extends CreateFrom {
+ /*
+ * create by yonk
+ *
+ */
+
+ public String desc = "";
+
+ public MID_CreateFromOrder(GridTab mTab) {
+ super(mTab);
+ if (log.isLoggable(Level.INFO)) log.info(mTab.toString());
+ }
+
+ @Override
+ public Object getWindow() {
+ return null;
+ }
+
+ protected Vector getOISColumnNames()
+ {
+ // Header Info
+ Vector columnNames = new Vector(7);
+ columnNames.add(Msg.getMsg(Env.getCtx(), "Select"));
+ columnNames.add("Line");
+ columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
+ columnNames.add(Msg.translate(Env.getCtx(), "C_Charge_ID"));
+ columnNames.add(Msg.translate(Env.getCtx(), "Quantity"));
+ columnNames.add(Msg.translate(Env.getCtx(), "DateRequired"));
+ columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID"));
+// columnNames.add(Msg.translate(Env.getCtx(), "SisaPO"));
+ return columnNames;
+ }
+
+ @Override
+ public boolean dynInit() throws Exception {
+ log.config("");
+ setTitle(Msg.getElement(Env.getCtx(), "C_Order_ID", false) + " .. " + Msg.translate(Env.getCtx(), "CreateFrom"));
+ return true;
+ }
+
+ @Override
+ public void info(IMiniTable miniTable, IStatusBar statusBar) {
+
+ }
+
+ protected Vector> getRequisitionData(int M_Requisition_ID, int M_Product_ID, Timestamp dateRequired, int C_Charge_ID, int salesRepID)
+ {
+ //int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "C_Order_ID");
+ Vector> data = new Vector>();
+ int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "C_Order_ID");
+ MOrder order = new MOrder(Env.getCtx(), C_Order_ID, null);
+
+ /**
+ * 1 M_RequisitionLine_ID
+ * 2 Line
+ * 3 Product Name
+ * 4 Qty Entered
+ */
+ StringBuilder sqlStmt = new StringBuilder();
+
+ sqlStmt.append("SELECT rl.M_RequisitionLine_ID, rl.Line, "); //1..2
+ sqlStmt.append("CASE WHEN rl.M_Product_ID IS NOT NULL THEN (SELECT p.Value||'-'||p.Name FROM M_Product p WHERE p.M_Product_ID = rl.M_Product_ID) END as ProductName, "); //3
+ sqlStmt.append("rl.qty as Qty, mr.DateRequired, "); //4..5
+ sqlStmt.append("CASE WHEN rl.C_UOM_ID IS NOT NULL THEN (SELECT u.Name FROM C_UOM u WHERE u.C_UOM_ID = rl.C_UOM_ID) END AS uomName, "); //7
+ sqlStmt.append("CASE WHEN rl.C_Charge_ID IS NOT NULL THEN (SELECT c.Name FROM C_Charge c WHERE c.C_Charge_ID = rl.C_Charge_ID) END as ChargeName, ");
+ sqlStmt.append("COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) as sisapo ");
+ sqlStmt.append("FROM M_RequisitionLine rl ");
+ sqlStmt.append("INNER JOIN M_Requisition mr ON mr.M_Requisition_ID=rl.M_Requisition_ID ");
+ sqlStmt.append(" LEFT JOIN (SELECT M_RequisitionLine_ID, COALESCE(SUM(QtyOrdered),0) as QtyOrdered FROM C_OrderLine");
+ sqlStmt.append(" GROUP BY M_RequisitionLine_ID) ol ON (ol.M_RequisitionLine_ID=rl.M_RequisitionLine_ID)");
+ sqlStmt.append(" WHERE rl.AD_Client_ID=? AND mr.DocStatus=? ");
+ sqlStmt.append(" AND (rl.qty > ol.QtyOrdered OR COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) > 0)");
+
+
+ if (M_Requisition_ID > 0) {
+ sqlStmt.append("AND rl.M_Requisition_ID=? ");
+ MRequisition req = new MRequisition(Env.getCtx(), M_Requisition_ID, null);
+ desc = req.getDescription();
+ }
+
+ if (M_Product_ID > 0) {
+ sqlStmt.append("AND rl.M_Product_ID=? ");
+ }
+
+ if (dateRequired != null) {
+ sqlStmt.append("AND mr.DateRequired=? ");
+ }
+
+ if (C_Charge_ID > 0) {
+ sqlStmt.append("AND rl.C_Charge_ID=? ");
+ }
+
+ sqlStmt.append(" ORDER BY rl.line");
+
+ try
+ {
+ int count = 1;
+ PreparedStatement pstmt = DB.prepareStatement(sqlStmt.toString(), null);
+ pstmt.setInt(count, Env.getAD_Client_ID(Env.getCtx())); count++;
+ pstmt.setString(count, DocAction.STATUS_Completed);
+
+ if (M_Requisition_ID > 0) {
+ count++;
+ pstmt.setInt(count, M_Requisition_ID);
+ }
+
+ if (M_Product_ID > 0) {
+ count++;
+ pstmt.setInt(count, M_Product_ID);
+ }
+
+ if (dateRequired != null) {
+ count++;
+ pstmt.setTimestamp(count, dateRequired);
+ }
+
+ if (C_Charge_ID > 0) {
+ count++;
+ pstmt.setInt(count, C_Charge_ID);
+ }
+
+ ResultSet rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ if(rs.getBigDecimal(8).signum()<=0)
+ continue;
+
+ Vector