Create From Order Mod
This commit is contained in:
parent
720e6f37f5
commit
f2898f3327
|
|
@ -82,8 +82,6 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
//int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "C_Order_ID");
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
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
|
||||
|
|
@ -213,6 +211,15 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
StringBuilder display = new StringBuilder("r.DocumentNo");
|
||||
//.append(DB.TO_CHAR("r.TotaLines", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
||||
|
||||
// Add By animfalahuddin
|
||||
StringBuilder project = new StringBuilder(" AND true");
|
||||
|
||||
if(order.getC_Project() != null && order.getC_Project_ID() > 0) {
|
||||
project = new StringBuilder(" AND r.C_Project_ID = " + order.getC_Project_ID());
|
||||
} else {
|
||||
project = new StringBuilder(" AND r.C_Project_ID is null");
|
||||
}
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT DISTINCT r.MID_Requisition_ID,").append(display)
|
||||
.append(" FROM MID_Requisition r ")
|
||||
.append(" LEFT JOIN MID_RequisitionLine rl ON (rl.MID_Requisition_ID=r.MID_Requisition_ID)")
|
||||
|
|
@ -222,6 +229,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
//.append(" AND l.AD_Client_ID=? AND r.DocStatus=?) AND r.C_BPartner_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(project)
|
||||
.append(" GROUP BY r.MID_Requisition_ID");
|
||||
|
||||
sql = sql.append(" ORDER BY r.DocumentNo DESC");
|
||||
|
|
@ -265,6 +273,15 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
StringBuilder display = new StringBuilder("r.DocumentNo");
|
||||
//.append(DB.TO_CHAR("r.TotaLines", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
||||
|
||||
// Add By @animfalahuddin
|
||||
StringBuilder project = new StringBuilder(" AND true");
|
||||
|
||||
if(order.getC_Project_ID() > 0) {
|
||||
project = new StringBuilder(" AND r.C_Project_ID = " + order.getC_Project_ID());
|
||||
} else {
|
||||
project = new StringBuilder(" AND r.C_Project_ID is null");
|
||||
}
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT DISTINCT r.M_Requisition_ID,").append(display)
|
||||
.append(" FROM M_Requisition r ")
|
||||
.append(" LEFT JOIN M_RequisitionLine rl ON (rl.M_Requisition_ID=r.M_Requisition_ID)")
|
||||
|
|
@ -274,12 +291,14 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
//.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 (rl.qty > ol.QtyOrdered OR COALESCE(rl.qty - COALESCE(ol.QtyOrdered,0), 0) > 0)")
|
||||
.append(project)
|
||||
.append(" GROUP BY r.M_Requisition_ID");
|
||||
|
||||
sql = sql.append(" ORDER BY r.DocumentNo DESC");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try
|
||||
{
|
||||
int count = 0;
|
||||
|
|
@ -342,7 +361,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
BigDecimal qtyOrdered = qty;
|
||||
// BigDecimal qtyOrdered = sisapo;
|
||||
KeyNamePair pp = (KeyNamePair)miniTable.getValueAt(i, 1); // 1-Line
|
||||
if(!isSOTrx){
|
||||
if(!isSOTrx){
|
||||
|
||||
int requisitionLineID = pp.getKey();
|
||||
MRequisitionLine reqLine = new MRequisitionLine(Env.getCtx(), requisitionLineID, null);
|
||||
|
|
@ -443,6 +462,11 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
orderLine.set_ValueNoCheck("Comments", reqLine.get_Value("Comments"));
|
||||
// orderLine.set_ValueOfColumn("Comments", reqLine.get_Value("Comments"));
|
||||
|
||||
// Add By @animfalahuddin
|
||||
orderLine.set_ValueNoCheck("Construction_C_Order_ID", reqLine.get_Value("Construction_C_Order_ID") != null ? reqLine.get_ValueAsInt("Construction_C_Order_ID") : null);
|
||||
orderLine.set_ValueNoCheck("SAP_ExpenseCode_ID", reqLine.get_Value("SAP_ExpenseCode_ID") != null ? reqLine.get_ValueAsInt("SAP_ExpenseCode_ID") : null);
|
||||
|
||||
|
||||
if(!orderLine.save()){
|
||||
// String sqlDelete = "DELETE FROM C_OrderLine WHERE C_Order_ID=?";
|
||||
// int line = DB.executeUpdate(sqlDelete, order.getC_Order_ID(), null);
|
||||
|
|
@ -458,7 +482,7 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
MRequisition req = (MRequisition) reqLine.getM_Requisition();
|
||||
if(req.get_ValueAsInt("C_BPartner_ID")>0)
|
||||
order.setC_BPartner_ID(req.get_ValueAsInt("C_BPartner_ID"));
|
||||
}else{
|
||||
} else {
|
||||
//Is SO Trx = Y
|
||||
int requisitionLineID = pp.getKey();
|
||||
MID_MRequisitionTrxLine reqLine = new MID_MRequisitionTrxLine(Env.getCtx(), requisitionLineID, null);
|
||||
|
|
|
|||
Loading…
Reference in New Issue