BF [ 2892595 ] RfQResponseRank - ranking is not good

https://sourceforge.net/tracker/?func=detail&aid=2892595&group_id=176962&atid=879332

I've keeped same algorithm but I make it work.
This commit is contained in:
teo_sarca 2009-11-05 13:35:38 +00:00
parent 14cb45fec7
commit 3e080a8836
1 changed files with 21 additions and 13 deletions

View File

@ -33,6 +33,10 @@ import org.compiere.util.Env;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: RfQResponseRank.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ * @version $Id: RfQResponseRank.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
*
* @author Teo Sarca, teo.sarca@gmail.com
* <li>BF [ 2892595 ] RfQResponseRank - ranking is not good
* https://sourceforge.net/tracker/?func=detail&aid=2892595&group_id=176962&atid=879332
*/ */
public class RfQResponseRank extends SvrProcess public class RfQResponseRank extends SvrProcess
{ {
@ -84,8 +88,8 @@ public class RfQResponseRank extends SvrProcess
if (responses.length == 1) if (responses.length == 1)
{ {
responses[0].setIsSelectedWinner(true); responses[0].setIsSelectedWinner(true);
responses[0].save(); responses[0].saveEx();
throw new IllegalArgumentException("Only one completed RfQ Response found"); return "Only one completed RfQ Response found";
} }
// Rank // Rank
@ -146,28 +150,31 @@ public class RfQResponseRank extends SvrProcess
{ {
Arrays.sort(respQtys, respQtys[0]); Arrays.sort(respQtys, respQtys[0]);
int lastRank = 1; // multiple rank #1 int lastRank = 1; // multiple rank #1
BigDecimal lastAmt = Env.ZERO; BigDecimal lastAmt = Env.ZERO;
for (int rank = 0; rank < respQtys.length; rank++) int rank = 0;
for (int k = 0; k < respQtys.length; k++)
{ {
MRfQResponseLineQty qty = respQtys[rank]; MRfQResponseLineQty qty = respQtys[k];
if (!qty.isActive() || qty.getRanking() == 999) if (!qty.isActive() || qty.getRanking() == 999)
{
continue; continue;
}
BigDecimal netAmt = qty.getNetAmt(); BigDecimal netAmt = qty.getNetAmt();
if (netAmt == null) if (netAmt == null)
{ {
qty.setRanking(999); qty.setRanking(999);
qty.saveEx();
log.fine(" - Rank 999: " + qty); log.fine(" - Rank 999: " + qty);
continue;
} }
else
if (lastAmt.compareTo(netAmt) != 0)
{ {
if (lastAmt.compareTo(netAmt) != 0) lastRank = rank+1;
{ lastAmt = qty.getNetAmt();
lastRank = rank+1;
lastAmt = qty.getNetAmt();
}
qty.setRanking(lastRank);
log.fine(" - Rank " + lastRank + ": " + qty);
} }
qty.setRanking(lastRank);
log.fine(" - Rank " + lastRank + ": " + qty);
qty.save(); qty.save();
// //
if (rank == 0) // Update RfQ if (rank == 0) // Update RfQ
@ -175,6 +182,7 @@ public class RfQResponseRank extends SvrProcess
rfqQty.setBestResponseAmt(qty.getNetAmt()); rfqQty.setBestResponseAmt(qty.getNetAmt());
rfqQty.save(); rfqQty.save();
} }
rank++;
} }
} }
} // for all rfq line qtys } // for all rfq line qtys