Peer review for 11755, 11756
BIG ERRORS: - changed the whereClause not equivalent - moved the logic of Update Ratio within the loop when it was out of the loop 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
6e8d32a311
commit
21212ed383
|
@ -41,7 +41,6 @@ public class MDistribution extends X_GL_Distribution
|
|||
*/
|
||||
private static final long serialVersionUID = -906547096682610205L;
|
||||
|
||||
|
||||
/**
|
||||
* Get Distribution for combination
|
||||
* @param acct account (ValidCombination)
|
||||
|
@ -157,7 +156,7 @@ public class MDistribution extends X_GL_Distribution
|
|||
MDistribution[] retValue = (MDistribution[])s_accounts.get(key);
|
||||
if (retValue != null)
|
||||
return retValue;
|
||||
final String whereClause = I_GL_Distribution.COLUMNNAME_Account_ID;
|
||||
final String whereClause = "Account_ID=?";
|
||||
|
||||
List<MDistribution> list = new Query(ctx,I_GL_Distribution.Table_Name,whereClause+"=?",null)
|
||||
.setParameters(Account_ID)
|
||||
|
@ -243,22 +242,22 @@ public class MDistribution extends X_GL_Distribution
|
|||
.list();
|
||||
//red1 Query -end-
|
||||
boolean hasNullRemainder = false;
|
||||
for (MDistributionLine dl:list){
|
||||
for (MDistributionLine dl : list) {
|
||||
if (dl.isActive())
|
||||
{
|
||||
PercentTotal = PercentTotal.add(dl.getPercent());
|
||||
hasNullRemainder = Env.ZERO.compareTo(dl.getPercent()) == 0;
|
||||
}
|
||||
dl.setParent(this);
|
||||
// Update Ratio when saved and difference
|
||||
if (hasNullRemainder)
|
||||
PercentTotal = Env.ONEHUNDRED;
|
||||
if (get_ID() != 0 && PercentTotal.compareTo(getPercentTotal()) != 0)
|
||||
{
|
||||
setPercentTotal(PercentTotal);
|
||||
save();
|
||||
}
|
||||
{
|
||||
PercentTotal = PercentTotal.add(dl.getPercent());
|
||||
hasNullRemainder = Env.ZERO.compareTo(dl.getPercent()) == 0;
|
||||
}
|
||||
dl.setParent(this);
|
||||
}
|
||||
// Update Ratio when saved and difference
|
||||
if (hasNullRemainder)
|
||||
PercentTotal = Env.ONEHUNDRED;
|
||||
if (get_ID() != 0 && PercentTotal.compareTo(getPercentTotal()) != 0)
|
||||
{
|
||||
setPercentTotal(PercentTotal);
|
||||
save();
|
||||
}
|
||||
// return
|
||||
m_lines = new MDistributionLine[list.size ()];
|
||||
list.toArray (m_lines);
|
||||
|
|
|
@ -22,7 +22,7 @@ import test.AdempiereTestCase;
|
|||
/**
|
||||
* @author Teo Sarca, www.arhipac.ro //red1 borrows from MInvoiceTest
|
||||
*/
|
||||
public class MDistributionListTest extends AdempiereTestCase
|
||||
public class MDistributionTest extends AdempiereTestCase
|
||||
{
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
Loading…
Reference in New Issue