Fixes issue 39903:Avoid duplicated records in the last records of Settle/Protest
authorMark <markmm82@gmail.com>
Sun, 20 Jan 2019 18:26:26 -0500
changeset 619 f21d7ee630cd
parent 618 437466c35d2d
child 620 a997de21a203
Fixes issue 39903:Avoid duplicated records in the last records of Settle/Protest
Remittance if some lines have same payments and scroll is shown

Avoid to return the last record when page size is 0. This way it is not considered the last record
twice if.
Also was fixed the pagination in the report to get the less vaue between the pagination
last record and the total of records, taking into account that it is possible records
with the same payment.
src/org/openbravo/module/remittance/ad_forms/CancelReturnRemittance.html
src/org/openbravo/module/remittance/ad_forms/CancelReturnRemittance.java
--- a/src/org/openbravo/module/remittance/ad_forms/CancelReturnRemittance.html	Thu Oct 04 19:35:29 2018 +0200
+++ b/src/org/openbravo/module/remittance/ad_forms/CancelReturnRemittance.html	Sun Jan 20 18:26:26 2019 -0500
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2014 Openbravo SLU
+ * All portions are Copyright (C) 2011-2019 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -210,11 +210,15 @@
   var res =  "<nobr class='Main_ToolBar_text_bookmark'>";
   var strPrevious = getMessage("GridPreviousPage");
   var strNext = getMessage("GridNextPage");
+  var strCurrPageEndRecord = (currPageStart+offset+liveGrid.visibleRows);
+  if (strCurrPageEndRecord > (currPageStart+liveGrid.metaData.getTotalRows())) {
+    strCurrPageEndRecord = (currPageStart+liveGrid.metaData.getTotalRows());
+  }
   
   if (!firstPage) {
     res = res + "<a href='#' onclick='gridMovePage(\"PREVIOUSPAGE\")' class='Main_ToolBar_text_pagerange'>" + strPrevious + " " + backendPageSize + "</a>&nbsp;&nbsp;";
   }
-  res = res + ((liveGrid.visibleRows>0)?(currPageStart+offset+1):0) + " - "+ (currPageStart+offset+liveGrid.visibleRows) + " / " + (currPageStart+liveGrid.metaData.getTotalRows());
+  res = res + ((liveGrid.visibleRows>0)?(currPageStart+offset+1):0) + " - "+ strCurrPageEndRecord + " / " + (currPageStart+liveGrid.metaData.getTotalRows());
   if (pageFull) {
     res = res + "&nbsp;&nbsp;<a href='#' onclick='gridMovePage(\"NEXTPAGE\")' class='Main_ToolBar_text_pagerange'>" + strNext + " " + backendPageSize + "</a>";
   }
--- a/src/org/openbravo/module/remittance/ad_forms/CancelReturnRemittance.java	Thu Oct 04 19:35:29 2018 +0200
+++ b/src/org/openbravo/module/remittance/ad_forms/CancelReturnRemittance.java	Sun Jan 20 18:26:26 2019 -0500
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2018 Openbravo SLU
+ * All portions are Copyright (C) 2011-2019 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -543,7 +543,6 @@
     } else {
       strRowsData.append("</xml-data>\n");
     }
-
     response.setContentType("text/xml; charset=UTF-8");
     response.setHeader("Cache-Control", "no-cache");
     PrintWriter out = response.getWriter();
@@ -637,7 +636,7 @@
       Remittance remittance, String description, BusinessPartner businessPartner,
       String strDateFrom, String strDateTo, int offset, int pageSize, String strOrderByProperty,
       String strAscDesc) {
-    if (organization == null) {
+    if (organization == null || pageSize == 0) {
       return new ArrayList<FIN_Payment>();
     }
     List<FIN_Payment> payments = new ArrayList<FIN_Payment>();
@@ -671,7 +670,7 @@
   private List<RemittanceLine> getRemittanceLine(Organization organization, Remittance remittance,
       String description, BusinessPartner businessPartner, String strDateFrom, String strDateTo,
       int offset, int pageSize, String strOrderByProperty, String strAscDesc) {
-    if (organization == null) {
+    if (organization == null || pageSize == 0) {
       return new ArrayList<RemittanceLine>();
     }
     Date datefrom = FIN_Utility.getDate(strDateFrom);