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;
|
private static final long serialVersionUID = -906547096682610205L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Distribution for combination
|
* Get Distribution for combination
|
||||||
* @param acct account (ValidCombination)
|
* @param acct account (ValidCombination)
|
||||||
|
@ -157,7 +156,7 @@ public class MDistribution extends X_GL_Distribution
|
||||||
MDistribution[] retValue = (MDistribution[])s_accounts.get(key);
|
MDistribution[] retValue = (MDistribution[])s_accounts.get(key);
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
return retValue;
|
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)
|
List<MDistribution> list = new Query(ctx,I_GL_Distribution.Table_Name,whereClause+"=?",null)
|
||||||
.setParameters(Account_ID)
|
.setParameters(Account_ID)
|
||||||
|
@ -243,22 +242,22 @@ public class MDistribution extends X_GL_Distribution
|
||||||
.list();
|
.list();
|
||||||
//red1 Query -end-
|
//red1 Query -end-
|
||||||
boolean hasNullRemainder = false;
|
boolean hasNullRemainder = false;
|
||||||
for (MDistributionLine dl:list){
|
for (MDistributionLine dl : list) {
|
||||||
if (dl.isActive())
|
if (dl.isActive())
|
||||||
{
|
{
|
||||||
PercentTotal = PercentTotal.add(dl.getPercent());
|
PercentTotal = PercentTotal.add(dl.getPercent());
|
||||||
hasNullRemainder = Env.ZERO.compareTo(dl.getPercent()) == 0;
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
// return
|
||||||
m_lines = new MDistributionLine[list.size ()];
|
m_lines = new MDistributionLine[list.size ()];
|
||||||
list.toArray (m_lines);
|
list.toArray (m_lines);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import test.AdempiereTestCase;
|
||||||
/**
|
/**
|
||||||
* @author Teo Sarca, www.arhipac.ro //red1 borrows from MInvoiceTest
|
* @author Teo Sarca, www.arhipac.ro //red1 borrows from MInvoiceTest
|
||||||
*/
|
*/
|
||||||
public class MDistributionListTest extends AdempiereTestCase
|
public class MDistributionTest extends AdempiereTestCase
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception
|
protected void setUp() throws Exception
|
Loading…
Reference in New Issue