diff --git a/org.adempiere.base/src/org/compiere/print/DataEngine.java b/org.adempiere.base/src/org/compiere/print/DataEngine.java index 62be2fd693..552c84b0e6 100644 --- a/org.adempiere.base/src/org/compiere/print/DataEngine.java +++ b/org.adempiere.base/src/org/compiere/print/DataEngine.java @@ -824,17 +824,32 @@ public class DataEngine // Check Group Change ---------------------------------------- if (m_group.getGroupColumnCount() > 1) // one is GRANDTOTAL_ { + ArrayList changedGroups = new ArrayList(); + ArrayList changedValues = new ArrayList(); + boolean force = false; + // 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]; if (!m_group.isGroupColumn(group_pdc.getColumnName())) continue; // 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 { + 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()); for (int f = 0; f < functions.length; f++) { @@ -873,7 +888,6 @@ public class DataEngine m_group.reset(group_pdc.getColumnName(), pdc.getColumnName()); } } // Group change - } // for all columns } // group change // new row --------------------------------------------------- @@ -1035,7 +1049,7 @@ public class DataEngine PrintDataColumn group_pdc = pd.getColumnInfo()[i]; if (!m_group.isGroupColumn(group_pdc.getColumnName())) 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 { char[] functions = m_group.getFunctions(group_pdc.getColumnName()); diff --git a/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java b/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java index a9941e40ac..38c375fb05 100644 --- a/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java +++ b/org.adempiere.base/src/org/compiere/print/PrintDataGroup.java @@ -95,7 +95,7 @@ public class PrintDataGroup * @param value column 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)) return null; @@ -106,7 +106,7 @@ public class PrintDataGroup if (m_groupMap.containsKey(groupColumnName)) { Object oldValue = m_groupMap.get(groupColumnName); - if (newValue.equals(oldValue)) + if (newValue.equals(oldValue) && !force ) return null; m_groupMap.put(groupColumnName, newValue); return oldValue;