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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IColumnCallout;
|
||||
import org.adempiere.base.IColumnCalloutFactory;
|
||||
|
||||
import andromedia.midsuit.callout.MID_CalloutRequisitionTrxLine;
|
||||
import andromedia.midsuit.model.X_MID_RequisitionLine;
|
||||
|
||||
public class MID_CalloutFactory implements IColumnCalloutFactory{
|
||||
|
||||
@Override
|
||||
public IColumnCallout[] getColumnCallouts(String tableName, String columnName) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
List<IColumnCallout> list = new ArrayList<IColumnCallout>();
|
||||
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(" 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='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(" 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.setPriceDate(order.getDateOrdered());
|
||||
|
||||
orderLine.setPriceEntered(pricing.getPriceStd().subtract(pricing.getPriceStd().multiply(orderLine.getDiscount())));
|
||||
orderLine.setPriceActual(pricing.getPriceStd());
|
||||
orderLine.setPriceList(pricing.getPriceList());
|
||||
orderLine.setPriceLimit(pricing.getPriceLimit());
|
||||
|
||||
// orderLine.setPriceEntered(pricing.getPriceStd().subtract(pricing.getPriceStd().multiply(orderLine.getDiscount())));
|
||||
// orderLine.setPriceActual(pricing.getPriceStd());
|
||||
// orderLine.setPriceList(pricing.getPriceList());
|
||||
// orderLine.setPriceLimit(pricing.getPriceLimit());
|
||||
orderLine.setPrice(reqLine.getPriceActual());
|
||||
//@Hodianto Change Default Price List
|
||||
MPriceList priceList = new MPriceList(Env.getCtx(), M_PriceList_ID, null);
|
||||
if(priceList.get_ValueAsBoolean("isLastPriceUsed")){
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.sql.ResultSet;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.compiere.model.MProcess;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocOptions;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
|
|
@ -34,6 +35,12 @@ public class MID_MRequisitionTrx extends X_MID_Requisition implements DocAction{
|
|||
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
|
||||
public boolean unlockIt() {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
|||
|
|
@ -20,4 +20,14 @@ public class MID_MRequisitionTrxLine extends X_MID_RequisitionLine {
|
|||
// 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.MTable;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.CCache;
|
||||
|
|
@ -29,12 +31,10 @@ import org.zkoss.json.JSONObject;
|
|||
import org.zkoss.json.parser.JSONParser;
|
||||
|
||||
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 final static CLogger s_log = CLogger.getCLogger(DefaultModelFactory.class);
|
||||
private String jsonString = "";
|
||||
private String tableName = "";
|
||||
@Override
|
||||
protected void prepare() {
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
|
|
@ -42,8 +42,8 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
String name = para[i].getParameterName();
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
else if (name.equals("AD_TableName"))
|
||||
p_tableName = para[i].getParameterAsString();
|
||||
if (para[i].getParameterName().equals("jsonString"))
|
||||
jsonString = para[i].getParameterAsString();
|
||||
else
|
||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||
}
|
||||
|
|
@ -51,37 +51,38 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
|
||||
@Override
|
||||
protected String doIt() throws Exception {
|
||||
String json = "{\"TableName\" : \"C_Order\","
|
||||
+ " \"field1\":"
|
||||
+ " [{\"abc\" : \"aab\" }],\"field2\":\"abc\"}\n" +
|
||||
"\n" ;
|
||||
|
||||
if(jsonString.length()==0) return "Failed to execute insert";
|
||||
JSONParser parser = new JSONParser();
|
||||
|
||||
|
||||
|
||||
JSONObject o = (JSONObject) parser.parse(json);
|
||||
if(o!=null) {
|
||||
|
||||
String orr = o.get("TableName").toString();
|
||||
JSONArray arr = (JSONArray) o.get("field1");
|
||||
Set<Object> s= o.keySet();
|
||||
Iterator keys = s.iterator();
|
||||
String keylist = "";
|
||||
JSONObject JSON = (JSONObject) parser.parse(jsonString);
|
||||
if(JSON!=null) {
|
||||
PO po = null;
|
||||
tableName = JSON.get("TableName").toString();
|
||||
JSONObject Data = (JSONObject) JSON.get("Data");
|
||||
String Mode = JSON.get("Mode").toString();
|
||||
if(Mode.equals("I")) {
|
||||
po = getPO(tableName, 0, get_TrxName());
|
||||
}else if (Mode.equals("U")) {
|
||||
int Record_ID = Integer.parseInt(Data.get("Record_ID").toString());
|
||||
po = getPO(tableName, Record_ID, get_TrxName());
|
||||
}
|
||||
Set<Object> keySet= Data.keySet();
|
||||
Iterator<Object> keys = keySet.iterator();
|
||||
while(keys.hasNext()) {
|
||||
keylist = keylist + keys.next().toString();
|
||||
}
|
||||
return orr.toString() + " " + arr.toString()+ " "+keylist;
|
||||
}
|
||||
|
||||
po = getPO("C_Order", 0, get_TrxName());
|
||||
po.set_ValueNoCheck("DocumentNo", "12345");
|
||||
|
||||
if(po.get_TableName().equals("C_Order")) {
|
||||
String buang = po.get_ValueAsString("DocumentNo")+" "+po.get_TableName()+" ";
|
||||
return buang;
|
||||
}
|
||||
String columnInsert = keys.next().toString();
|
||||
po.set_ValueNoCheck(columnInsert, Data.get(columnInsert));
|
||||
po.saveEx();
|
||||
}
|
||||
}else {
|
||||
return "No JSON to be processed !";
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition to be met
|
||||
* 1. TableName must not null / length>0
|
||||
* 2. Data Exists
|
||||
* 3. Mode to be used
|
||||
*/
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +92,8 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
"org.compiere.print", "org.compiere.impexp",
|
||||
"compiere.model", // globalqss allow compatibility with other plugins
|
||||
"adempiere.model", // Extensions
|
||||
"org.adempiere.model"
|
||||
"org.adempiere.model",
|
||||
"andromedia.midsuit.model"
|
||||
};
|
||||
|
||||
public Class<?> getClass(String tableName) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue