IDEMPIERE-3332 Report calculates subtotals incorrectly / integrate fix from Adaxa - Paul Bowden (phib)

from https://sourceforge.net/p/adempiere/contribution-adaxa/ci/c4a672
This commit is contained in:
Carlos Ruiz 2017-04-03 22:12:29 +02:00
parent f9853ba495
commit b20049e5a0
2 changed files with 20 additions and 6 deletions

View File

@ -824,17 +824,32 @@ public class DataEngine
// Check Group Change ---------------------------------------- // Check Group Change ----------------------------------------
if (m_group.getGroupColumnCount() > 1) // one is GRANDTOTAL_ if (m_group.getGroupColumnCount() > 1) // one is GRANDTOTAL_
{ {
ArrayList<PrintDataColumn> changedGroups = new ArrayList<PrintDataColumn>();
ArrayList<Object> changedValues = new ArrayList<Object>();
boolean force = false;
// Check Columns for Function Columns // Check Columns for Function Columns
for (int i = pd.getColumnInfo().length-1; i >= 0; i--) // backwards (leaset group first) for (int i = 0; i < pd.getColumnInfo().length; i++)
{ {
PrintDataColumn group_pdc = pd.getColumnInfo()[i]; PrintDataColumn group_pdc = pd.getColumnInfo()[i];
if (!m_group.isGroupColumn(group_pdc.getColumnName())) if (!m_group.isGroupColumn(group_pdc.getColumnName()))
continue; continue;
// Group change // Group change
Object value = m_group.groupChange(group_pdc.getColumnName(), rs.getObject(group_pdc.getAlias())); Object value = m_group.groupChange(group_pdc.getColumnName(), rs.getObject(group_pdc.getAlias()), force);
if (value != null) // Group change if (value != null) // Group change
{ {
changedGroups.add(group_pdc);
changedValues.add(value);
force = true; // all subsequent groups force change
}
}
for (int j = changedGroups.size() - 1; j >= 0; j--) // backwards (least group first)
{
PrintDataColumn group_pdc = changedGroups.get(j);
Object value = changedValues.get(j);
char[] functions = m_group.getFunctions(group_pdc.getColumnName()); char[] functions = m_group.getFunctions(group_pdc.getColumnName());
for (int f = 0; f < functions.length; f++) for (int f = 0; f < functions.length; f++)
{ {
@ -873,7 +888,6 @@ public class DataEngine
m_group.reset(group_pdc.getColumnName(), pdc.getColumnName()); m_group.reset(group_pdc.getColumnName(), pdc.getColumnName());
} }
} // Group change } // Group change
} // for all columns
} // group change } // group change
// new row --------------------------------------------------- // new row ---------------------------------------------------
@ -1035,7 +1049,7 @@ public class DataEngine
PrintDataColumn group_pdc = pd.getColumnInfo()[i]; PrintDataColumn group_pdc = pd.getColumnInfo()[i];
if (!m_group.isGroupColumn(group_pdc.getColumnName())) if (!m_group.isGroupColumn(group_pdc.getColumnName()))
continue; continue;
Object value = m_group.groupChange(group_pdc.getColumnName(), new Object()); Object value = m_group.groupChange(group_pdc.getColumnName(), new Object(), false);
if (value != null) // Group change if (value != null) // Group change
{ {
char[] functions = m_group.getFunctions(group_pdc.getColumnName()); char[] functions = m_group.getFunctions(group_pdc.getColumnName());

View File

@ -95,7 +95,7 @@ public class PrintDataGroup
* @param value column value * @param value column value
* @return null if no group change otherwise old value * @return null if no group change otherwise old value
*/ */
public Object groupChange (String groupColumnName, Object value) public Object groupChange (String groupColumnName, Object value, boolean force)
{ {
if (!isGroupColumn(groupColumnName)) if (!isGroupColumn(groupColumnName))
return null; return null;
@ -106,7 +106,7 @@ public class PrintDataGroup
if (m_groupMap.containsKey(groupColumnName)) if (m_groupMap.containsKey(groupColumnName))
{ {
Object oldValue = m_groupMap.get(groupColumnName); Object oldValue = m_groupMap.get(groupColumnName);
if (newValue.equals(oldValue)) if (newValue.equals(oldValue) && !force )
return null; return null;
m_groupMap.put(groupColumnName, newValue); m_groupMap.put(groupColumnName, newValue);
return oldValue; return oldValue;