Trx Requisition / Sales Requisition
This commit is contained in:
parent
af67456aa2
commit
0488fa2e5a
|
|
@ -0,0 +1,28 @@
|
||||||
|
package andromedia.midsuit.callout;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
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 andromedia.midsuit.model.X_MID_RequisitionLine;
|
||||||
|
|
||||||
|
public class MID_CalloutRequisitionTrxLine 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_MID_RequisitionLine.COLUMNNAME_Qty) || mField.getColumnName().equals(X_MID_RequisitionLine.COLUMNNAME_PriceActual)) {
|
||||||
|
if(value==null) return null;
|
||||||
|
if(mTab.getValue(X_MID_RequisitionLine.COLUMNNAME_Qty)!=null || mTab.getValue(X_MID_RequisitionLine.COLUMNNAME_PriceActual)!=null) {
|
||||||
|
BigDecimal Qty = (BigDecimal) mTab.getValue(X_MID_RequisitionLine.COLUMNNAME_Qty);
|
||||||
|
BigDecimal Price = (BigDecimal) mTab.getValue(X_MID_RequisitionLine.COLUMNNAME_PriceActual);
|
||||||
|
mTab.setValue(X_MID_RequisitionLine.COLUMNNAME_LineNetAmt, Qty.multiply(Price));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,22 @@
|
||||||
package andromedia.midsuit.factory;
|
package andromedia.midsuit.factory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.adempiere.base.IColumnCallout;
|
import org.adempiere.base.IColumnCallout;
|
||||||
import org.adempiere.base.IColumnCalloutFactory;
|
import org.adempiere.base.IColumnCalloutFactory;
|
||||||
|
|
||||||
|
import andromedia.midsuit.callout.MID_CalloutRequisitionTrxLine;
|
||||||
|
import andromedia.midsuit.model.X_MID_RequisitionLine;
|
||||||
|
|
||||||
public class MID_CalloutFactory implements IColumnCalloutFactory{
|
public class MID_CalloutFactory implements IColumnCalloutFactory{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IColumnCallout[] getColumnCallouts(String tableName, String columnName) {
|
public IColumnCallout[] getColumnCallouts(String tableName, String columnName) {
|
||||||
// TODO Auto-generated method stub
|
List<IColumnCallout> list = new ArrayList<IColumnCallout>();
|
||||||
return null;
|
if (tableName.equals(X_MID_RequisitionLine.Table_Name))
|
||||||
|
list.add(new MID_CalloutRequisitionTrxLine());
|
||||||
|
return list != null ? list.toArray(new IColumnCallout[0]) : new IColumnCallout[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
.append(" GROUP BY MID_RequisitionLine_ID) ol ON (ol.MID_RequisitionLine_ID=rl.MID_RequisitionLine_ID)")
|
.append(" GROUP BY MID_RequisitionLine_ID) ol ON (ol.MID_RequisitionLine_ID=rl.MID_RequisitionLine_ID)")
|
||||||
.append(" WHERE EXISTS (SELECT 1 FROM MID_RequisitionLine l WHERE r.MID_Requisition_ID=l.MID_Requisition_ID")
|
.append(" WHERE EXISTS (SELECT 1 FROM MID_RequisitionLine l WHERE r.MID_Requisition_ID=l.MID_Requisition_ID")
|
||||||
//.append(" AND l.AD_Client_ID=? AND r.DocStatus=?) AND r.C_BPartner_ID =?");
|
//.append(" AND l.AD_Client_ID=? AND r.DocStatus=?) AND r.C_BPartner_ID =?");
|
||||||
.append(" AND l.AD_Client_ID=? AND r.DocStatus='CO') AND r.M_Warehouse_ID =?")
|
.append(" AND l.AD_Client_ID=? AND r.DocStatus='CO') ")
|
||||||
.append(" AND (rl.qty > ol.QtyOrdered OR COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) > 0)")
|
.append(" AND (rl.qty > ol.QtyOrdered OR COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) > 0)")
|
||||||
.append(" GROUP BY r.MID_Requisition_ID");
|
.append(" GROUP BY r.MID_Requisition_ID");
|
||||||
|
|
||||||
|
|
@ -494,11 +494,11 @@ public class MID_CreateFromOrder extends CreateFrom {
|
||||||
pricing.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
pricing.setM_PriceList_Version_ID(M_PriceList_Version_ID);
|
||||||
pricing.setPriceDate(order.getDateOrdered());
|
pricing.setPriceDate(order.getDateOrdered());
|
||||||
|
|
||||||
orderLine.setPriceEntered(pricing.getPriceStd().subtract(pricing.getPriceStd().multiply(orderLine.getDiscount())));
|
// orderLine.setPriceEntered(pricing.getPriceStd().subtract(pricing.getPriceStd().multiply(orderLine.getDiscount())));
|
||||||
orderLine.setPriceActual(pricing.getPriceStd());
|
// orderLine.setPriceActual(pricing.getPriceStd());
|
||||||
orderLine.setPriceList(pricing.getPriceList());
|
// orderLine.setPriceList(pricing.getPriceList());
|
||||||
orderLine.setPriceLimit(pricing.getPriceLimit());
|
// orderLine.setPriceLimit(pricing.getPriceLimit());
|
||||||
|
orderLine.setPrice(reqLine.getPriceActual());
|
||||||
//@Hodianto Change Default Price List
|
//@Hodianto Change Default Price List
|
||||||
MPriceList priceList = new MPriceList(Env.getCtx(), M_PriceList_ID, null);
|
MPriceList priceList = new MPriceList(Env.getCtx(), M_PriceList_ID, null);
|
||||||
if(priceList.get_ValueAsBoolean("isLastPriceUsed")){
|
if(priceList.get_ValueAsBoolean("isLastPriceUsed")){
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import java.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.process.DocAction;
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.process.DocOptions;
|
import org.compiere.process.DocOptions;
|
||||||
import org.compiere.process.DocumentEngine;
|
import org.compiere.process.DocumentEngine;
|
||||||
|
|
@ -34,6 +35,12 @@ public class MID_MRequisitionTrx extends X_MID_Requisition implements DocAction{
|
||||||
return engine.processIt (action, getDocAction());
|
return engine.processIt (action, getDocAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateTotalLines(){
|
||||||
|
BigDecimal totalLines = new Query(getCtx(), MID_MRequisitionTrxLine.Table_Name, "MID_Requisition_ID =?", get_TrxName())
|
||||||
|
.setParameters(new Object[] { getMID_Requisition_ID() })
|
||||||
|
.sum(X_MID_RequisitionLine.COLUMNNAME_LineNetAmt);
|
||||||
|
setTotalLines(totalLines);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean unlockIt() {
|
public boolean unlockIt() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,15 @@ public class MID_MRequisitionTrxLine extends X_MID_RequisitionLine {
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean afterSave(boolean newRecord, boolean success) {
|
||||||
|
if(newRecord || is_ValueChanged(COLUMNNAME_LineNetAmt)) {
|
||||||
|
MID_MRequisitionTrx Req = (MID_MRequisitionTrx) getMID_Requisition();
|
||||||
|
Req.updateTotalLines();
|
||||||
|
Req.saveEx();
|
||||||
|
}
|
||||||
|
return super.afterSave(newRecord, success);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ import org.adempiere.base.DefaultModelFactory;
|
||||||
import org.compiere.model.MEntityType;
|
import org.compiere.model.MEntityType;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
|
import org.compiere.process.DocumentEngine;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
|
|
@ -29,12 +31,10 @@ import org.zkoss.json.JSONObject;
|
||||||
import org.zkoss.json.parser.JSONParser;
|
import org.zkoss.json.parser.JSONParser;
|
||||||
|
|
||||||
public class MID_InsertIntoAllTable extends SvrProcess{
|
public class MID_InsertIntoAllTable extends SvrProcess{
|
||||||
Class modelClass = null;
|
|
||||||
PO po = null;
|
|
||||||
String p_tableName = "";
|
|
||||||
String column = "";
|
|
||||||
private static CCache<String,Class<?>> s_classCache = new CCache<String,Class<?>>(null, "PO_Class", 20, false);
|
private static CCache<String,Class<?>> s_classCache = new CCache<String,Class<?>>(null, "PO_Class", 20, false);
|
||||||
private final static CLogger s_log = CLogger.getCLogger(DefaultModelFactory.class);
|
private final static CLogger s_log = CLogger.getCLogger(DefaultModelFactory.class);
|
||||||
|
private String jsonString = "";
|
||||||
|
private String tableName = "";
|
||||||
@Override
|
@Override
|
||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
ProcessInfoParameter[] para = getParameter();
|
ProcessInfoParameter[] para = getParameter();
|
||||||
|
|
@ -42,8 +42,8 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
||||||
String name = para[i].getParameterName();
|
String name = para[i].getParameterName();
|
||||||
if (para[i].getParameter() == null)
|
if (para[i].getParameter() == null)
|
||||||
;
|
;
|
||||||
else if (name.equals("AD_TableName"))
|
if (para[i].getParameterName().equals("jsonString"))
|
||||||
p_tableName = para[i].getParameterAsString();
|
jsonString = para[i].getParameterAsString();
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
|
|
@ -51,37 +51,38 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doIt() throws Exception {
|
protected String doIt() throws Exception {
|
||||||
String json = "{\"TableName\" : \"C_Order\","
|
if(jsonString.length()==0) return "Failed to execute insert";
|
||||||
+ " \"field1\":"
|
|
||||||
+ " [{\"abc\" : \"aab\" }],\"field2\":\"abc\"}\n" +
|
|
||||||
"\n" ;
|
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
|
JSONObject JSON = (JSONObject) parser.parse(jsonString);
|
||||||
|
if(JSON!=null) {
|
||||||
|
PO po = null;
|
||||||
JSONObject o = (JSONObject) parser.parse(json);
|
tableName = JSON.get("TableName").toString();
|
||||||
if(o!=null) {
|
JSONObject Data = (JSONObject) JSON.get("Data");
|
||||||
|
String Mode = JSON.get("Mode").toString();
|
||||||
String orr = o.get("TableName").toString();
|
if(Mode.equals("I")) {
|
||||||
JSONArray arr = (JSONArray) o.get("field1");
|
po = getPO(tableName, 0, get_TrxName());
|
||||||
Set<Object> s= o.keySet();
|
}else if (Mode.equals("U")) {
|
||||||
Iterator keys = s.iterator();
|
int Record_ID = Integer.parseInt(Data.get("Record_ID").toString());
|
||||||
String keylist = "";
|
po = getPO(tableName, Record_ID, get_TrxName());
|
||||||
while(keys.hasNext()) {
|
|
||||||
keylist = keylist + keys.next().toString();
|
|
||||||
}
|
}
|
||||||
return orr.toString() + " " + arr.toString()+ " "+keylist;
|
Set<Object> keySet= Data.keySet();
|
||||||
|
Iterator<Object> keys = keySet.iterator();
|
||||||
|
while(keys.hasNext()) {
|
||||||
|
String columnInsert = keys.next().toString();
|
||||||
|
po.set_ValueNoCheck(columnInsert, Data.get(columnInsert));
|
||||||
|
po.saveEx();
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return "No JSON to be processed !";
|
||||||
}
|
}
|
||||||
|
|
||||||
po = getPO("C_Order", 0, get_TrxName());
|
/**
|
||||||
po.set_ValueNoCheck("DocumentNo", "12345");
|
* Condition to be met
|
||||||
|
* 1. TableName must not null / length>0
|
||||||
|
* 2. Data Exists
|
||||||
|
* 3. Mode to be used
|
||||||
|
*/
|
||||||
|
|
||||||
if(po.get_TableName().equals("C_Order")) {
|
|
||||||
String buang = po.get_ValueAsString("DocumentNo")+" "+po.get_TableName()+" ";
|
|
||||||
return buang;
|
|
||||||
}
|
|
||||||
po.saveEx();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +92,8 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
||||||
"org.compiere.print", "org.compiere.impexp",
|
"org.compiere.print", "org.compiere.impexp",
|
||||||
"compiere.model", // globalqss allow compatibility with other plugins
|
"compiere.model", // globalqss allow compatibility with other plugins
|
||||||
"adempiere.model", // Extensions
|
"adempiere.model", // Extensions
|
||||||
"org.adempiere.model"
|
"org.adempiere.model",
|
||||||
|
"andromedia.midsuit.model"
|
||||||
};
|
};
|
||||||
|
|
||||||
public Class<?> getClass(String tableName) {
|
public Class<?> getClass(String tableName) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue