Fixes ISSUE-44780. Allows to hide information about Reversed Payments
authordavid.miguelez <david.miguelez@openbravo.com>
Tue, 11 Aug 2020 12:43:41 +0200
changeset 37507 19361bd9dc0e
parent 37506 d6655bf58677
child 37508 89b0b6a30daf
Fixes ISSUE 44780. Allows to hide information about Reversed Payments
in Aging Balance Report
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/OBUIAPP_PARAMETER.xml
src/org/openbravo/common/actionhandler/AgingBalanceReportActionHandler.java
src/org/openbravo/erpCommon/ad_reports/AgingDao.java
src/org/openbravo/erpCommon/ad_reports/AgingDao_data.xsql
src/org/openbravo/erpCommon/ad_reports/AgingScheduleDetailHTML.jrxml
src/org/openbravo/erpCommon/ad_reports/AgingScheduleHTML.jrxml
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Aug 05 08:17:58 2020 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Tue Aug 11 12:43:41 2020 +0200
@@ -27655,6 +27655,20 @@
 <!--719F3857EC4B43BB9C29FCD9764F02AC-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--719F3857EC4B43BB9C29FCD9764F02AC--></AD_ELEMENT>
 
+<!--718CE226E80C460FBAD335B2E3D66381--><AD_ELEMENT>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <AD_ELEMENT_ID><![CDATA[718CE226E80C460FBAD335B2E3D66381]]></AD_ELEMENT_ID>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <COLUMNNAME><![CDATA[ShowReversed]]></COLUMNNAME>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <NAME><![CDATA[Reversed payments needs to be included]]></NAME>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <PRINTNAME><![CDATA[Reversed payments needs to be included]]></PRINTNAME>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <DESCRIPTION><![CDATA[Reversed payments needs to be included]]></DESCRIPTION>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <HELP><![CDATA[Reversed payments needs to be included]]></HELP>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--718CE226E80C460FBAD335B2E3D66381-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--718CE226E80C460FBAD335B2E3D66381--></AD_ELEMENT>
+
 <!--71B1ABC309C8472D9153E2D447C1D929--><AD_ELEMENT>
 <!--71B1ABC309C8472D9153E2D447C1D929-->  <AD_ELEMENT_ID><![CDATA[71B1ABC309C8472D9153E2D447C1D929]]></AD_ELEMENT_ID>
 <!--71B1ABC309C8472D9153E2D447C1D929-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Aug 05 08:17:58 2020 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Tue Aug 11 12:43:41 2020 +0200
@@ -10663,6 +10663,17 @@
 <!--8479F2E1BCED41998B76E6ED72E5AA61-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--8479F2E1BCED41998B76E6ED72E5AA61--></AD_REF_LIST>
 
+<!--84E11C8AD8E848BC990C40BC7B5CC187--><AD_REF_LIST>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <AD_REF_LIST_ID><![CDATA[84E11C8AD8E848BC990C40BC7B5CC187]]></AD_REF_LIST_ID>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <VALUE><![CDATA[AGING_ShowReversedCheckbox]]></VALUE>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <NAME><![CDATA[Enable reversed payment documents filter in Aging Reports]]></NAME>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--84E11C8AD8E848BC990C40BC7B5CC187-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--84E11C8AD8E848BC990C40BC7B5CC187--></AD_REF_LIST>
+
 <!--855D3B08CF8248ADB9BB84CF8D3FD9C5--><AD_REF_LIST>
 <!--855D3B08CF8248ADB9BB84CF8D3FD9C5-->  <AD_REF_LIST_ID><![CDATA[855D3B08CF8248ADB9BB84CF8D3FD9C5]]></AD_REF_LIST_ID>
 <!--855D3B08CF8248ADB9BB84CF8D3FD9C5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Wed Aug 05 08:17:58 2020 +0200
+++ b/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Tue Aug 11 12:43:41 2020 +0200
@@ -2176,6 +2176,32 @@
 <!--D81A65F88E6F4DA9B32076EBB9303786-->  <ATT_SHOWINDESCRIPTION><![CDATA[N]]></ATT_SHOWINDESCRIPTION>
 <!--D81A65F88E6F4DA9B32076EBB9303786--></OBUIAPP_PARAMETER>
 
+<!--DAA2C7B78E604241A4706AF9D0AA725E--><OBUIAPP_PARAMETER>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <OBUIAPP_PARAMETER_ID><![CDATA[DAA2C7B78E604241A4706AF9D0AA725E]]></OBUIAPP_PARAMETER_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <NAME><![CDATA[Reversed payments needs to be included]]></NAME>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <SEQNO><![CDATA[95]]></SEQNO>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <COLUMNNAME><![CDATA[ShowReversed]]></COLUMNNAME>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <DEFAULTVALUE><![CDATA['Y']]></DEFAULTVALUE>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <AD_ELEMENT_ID><![CDATA[718CE226E80C460FBAD335B2E3D66381]]></AD_ELEMENT_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <OBUIAPP_PROCESS_ID><![CDATA[0D37A9F6109549DEB058373EF2DAEB6A]]></OBUIAPP_PROCESS_ID>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <DISPLAYLOGIC><![CDATA[OB.PropertyStore.get('AGING_ShowReversedCheckbox')='Y']]></DISPLAYLOGIC>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <NUMCOLUMN><![CDATA[4]]></NUMCOLUMN>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--DAA2C7B78E604241A4706AF9D0AA725E-->  <ATT_SHOWINDESCRIPTION><![CDATA[N]]></ATT_SHOWINDESCRIPTION>
+<!--DAA2C7B78E604241A4706AF9D0AA725E--></OBUIAPP_PARAMETER>
+
 <!--DAE78C4FC90D4E40AA2DB068CE21343D--><OBUIAPP_PARAMETER>
 <!--DAE78C4FC90D4E40AA2DB068CE21343D-->  <OBUIAPP_PARAMETER_ID><![CDATA[DAE78C4FC90D4E40AA2DB068CE21343D]]></OBUIAPP_PARAMETER_ID>
 <!--DAE78C4FC90D4E40AA2DB068CE21343D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2227,6 +2253,33 @@
 <!--DBD34BCBFA5D4FFDBA7DDD0565581728-->  <ATT_SHOWINDESCRIPTION><![CDATA[N]]></ATT_SHOWINDESCRIPTION>
 <!--DBD34BCBFA5D4FFDBA7DDD0565581728--></OBUIAPP_PARAMETER>
 
+<!--DCFC931AFC124D67B39F57978A83BE3D--><OBUIAPP_PARAMETER>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <OBUIAPP_PARAMETER_ID><![CDATA[DCFC931AFC124D67B39F57978A83BE3D]]></OBUIAPP_PARAMETER_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <NAME><![CDATA[Reversed payments needs to be included]]></NAME>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <DESCRIPTION><![CDATA[Reversed payments needs to be included]]></DESCRIPTION>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <HELP><![CDATA[Reversed payments needs to be included]]></HELP>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <SEQNO><![CDATA[110]]></SEQNO>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <COLUMNNAME><![CDATA[ShowReversed]]></COLUMNNAME>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <DEFAULTVALUE><![CDATA['Y']]></DEFAULTVALUE>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <AD_ELEMENT_ID><![CDATA[718CE226E80C460FBAD335B2E3D66381]]></AD_ELEMENT_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <OBUIAPP_PROCESS_ID><![CDATA[EB4C4053F3B94A17A08D1DD7E89CEB7E]]></OBUIAPP_PROCESS_ID>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <DISPLAYLOGIC><![CDATA[OB.PropertyStore.get('AGING_ShowReversedCheckbox')='Y']]></DISPLAYLOGIC>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--DCFC931AFC124D67B39F57978A83BE3D-->  <ATT_SHOWINDESCRIPTION><![CDATA[N]]></ATT_SHOWINDESCRIPTION>
+<!--DCFC931AFC124D67B39F57978A83BE3D--></OBUIAPP_PARAMETER>
+
 <!--DEC3B66EB67A401B95B394EEC6D09A82--><OBUIAPP_PARAMETER>
 <!--DEC3B66EB67A401B95B394EEC6D09A82-->  <OBUIAPP_PARAMETER_ID><![CDATA[DEC3B66EB67A401B95B394EEC6D09A82]]></OBUIAPP_PARAMETER_ID>
 <!--DEC3B66EB67A401B95B394EEC6D09A82-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/common/actionhandler/AgingBalanceReportActionHandler.java	Wed Aug 05 08:17:58 2020 +0200
+++ b/src/org/openbravo/common/actionhandler/AgingBalanceReportActionHandler.java	Tue Aug 11 12:43:41 2020 +0200
@@ -78,6 +78,8 @@
   private static final String PARAM_BP = "BusinessPartner";
   private static final String PARAM_SHOWVOID = "ShowVoid";
   private static final String PREFERENCE_SHOWVOID = "AGING_ShowVoidCheckbox";
+  private static final String PARAM_SHOWREVERSED = "ShowReversed";
+  private static final String PREFERENCE_SHOWREVERSED = "AGING_ShowReversedCheckbox";
   private static final String PARAM_DOUBTFUL = "Doubtful";
   private static final String PARAM_RECORPAY = "RecOrPay";
   private static final String RECEIVABLES = "RECEIVABLES";
@@ -178,6 +180,19 @@
           strVoid = TRUE;
         }
         return strVoid;
+      } else if (PARAM_SHOWREVERSED.equals(parameter)) {
+        String strReversed;
+        try {
+          strReversed = Preferences
+              .getPreferenceValue(PREFERENCE_SHOWREVERSED, true,
+                  OBContext.getOBContext().getCurrentClient(),
+                  OBContext.getOBContext().getCurrentOrganization(),
+                  OBContext.getOBContext().getUser(), OBContext.getOBContext().getRole(), null)
+              .equals("Y") ? params.getString(PARAM_SHOWREVERSED) : TRUE;
+        } catch (Exception ex) {
+          strReversed = TRUE;
+        }
+        return strReversed;
       } else if (PARAM_DOUBTFUL.equals(parameter)) {
         String recOrPay = params.getString(PARAM_RECORPAY);
         String strDoubtful = FALSE;
@@ -201,6 +216,8 @@
     FieldProvider[] data;
     boolean showDoubtful = TRUE.equals(getParameter(PARAM_DOUBTFUL, content));
     boolean excludeVoid = FALSE.equals(getParameter(PARAM_SHOWVOID, content));
+    boolean excludeReversed = FALSE.equals(getParameter(PARAM_SHOWREVERSED, content));
+
     Currency convCurrency = null;
     String dateFormatString = OBPropertiesProvider.getInstance()
         .getOpenbravoProperties()
@@ -227,7 +244,7 @@
         getParameter(PARAM_RECORPAY, content), getParameter(PARAM_COLUMN1, content),
         getParameter(PARAM_COLUMN2, content), getParameter(PARAM_COLUMN3, content),
         getParameter(PARAM_COLUMN4, content), getParameter(PARAM_BP, content), showDoubtful,
-        excludeVoid);
+        excludeVoid, excludeReversed);
     return data;
   }
 
@@ -271,6 +288,7 @@
     cal.setTime(currentDate);
     boolean showDoubtful = TRUE.equals(getParameter(PARAM_DOUBTFUL, content));
     boolean excludeVoid = FALSE.equals(getParameter(PARAM_SHOWVOID, content));
+    boolean excludeReversed = FALSE.equals(getParameter(PARAM_SHOWREVERSED, content));
 
     // Save in session report limit
     RequestContext.get()
@@ -280,9 +298,10 @@
         getParameter(PARAM_BP, content), getParameter(PARAM_GL, content), currentDate,
         getParameter(PARAM_COLUMN1, content), getParameter(PARAM_COLUMN2, content),
         getParameter(PARAM_COLUMN3, content), getParameter(PARAM_COLUMN4, content),
-        getParameter(PARAM_ORGANIZATION, content), new OrganizationStructureProvider()
-            .getChildTree(getParameter(PARAM_ORGANIZATION, content), true),
-        getParameter(PARAM_RECORPAY, content), showDoubtful, excludeVoid);
+        getParameter(PARAM_ORGANIZATION, content),
+        new OrganizationStructureProvider().getChildTree(getParameter(PARAM_ORGANIZATION, content),
+            true),
+        getParameter(PARAM_RECORPAY, content), showDoubtful, excludeVoid, excludeReversed);
     return data;
   }
 
@@ -397,6 +416,7 @@
       String strCurrentDate = getParameter(PARAM_CURRENTDATE, jsonContent);
       String strcBpartnerId = getParameter(PARAM_BP, jsonContent);
       String strVoid = getParameter(PARAM_SHOWVOID, jsonContent);
+      String strReversed = getParameter(PARAM_SHOWREVERSED, jsonContent);
       String strDoubtful = getParameter(PARAM_DOUBTFUL, jsonContent);
       String dateFormatString = OBPropertiesProvider.getInstance()
           .getOpenbravoProperties()
@@ -435,6 +455,7 @@
         parameters.put("inpLabel4", (Integer.valueOf(strColumn3) + 1) + "-" + strColumn4);
         parameters.put("inpLabel5", "Over " + strColumn4);
         parameters.put("void", strVoid);
+        parameters.put("reversed", strReversed);
         if (RECEIVABLES.equals(recOrPay)) {
           parameters.put("title", Utility.messageBD(conn, "AGING_ORASD", vars.getLanguage()));
           parameters.put("tabID", "263");
@@ -494,6 +515,7 @@
         parameters.put("toCurrency", toCurrency.getId());
         parameters.put("showDoubtfulDebt", strDoubtful);
         parameters.put("void", strVoid);
+        parameters.put("reversed", strReversed);
         if (RECEIVABLES.equals(recOrPay)) {
           parameters.put("tabTitle", Utility.messageBD(conn, "AGING_ORASD", vars.getLanguage()));
           parameters.put("title", Utility.messageBD(conn, "AGING_ORAS", vars.getLanguage()));
--- a/src/org/openbravo/erpCommon/ad_reports/AgingDao.java	Wed Aug 05 08:17:58 2020 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/AgingDao.java	Tue Aug 11 12:43:41 2020 +0200
@@ -74,8 +74,8 @@
   public FieldProvider[] getOpenReceivablesAgingSchedule(ConnectionProvider connectionProvider,
       String strcBpartnerId, String strAccSchema, Date currentDate, String strcolumn1,
       String strcolumn2, String strcolumn3, String strcolumn4, String strOrg,
-      Set<String> organizations, String recOrPay, boolean showDoubtfulDebt, boolean excludeVoids)
-      throws IOException, ServletException {
+      Set<String> organizations, String recOrPay, boolean showDoubtfulDebt, boolean excludeVoids,
+      boolean excludeReverseds) throws IOException, ServletException {
 
     // Initialization of some variables
     List<String> paidStatus = FIN_Utility.getListPaymentConfirmed();
@@ -158,8 +158,8 @@
       dataCreditSR = AgingDaoData.selectCredit(connectionProvider, convCurrency.getId(),
           Utility.getInStrSet(organizations), Utility.getInStrSet(new HashSet<String>(paidStatus)),
           OBDateUtils.formatDate(currentDate),
-          StringUtils.equals(recOrPay, "RECEIVABLES") ? "Y" : "N", strcBpartnerId, pgLimit,
-          oraLimit);
+          StringUtils.equals(recOrPay, "RECEIVABLES") ? "Y" : "N", strcBpartnerId,
+          excludeReverseds ? "excludeReverseds" : "", pgLimit, oraLimit);
       log4j.debug("Credit Query: " + (System.currentTimeMillis() - init));
       init = System.currentTimeMillis();
       i = 0;
@@ -218,7 +218,8 @@
       ConnectionProvider connectionProvider, Date currentDate, SimpleDateFormat dateFormat,
       Currency convCurrency, Set<String> organizations, String recOrPay, String strcolumn1,
       String strcolumn2, String strcolumn3, String strcolumn4, String strcBpartnerId,
-      boolean showDoubtfulDebt, Boolean excludeVoid) throws IOException, ServletException {
+      boolean showDoubtfulDebt, Boolean excludeVoid, Boolean excludeReversed)
+      throws IOException, ServletException {
 
     List<HashMap<String, String>> hashMapList = new ArrayList<HashMap<String, String>>();
     FieldProvider[] data = null;
@@ -285,8 +286,8 @@
       dataCreditSR = AgingDaoData.selectCredit(connectionProvider, convCurrency.getId(),
           Utility.getInStrSet(organizations), Utility.getInStrSet(new HashSet<String>(paidStatus)),
           OBDateUtils.formatDate(currentDate),
-          StringUtils.equals(recOrPay, "RECEIVABLES") ? "Y" : "N", strcBpartnerId, pgLimit,
-          oraLimit);
+          StringUtils.equals(recOrPay, "RECEIVABLES") ? "Y" : "N", strcBpartnerId,
+          excludeReversed ? "excludeReverseds" : "", pgLimit, oraLimit);
       log4j.debug("Credit Query: " + (System.currentTimeMillis() - init));
       init = System.currentTimeMillis();
       i = 0;
--- a/src/org/openbravo/erpCommon/ad_reports/AgingDao_data.xsql	Wed Aug 05 08:17:58 2020 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/AgingDao_data.xsql	Tue Aug 11 12:43:41 2020 +0200
@@ -185,6 +185,7 @@
     <Parameter name="asOfDate"/>
     <Parameter name="recOrPay"/>
     <Parameter name="cbPartnerId" optional="true" type="argument" after="AND 2=2"><![CDATA[ AND fp2.C_BPARTNER_ID IN]]></Parameter>
+    <Parameter name="excludeReverseds" type="none" optional="true" after="AND 2=2" text=" AND (fp2.fin_rev_payment_id is null AND fp2.documentno not like ('*R*%'))"/>
     <Parameter name="asOfDate"/>
     <Parameter name="paidStatus" type="replace" optional="true" after="OR ( fp1.status IN (" text="'1'"/>
     <Parameter name="pgLimit" type="argument" optional="true" after=") B"><![CDATA[LIMIT ]]></Parameter>
--- a/src/org/openbravo/erpCommon/ad_reports/AgingScheduleDetailHTML.jrxml	Wed Aug 05 08:17:58 2020 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/AgingScheduleDetailHTML.jrxml	Tue Aug 11 12:43:41 2020 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
-<!-- 2016-11-02T09:12:28 -->
+<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
+<!-- 2016-11-02T09:12:28 -->
 <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="PaymentReportPDF" pageWidth="1100" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="1040" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" uuid="f73cd4f8-17ca-4505-866b-7b88e67c1d99">
 	<property name="ireport.scriptlethandling" value="0"/>
 	<property name="ireport.encoding" value="UTF-8"/>
@@ -60,6 +60,9 @@
 	<parameter name="void" class="java.lang.String">
 		<defaultValueExpression><![CDATA["true"]]></defaultValueExpression>
 	</parameter>
+	<parameter name="reversed" class="java.lang.String">
+		<defaultValueExpression><![CDATA["true"]]></defaultValueExpression>
+	</parameter>
 	<parameter name="processId" class="java.lang.String" isForPrompting="false">
 		<parameterDescription><![CDATA[]]></parameterDescription>
 	</parameter>
@@ -442,33 +445,33 @@
 					<font isUnderline="true"/>
 				</textElement>
 				<textFieldExpression><![CDATA["PDF"]]></textFieldExpression>
-				<hyperlinkReferenceExpression><![CDATA["javascript:top.OB.RemoteCallManager.call(\'org.openbravo.common.actionhandler.AgingBalanceReportActionHandler\',"
-    +"{"
-    +"  _buttonValue:\'PDF\',"
-    +"  _params:{"
-		+"    AccSchema:\'"+$P{accSchemaID}+"\',"
-		+"    BusinessPartner: [\'"+$P{BPartnerID}+"\'],"
-		+"    Column1:"+$P{inpColumn1}+","
-		+"    Column2:"+$P{inpColumn2}+","
-		+"    Column3:"+$P{inpColumn3}+","
-		+"    Column4:"+$P{inpColumn4}+","
-		+"    CurrentDate: \'"+$P{dateFromUI}+"\',"
-		+"    Details:\'true\',"
-		+"    Doubtful:\'"+$P{showDoubtfulDebt}+"\',"
-		+"    Organization:\'"+$P{organizationID}+"\',"
-		+"    RecOrPay:\'"+$P{recOrPay}+"\',"
-		+"    ShowVoid:\'"+$P{void}+"\'"
-		+"  }"
-		+"},"
-		+"{"
-		+"  processId:\'"+$P{processId}+"\',"
-		+"  reportId:\'"+$P{reportId}+"',"
-		+"  windowId: null"
-		+"},"
-		+"function(rpcResponse, data, rpcRequest) {"
-		+"  console.log(data);"
-		+"  top.OB.Utilities.Action.executeJSON(data.responseActions, null, null, null);"
-		+"}"
+				<hyperlinkReferenceExpression><![CDATA["javascript:top.OB.RemoteCallManager.call(\'org.openbravo.common.actionhandler.AgingBalanceReportActionHandler\',"
+    +"{"
+    +"  _buttonValue:\'PDF\',"
+    +"  _params:{"
+		+"    AccSchema:\'"+$P{accSchemaID}+"\',"
+		+"    BusinessPartner: [\'"+$P{BPartnerID}+"\'],"
+		+"    Column1:"+$P{inpColumn1}+","
+		+"    Column2:"+$P{inpColumn2}+","
+		+"    Column3:"+$P{inpColumn3}+","
+		+"    Column4:"+$P{inpColumn4}+","
+		+"    CurrentDate: \'"+$P{dateFromUI}+"\',"
+		+"    Details:\'true\',"
+		+"    Doubtful:\'"+$P{showDoubtfulDebt}+"\',"
+		+"    Organization:\'"+$P{organizationID}+"\',"
+		+"    RecOrPay:\'"+$P{recOrPay}+"\',"
+		+"    ShowVoid:\'"+$P{void}+"\'"
+		+"  }"
+		+"},"
+		+"{"
+		+"  processId:\'"+$P{processId}+"\',"
+		+"  reportId:\'"+$P{reportId}+"',"
+		+"  windowId: null"
+		+"},"
+		+"function(rpcResponse, data, rpcRequest) {"
+		+"  console.log(data);"
+		+"  top.OB.Utilities.Action.executeJSON(data.responseActions, null, null, null);"
+		+"}"
 		+");"]]></hyperlinkReferenceExpression>
 			</textField>
 			<textField hyperlinkType="Reference">
@@ -477,33 +480,33 @@
 					<font isUnderline="true"/>
 				</textElement>
 				<textFieldExpression><![CDATA["XLS"]]></textFieldExpression>
-				<hyperlinkReferenceExpression><![CDATA["javascript:top.OB.RemoteCallManager.call(\'org.openbravo.common.actionhandler.AgingBalanceReportActionHandler\',"
-    +"{"
-    +"  _buttonValue:\'XLS\',"
-    +"  _params:{"
-		+"    AccSchema:\'"+$P{accSchemaID}+"\',"
-		+"    BusinessPartner: [\'"+$P{BPartnerID}+"\'],"
-		+"    Column1:"+$P{inpColumn1}+","
-		+"    Column2:"+$P{inpColumn2}+","
-		+"    Column3:"+$P{inpColumn3}+","
-		+"    Column4:"+$P{inpColumn4}+","
-		+"    CurrentDate: \'"+$P{dateFromUI}+"\',"
-		+"    Details:\'true\',"
-		+"    Doubtful:\'"+$P{showDoubtfulDebt}+"\',"
-		+"    Organization:\'"+$P{organizationID}+"\',"
-		+"    RecOrPay:\'"+$P{recOrPay}+"\',"
-		+"    ShowVoid:\'"+$P{void}+"\'"
-		+"  }"
-		+"},"
-		+"{"
-		+"  processId:\'"+$P{processId}+"\',"
-		+"  reportId:\'"+$P{reportId}+"',"
-		+"  windowId: null"
-		+"},"
-		+"function(rpcResponse, data, rpcRequest) {"
-		+"  console.log(data);"
-		+"  top.OB.Utilities.Action.executeJSON(data.responseActions, null, null, null);"
-		+"}"
+				<hyperlinkReferenceExpression><![CDATA["javascript:top.OB.RemoteCallManager.call(\'org.openbravo.common.actionhandler.AgingBalanceReportActionHandler\',"
+    +"{"
+    +"  _buttonValue:\'XLS\',"
+    +"  _params:{"
+		+"    AccSchema:\'"+$P{accSchemaID}+"\',"
+		+"    BusinessPartner: [\'"+$P{BPartnerID}+"\'],"
+		+"    Column1:"+$P{inpColumn1}+","
+		+"    Column2:"+$P{inpColumn2}+","
+		+"    Column3:"+$P{inpColumn3}+","
+		+"    Column4:"+$P{inpColumn4}+","
+		+"    CurrentDate: \'"+$P{dateFromUI}+"\',"
+		+"    Details:\'true\',"
+		+"    Doubtful:\'"+$P{showDoubtfulDebt}+"\',"
+		+"    Organization:\'"+$P{organizationID}+"\',"
+		+"    RecOrPay:\'"+$P{recOrPay}+"\',"
+		+"    ShowVoid:\'"+$P{void}+"\'"
+		+"  }"
+		+"},"
+		+"{"
+		+"  processId:\'"+$P{processId}+"\',"
+		+"  reportId:\'"+$P{reportId}+"',"
+		+"  windowId: null"
+		+"},"
+		+"function(rpcResponse, data, rpcRequest) {"
+		+"  console.log(data);"
+		+"  top.OB.Utilities.Action.executeJSON(data.responseActions, null, null, null);"
+		+"}"
 		+");"]]></hyperlinkReferenceExpression>
 			</textField>
 			<line>
--- a/src/org/openbravo/erpCommon/ad_reports/AgingScheduleHTML.jrxml	Wed Aug 05 08:17:58 2020 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/AgingScheduleHTML.jrxml	Tue Aug 11 12:43:41 2020 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
-<!-- 2016-11-02T09:12:32 -->
+<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
+<!-- 2016-11-02T09:12:32 -->
 <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ReportAgingBalance" pageWidth="975" pageHeight="842" columnWidth="915" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" uuid="bd188040-4e9b-4416-89da-8ac052697179">
 	<property name="ireport.scriptlethandling" value="0"/>
 	<property name="ireport.encoding" value="UTF-8"/>
@@ -106,6 +106,9 @@
 	<parameter name="void" class="java.lang.String">
 		<defaultValueExpression><![CDATA["true"]]></defaultValueExpression>
 	</parameter>
+	<parameter name="reversed" class="java.lang.String">
+		<defaultValueExpression><![CDATA["true"]]></defaultValueExpression>
+	</parameter>
 	<parameter name="processId" class="java.lang.String" isForPrompting="false">
 		<parameterDescription><![CDATA[]]></parameterDescription>
 	</parameter>
@@ -439,34 +442,35 @@
 					<font size="8" isUnderline="true"/>
 				</textElement>
 				<textFieldExpression><![CDATA[$F{BPartner}]]></textFieldExpression>
-				<hyperlinkReferenceExpression><![CDATA["javascript:top.OB.RemoteCallManager.call(\'org.openbravo.common.actionhandler.AgingBalanceReportActionHandler\',"
-    +"{"
-    +"  _buttonValue:\'HTML\',"
-    +"  _params:{"
-		+"    AccSchema:\'"+$P{AccSchema}+"\',"
-		+"    BusinessPartner: [\'"+$F{BPartnerID}+"\'],"
-		+"    Column1:"+$P{inpColumn1}+","
-		+"    Column2:"+$P{inpColumn2}+","
-		+"    Column3:"+$P{inpColumn3}+","
-		+"    Column4:"+$P{inpColumn4}+","
-		+"    CurrentDate: \'"+$P{dateFromUI}+"\',"
-		+"    Details:\'true\',"
-		+"    Doubtful:\'"+$P{showDoubtfulDebt}+"\',"
-		+"    Organization:\'"+$P{Organization}+"\',"
-		+"    RecOrPay:\'"+$P{recOrPay}+"\',"
-		+"    ShowVoid:\'"+$P{void}+"\'"
-		+"  }"
-		+"},"
-		+"{"
-		+"  processId:\'"+$P{processId}+"\',"
-		+"  reportId:\'"+$P{reportId}+"',"
-		+"  windowId: null"
-		+"},"
-		+"function(rpcResponse, data, rpcRequest) {"
-		+"  console.log(data);"
-		+"  console.log(\'OB\',top.OB);"
-		+"  top.OB.Utilities.Action.executeJSON(data.responseActions, null, null, null);"
-		+"}"
+				<hyperlinkReferenceExpression><![CDATA["javascript:top.OB.RemoteCallManager.call(\'org.openbravo.common.actionhandler.AgingBalanceReportActionHandler\',"
+    +"{"
+    +"  _buttonValue:\'HTML\',"
+    +"  _params:{"
+		+"    AccSchema:\'"+$P{AccSchema}+"\',"
+		+"    BusinessPartner: [\'"+$F{BPartnerID}+"\'],"
+		+"    Column1:"+$P{inpColumn1}+","
+		+"    Column2:"+$P{inpColumn2}+","
+		+"    Column3:"+$P{inpColumn3}+","
+		+"    Column4:"+$P{inpColumn4}+","
+		+"    CurrentDate: \'"+$P{dateFromUI}+"\',"
+		+"    Details:\'true\',"
+		+"    Doubtful:\'"+$P{showDoubtfulDebt}+"\',"
+		+"    Organization:\'"+$P{Organization}+"\',"
+		+"    RecOrPay:\'"+$P{recOrPay}+"\',"
+		+"    ShowVoid:\'"+$P{void}+"\',"
+		+"    ShowReversed:\'"+$P{reversed}+"\'"
+		+"  }"
+		+"},"
+		+"{"
+		+"  processId:\'"+$P{processId}+"\',"
+		+"  reportId:\'"+$P{reportId}+"',"
+		+"  windowId: null"
+		+"},"
+		+"function(rpcResponse, data, rpcRequest) {"
+		+"  console.log(data);"
+		+"  console.log(\'OB\',top.OB);"
+		+"  top.OB.Utilities.Action.executeJSON(data.responseActions, null, null, null);"
+		+"}"
 		+");"]]></hyperlinkReferenceExpression>
 				<hyperlinkTooltipExpression><![CDATA["Details"]]></hyperlinkTooltipExpression>
 			</textField>