BF [ 2419978 ] Voiding PO, requisition don't set on NULL

https://sourceforge.net/tracker/index.php?func=detail&aid=2419978&group_id=176962&atid=879332
This commit is contained in:
teo_sarca 2009-01-26 12:39:30 +00:00
parent ad44888075
commit 8def96311d
3 changed files with 86 additions and 3 deletions

View File

@ -52,6 +52,9 @@ import org.eevolution.model.MPPProductBOMLine;
* <li> FR [ 2520591 ] Support multiples calendar for Org
* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
* @version $Id: MOrder.java,v 1.5 2006/10/06 00:42:24 jjanke Exp $
*
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2419978 ] Voiding PO, requisition don't set on NULL
*/
public class MOrder extends X_C_Order implements DocAction
{
@ -1972,6 +1975,9 @@ public class MOrder extends X_C_Order implements DocAction
return false;
}
// UnLink All Requisitions
MRequisitionLine.unlinkC_Order_ID(getCtx(), get_ID(), get_TrxName());
if (!createReversals())
return false;

View File

@ -41,6 +41,10 @@ import org.compiere.util.Msg;
* </code>
* @author Jorg Janke
* @version $Id: MOrderLine.java,v 1.6 2006/10/02 05:18:39 jjanke Exp $
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>FR [ 1883362 ] Usability: force Product/Charge on Invoice Line as an option
* TODO: integrate to trunk
*/
public class MOrderLine extends X_C_OrderLine
{
@ -855,6 +859,9 @@ public class MOrderLine extends X_C_OrderLine
return false;
}
// UnLink All Requisitions
MRequisitionLine.unlinkC_OrderLine_ID(getCtx(), get_ID(), get_TrxName());
return true;
} // beforeDelete

View File

@ -18,6 +18,7 @@ package org.compiere.model;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -29,11 +30,80 @@ import org.compiere.util.Env;
*
* @author Jorg Janke
* @version $Id: MRequisitionLine.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $
*
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2419978 ] Voiding PO, requisition don't set on NULL
*/
public class MRequisitionLine extends X_M_RequisitionLine
{
private static final long serialVersionUID = 1L;
/**
* Get corresponding Requisition Line for given Order Line
* @param ctx
* @param C_OrderLine_ID order line
* @param trxName
* @return Requisition Line
*/
public static MRequisitionLine[] forC_Order_ID(Properties ctx, int C_Order_ID, String trxName)
{
final String whereClause = "EXISTS (SELECT 1 FROM C_OrderLine ol"
+" WHERE ol.C_OrderLine_ID=M_RequisitionLine.C_OrderLine_ID"
+" AND ol.C_Order_ID=?)";
List<MRequisitionLine> list = new Query(ctx, MRequisitionLine.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_Order_ID})
.list();
return list.toArray(new MRequisitionLine[list.size()]);
}
/**
* UnLink Requisition Lines for given Order
* @param ctx
* @param C_Order_ID
* @param trxName
*/
public static void unlinkC_Order_ID(Properties ctx, int C_Order_ID, String trxName)
{
for (MRequisitionLine line : MRequisitionLine.forC_Order_ID(ctx, C_Order_ID, trxName))
{
line.setC_OrderLine_ID(0);
line.saveEx();
}
}
/**
* Get corresponding Requisition Line for given Order Line
* @param ctx
* @param C_OrderLine_ID order line
* @param trxName
* @return Requisition Line
*/
public static MRequisitionLine forC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
{
final String whereClause = COLUMNNAME_C_OrderLine_ID+"=?";
return new Query(ctx, MRequisitionLine.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_OrderLine_ID})
.firstOnly();
}
/**
* UnLink Requisition Lines for given Order Line
* @param ctx
* @param C_OrderLine_ID
* @param trxName
*/
public static void unlinkC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
{
MRequisitionLine line = forC_OrderLine_ID(ctx, C_OrderLine_ID, trxName);
if (line != null)
{
line.setC_OrderLine_ID(0);
line.saveEx();
}
}
/**
* Standard Constructor
* @param ctx context
@ -184,7 +254,7 @@ public class MRequisitionLine extends X_M_RequisitionLine
if (getLine() == 0)
{
String sql = "SELECT COALESCE(MAX(Line),0)+10 FROM M_RequisitionLine WHERE M_Requisition_ID=?";
int ii = DB.getSQLValue (get_TrxName(), sql, getM_Requisition_ID());
int ii = DB.getSQLValueEx (get_TrxName(), sql, getM_Requisition_ID());
setLine (ii);
}
// Product & ASI - Charge
@ -237,8 +307,8 @@ public class MRequisitionLine extends X_M_RequisitionLine
+ " SET TotalLines="
+ "(SELECT COALESCE(SUM(LineNetAmt),0) FROM M_RequisitionLine rl "
+ "WHERE r.M_Requisition_ID=rl.M_Requisition_ID) "
+ "WHERE M_Requisition_ID=" + getM_Requisition_ID();
int no = DB.executeUpdateEx(sql, get_TrxName());
+ "WHERE M_Requisition_ID=?";
int no = DB.executeUpdateEx(sql, new Object[]{getM_Requisition_ID()}, get_TrxName());
if (no != 1)
log.log(Level.SEVERE, "Header update #" + no);
m_parent = null;