peer review for 11545 and 11546 - refactored getProductLot to have predictable results
FR: [ 2214883 ] Remove SQL code and Replace for Query Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
parent
ff9dffd082
commit
98c74ef980
|
@ -70,16 +70,15 @@ public class MLot extends X_M_Lot
|
|||
* @param M_Product_ID product
|
||||
* @param lot
|
||||
* @param trxName transaction
|
||||
* @return Array of Lots for Product //red1 -- last Lot
|
||||
* @return Last Lot for Product
|
||||
*/
|
||||
public static MLot getProductLot (Properties ctx, int M_Product_ID, String lot, String trxName)
|
||||
{
|
||||
final String whereClause = "M_Product_ID=? AND Name=?";
|
||||
List <MLot> list = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
|
||||
MLot retValue = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
|
||||
.setParameters(M_Product_ID, lot)
|
||||
.list();
|
||||
MLot retValue = null;
|
||||
retValue = list.get(list.size()-1); //red1 get last lot
|
||||
.setOrderBy(I_M_Lot.COLUMNNAME_M_Lot_ID + " DESC")
|
||||
.first();
|
||||
return retValue;
|
||||
} // getProductLot
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
*****************************************************************************/
|
||||
package test.functional;
|
||||
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MLot;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
|
@ -35,8 +34,12 @@ public class MLotTest extends AdempiereTestCase
|
|||
|
||||
public void testQuery() throws Exception
|
||||
{
|
||||
MLot retValue = MLot.getProductLot(getCtx(), 122, "Test", getTrxName()); //red1 test record created with such values
|
||||
assertTrue("Last Lot Rec is 101", retValue.getM_Lot_ID() == 101);
|
||||
// to set up record - in a clean seed database
|
||||
// open material receipt window
|
||||
// create a material receipt for the product Fertilizer #50
|
||||
// and push the "New Record" button on the attribute set instance dialog
|
||||
MLot retValue = MLot.getProductLot(getCtx(), 136, "100", getTrxName());
|
||||
assertTrue("Last Lot Rec is 101", retValue.getM_Lot_ID() == 1000000);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue