[PENGADAAN] : Create From Order, Shipment
This commit is contained in:
parent
f2898f3327
commit
470f1d8748
|
|
@ -465,7 +465,8 @@ public class MID_CreateFromOrder extends CreateFrom {
|
|||
// 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);
|
||||
|
||||
orderLine.set_ValueNoCheck("C_Project_ID", reqLine.get_Value("C_Project_ID") != null ? reqLine.get_ValueAsInt("C_Project_ID") : null);
|
||||
orderLine.set_ValueNoCheck("C_ProjectPhase_ID", reqLine.get_Value("C_ProjectPhase_ID") != null ? reqLine.get_ValueAsInt("C_ProjectPhase_ID") : null);
|
||||
|
||||
if(!orderLine.save()){
|
||||
// String sqlDelete = "DELETE FROM C_OrderLine WHERE C_Order_ID=?";
|
||||
|
|
|
|||
|
|
@ -127,6 +127,17 @@ public abstract class MID_CreateFromShipment extends CreateFrom
|
|||
{
|
||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||
|
||||
// Add By animfalahuddin
|
||||
int C_Project_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "C_Project_ID");
|
||||
|
||||
StringBuilder project = new StringBuilder(" AND true");
|
||||
|
||||
if(C_Project_ID > 0) {
|
||||
project = new StringBuilder(" AND i.C_Project_ID = " + C_Project_ID);
|
||||
} else {
|
||||
project = new StringBuilder(" AND i.C_Project_ID is null");
|
||||
}
|
||||
|
||||
StringBuffer display = new StringBuffer("i.DocumentNo||' - '||")
|
||||
.append(DB.TO_CHAR("DateInvoiced", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
|
||||
.append("|| ' - ' ||")
|
||||
|
|
@ -139,11 +150,14 @@ public abstract class MID_CreateFromShipment extends CreateFrom
|
|||
+ "(SELECT il.C_Invoice_ID FROM C_InvoiceLine il"
|
||||
+ " LEFT OUTER JOIN M_MatchInv mi ON (il.C_InvoiceLine_ID=mi.C_InvoiceLine_ID) "
|
||||
+ " JOIN C_Invoice i2 ON (il.C_Invoice_ID = i2.C_Invoice_ID) "
|
||||
+ " WHERE i2.C_BPartner_ID=? AND i2.IsSOTrx='N' AND i2.DocStatus IN ('CL','CO') "
|
||||
+ "GROUP BY il.C_Invoice_ID,mi.C_InvoiceLine_ID,il.QtyInvoiced "
|
||||
+ " WHERE i2.C_BPartner_ID=? AND i2.IsSOTrx='N' AND i2.DocStatus IN ('CL','CO') ");
|
||||
|
||||
sql = sql.append(project);
|
||||
|
||||
sql = sql.append(" GROUP BY il.C_Invoice_ID,mi.C_InvoiceLine_ID,il.QtyInvoiced "
|
||||
+ "HAVING (il.QtyInvoiced<>SUM(mi.Qty) AND mi.C_InvoiceLine_ID IS NOT NULL)"
|
||||
+ " OR mi.C_InvoiceLine_ID IS NULL) "
|
||||
+ "ORDER BY i.DateInvoiced");
|
||||
+ "ORDER BY i.DateInvoiced");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
|
@ -171,6 +185,81 @@ public abstract class MID_CreateFromShipment extends CreateFrom
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load PBartner dependent Order/Invoice/Shipment Field.
|
||||
* @param C_BPartner_ID BPartner
|
||||
* @param forInvoice for invoice
|
||||
*/
|
||||
protected ArrayList<KeyNamePair> loadOrderData (int C_BPartner_ID, boolean forInvoice, boolean sameWarehouseOnly)
|
||||
{
|
||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||
|
||||
// Add By animfalahuddin
|
||||
int C_Project_ID = Env.getContextAsInt(Env.getCtx(), getGridTab().getWindowNo(), "C_Project_ID");
|
||||
|
||||
StringBuilder project = new StringBuilder(" AND true");
|
||||
|
||||
if(C_Project_ID > 0) {
|
||||
project = new StringBuilder(" AND o.C_Project_ID = " + C_Project_ID);
|
||||
} else {
|
||||
project = new StringBuilder(" AND o.C_Project_ID is null");
|
||||
}
|
||||
|
||||
String isSOTrxParam = isSOTrx ? "Y":"N";
|
||||
// Display
|
||||
StringBuffer display = new StringBuffer("o.DocumentNo||' - ' ||")
|
||||
.append(DB.TO_CHAR("o.DateOrdered", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
|
||||
.append("||' - '||")
|
||||
.append(DB.TO_CHAR("o.GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
|
||||
//
|
||||
String column = "ol.QtyDelivered";
|
||||
if (forInvoice)
|
||||
column = "ol.QtyInvoiced";
|
||||
StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,").append(display)
|
||||
.append(" FROM C_Order o "
|
||||
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx=? AND o.DocStatus IN ('CL','CO')"
|
||||
+ " AND o.C_Order_ID IN "
|
||||
+ "(SELECT ol.C_Order_ID FROM C_OrderLine ol"
|
||||
+ " WHERE ol.QtyOrdered - ").append(column).append(" != 0) ");
|
||||
if(sameWarehouseOnly)
|
||||
{
|
||||
sql = sql.append(" AND o.M_Warehouse_ID=? ");
|
||||
}
|
||||
sql = sql.append(project);
|
||||
sql = sql.append(" ORDER BY o.DateOrdered,o.DocumentNo");
|
||||
//
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setInt(1, C_BPartner_ID);
|
||||
pstmt.setString(2, isSOTrxParam);
|
||||
log.log(Level.SEVERE, "pstmt : " + pstmt);
|
||||
if(sameWarehouseOnly)
|
||||
{
|
||||
//only active for material receipts
|
||||
pstmt.setInt(3, getM_Warehouse_ID());
|
||||
}
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
return list;
|
||||
} // initBPartnerOIS
|
||||
|
||||
/**
|
||||
* Load Data - Order
|
||||
* @param C_Order_ID Order
|
||||
|
|
@ -636,6 +725,10 @@ public abstract class MID_CreateFromShipment extends CreateFrom
|
|||
iol.setAD_OrgTrx_ID(ol.getAD_OrgTrx_ID());
|
||||
iol.setUser1_ID(ol.getUser1_ID());
|
||||
iol.setUser2_ID(ol.getUser2_ID());
|
||||
iol.set_ValueNoCheck("Construction_C_Order_ID", ol.get_Value("Construction_C_Order_ID") != null ? ol.get_ValueAsInt("Construction_C_Order_ID") : null);
|
||||
iol.set_ValueNoCheck("SAP_ExpenseCode_ID", ol.get_Value("SAP_ExpenseCode_ID") != null ? ol.get_ValueAsInt("SAP_ExpenseCode_ID") : null);
|
||||
iol.set_ValueNoCheck("C_Project_ID", ol.get_Value("C_Project_ID") != null ? ol.get_ValueAsInt("C_Project_ID") : null);
|
||||
iol.set_ValueNoCheck("C_ProjectPhase_ID", ol.get_Value("C_ProjectPhase_ID") != null ? ol.get_ValueAsInt("C_ProjectPhase_ID") : null);
|
||||
}
|
||||
else if (il != null)
|
||||
{
|
||||
|
|
@ -655,6 +748,10 @@ public abstract class MID_CreateFromShipment extends CreateFrom
|
|||
iol.setAD_OrgTrx_ID(il.getAD_OrgTrx_ID());
|
||||
iol.setUser1_ID(il.getUser1_ID());
|
||||
iol.setUser2_ID(il.getUser2_ID());
|
||||
iol.set_ValueNoCheck("Construction_C_Order_ID", il.get_Value("Construction_C_Order_ID") != null ? il.get_ValueAsInt("Construction_C_Order_ID") : null);
|
||||
iol.set_ValueNoCheck("SAP_ExpenseCode_ID", il.get_Value("SAP_ExpenseCode_ID") != null ? il.get_ValueAsInt("SAP_ExpenseCode_ID") : null);
|
||||
iol.set_ValueNoCheck("C_Project_ID", il.get_Value("C_Project_ID") != null ? il.get_ValueAsInt("C_Project_ID") : null);
|
||||
iol.set_ValueNoCheck("C_ProjectPhase_ID", il.get_Value("C_ProjectPhase_ID") != null ? il.get_ValueAsInt("C_ProjectPhase_ID") : null);
|
||||
}
|
||||
else if (M_RMALine_ID != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import org.adempiere.webui.editor.WStringEditor;
|
|||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.adempiere.webui.event.ValueChangeListener;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
import org.compiere.grid.CreateFromShipment;
|
||||
//import org.compiere.grid.CreateFromShipment;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MLocatorLookup;
|
||||
import org.compiere.model.MLookup;
|
||||
|
|
|
|||
Loading…
Reference in New Issue