Fixed bug 23279 Http 0 error obtained in manual reconciliation
authorSandra Huguet <sandra.huguet@openbravo.com>
Thu, 30 May 2013 09:30:09 +0200
changeset 20496 ff813ef90a4e
parent 20495 8a7979c5a247
child 20497 9708bd1d96eb
Fixed bug 23279 Http 0 error obtained in manual reconciliation
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.html
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ReconciliationGrid.srpt
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ReconciliationGrid.xml
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.html	Thu May 30 11:45:18 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.html	Thu May 30 09:30:09 2013 +0200
@@ -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) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -51,6 +51,7 @@
 </script>
 
 <script language="JavaScript" type="text/javascript">
+var checksToEnable=[];
 function showWarning(){
     if(!document.frmMain.inpAfterDate.checked){
       showJSMessage('APRM_DateWillBeUpdated');
@@ -115,6 +116,7 @@
 }
 
 function hideClearedTransactions(isChecked) {
+  disable();
   var chk = document.frmMain.inpTransactionId;
   if (chk === undefined) {
     return true;
@@ -132,7 +134,13 @@
       }
     }
   }
-  return true;
+  try {
+	 var url = "../org.openbravo.advpaymentmngt.ad_actionbutton/Reconciliation.html";
+	 var paramXMLReq = null;
+	 return submitXmlHttpRequest(callBackLineStatus, document.frmMain, "UPDATESTATUS", url, false, null, paramXMLReq);
+	 } catch (e) { 
+	  alert(e);
+	 }
 }
 
 function updateAll(mark) {
@@ -255,19 +263,17 @@
 <script language="JavaScript" type="text/javascript">
 
 function saveTransactionLineStatus(isChecked, transLineId) {
-  document.frmMain.inpCurrentTransIdSelected.value = transLineId;
-  document.frmMain.inpIsCurrentTransSelected.value = isChecked;
-  document.frmMain.inpClearAll.disabled = true;
-  document.getElementById('buttonSave').disabled = true;
-  document.getElementById('buttonProcess').disabled = true;
-  document.getElementById('buttonCancel').disabled = true;
-  try {
-    var url = "../org.openbravo.advpaymentmngt.ad_actionbutton/Reconciliation.html";
-    var paramXMLReq = null;
-    return submitXmlHttpRequest(callBackLineStatus, document.frmMain, "UPDATESTATUS", url, false, null, paramXMLReq);
-  } catch (e) {
-    alert(e);
-  }
+	document.frmMain.inpCurrentTransIdSelected.value = transLineId;
+	document.frmMain.inpIsCurrentTransSelected.value = isChecked;
+	disable();  
+	try {
+	  var url = "../org.openbravo.advpaymentmngt.ad_actionbutton/Reconciliation.html";
+	  var paramXMLReq = null;
+	  return submitXmlHttpRequest(callBackLineStatus, document.frmMain, "UPDATESTATUS", url, false, null, paramXMLReq);
+	  
+      } catch (e) { 
+	    alert(e);
+	  }	      
 }
 
 function callBackLineStatus(paramXMLParticular, XMLHttpRequestObj) {
@@ -276,10 +282,7 @@
     try {
       if (XMLHttpRequestObj.responseText) {
         strText = XMLHttpRequestObj.responseText;
-        document.frmMain.inpClearAll.disabled = false;
-        document.getElementById('buttonSave').disabled = false;
-        document.getElementById('buttonProcess').disabled = false;
-        document.getElementById('buttonCancel').disabled = false;
+        enable();
       } else {
       }
     } catch (e) {
@@ -289,6 +292,7 @@
 }
 
 function loadGrid() {
+  disable();
   try {
     var url = "../org.openbravo.advpaymentmngt.ad_actionbutton/Reconciliation.html";
     var paramXMLReq = null;
@@ -326,6 +330,7 @@
           document.frmMain.inpIsFirstLoad.value = "false";
         }
         updateWhenAjaxResponse();
+        enable();
       } else {
         document.getElementById('sectionGrid').innerHTML = '';
       }
@@ -334,6 +339,35 @@
   }
   return true;
 }
+
+function enable(){
+	  document.frmMain.inpClearAll.disabled = false;
+	  document.getElementById('buttonSave').disabled = false;
+	  document.getElementById('buttonProcess').disabled = false;
+	  document.getElementById('buttonCancel').disabled = false;
+	  document.getElementById('paramHideCleared').disabled = false;
+	  document.getElementById('paramAfterDate').disabled = false;
+	  for(var i=0; i<checksToEnable.length; i++){
+	     document.getElementById(checksToEnable[i]).disabled = false;
+	  }
+	}
+
+	function disable(){
+	    document.frmMain.inpClearAll.disabled = true;
+	  document.getElementById('buttonSave').disabled = true;
+	  document.getElementById('buttonProcess').disabled = true;
+	  document.getElementById('buttonCancel').disabled = true;
+	  document.getElementById('paramHideCleared').disabled = true;
+	  document.getElementById('paramAfterDate').disabled = true;
+	  var items = document.frmMain.getElementsByTagName("input");
+	  checksToEnable = [];
+	  for(var i=0; i<items.length; i++){
+	    if(items[i].name === 'inpTransactionId'){
+	        items[i].disabled=true;
+	        checksToEnable.push(items[i].id);
+	    }
+	  }
+	}
 </script>
 <script language="JavaScript" type="text/javascript">
   function onLoadDo(){
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java	Thu May 30 11:45:18 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java	Thu May 30 09:30:09 2013 +0200
@@ -114,8 +114,9 @@
 
     } else if (vars.commandIn("UPDATESTATUS")) {
       String strFinancialAccountId = vars.getStringParameter("inpFinFinancialAccountId", "");
-      String strSelectedTransId = vars.getStringParameter("inpCurrentTransIdSelected");
+      String strSelectedTransId = vars.getStringParameter("inpCurrentTransIdSelected", "");
       boolean isChecked = "true".equals(vars.getStringParameter("inpIsCurrentTransSelected"));
+
       updateTransactionStatus(response, strFinancialAccountId, strSelectedTransId, isChecked);
     }
 
@@ -126,30 +127,31 @@
 
     OBContext.setAdminMode();
     try {
-      FIN_FinaccTransaction trans = OBDal.getInstance().get(FIN_FinaccTransaction.class,
-          strSelectedTransId);
+      if (strSelectedTransId != "") {
+        FIN_FinaccTransaction trans = OBDal.getInstance().get(FIN_FinaccTransaction.class,
+            strSelectedTransId);
+        String newStatus = "RPPC";
+        if (!isChecked) {
+          newStatus = (trans.getPaymentAmount().compareTo(trans.getDepositAmount()) >= 0) ? "RDNC"
+              : "PWNC";
+          trans.setReconciliation(null);
+          if (trans.getFinPayment() != null) {
+            trans.getFinPayment().setStatus((trans.getFinPayment().isReceipt()) ? "RDNC" : "PWNC");
+          }
+        } else {
+          FIN_FinancialAccount account = OBDal.getInstance().get(FIN_FinancialAccount.class,
+              strFinancialAccountId);
+          FIN_Reconciliation reconciliation = TransactionsDao.getLastReconciliation(account, "N");
+          trans.setReconciliation(reconciliation);
+          if (trans.getFinPayment() != null) {
+            trans.getFinPayment().setStatus("RPPC");
+          }
+        }
 
-      String newStatus = "RPPC";
-      if (!isChecked) {
-        newStatus = (trans.getPaymentAmount().compareTo(trans.getDepositAmount()) >= 0) ? "RDNC"
-            : "PWNC";
-        trans.setReconciliation(null);
-        if (trans.getFinPayment() != null) {
-          trans.getFinPayment().setStatus((trans.getFinPayment().isReceipt()) ? "RDNC" : "PWNC");
-        }
-      } else {
-        FIN_FinancialAccount account = OBDal.getInstance().get(FIN_FinancialAccount.class,
-            strFinancialAccountId);
-        FIN_Reconciliation reconciliation = TransactionsDao.getLastReconciliation(account, "N");
-        trans.setReconciliation(reconciliation);
-        if (trans.getFinPayment() != null) {
-          trans.getFinPayment().setStatus("RPPC");
-        }
+        trans.setStatus(newStatus);
+        OBDal.getInstance().save(trans);
+        OBDal.getInstance().flush();
       }
-      trans.setStatus(newStatus);
-      OBDal.getInstance().save(trans);
-      OBDal.getInstance().flush();
-
       response.setContentType("text/html; charset=UTF-8");
       PrintWriter out = response.getWriter();
       out.println("");
@@ -468,6 +470,7 @@
     BigDecimal totalDeposit = new BigDecimal(strTotalDeposit);
 
     for (FieldProvider fp : data) {
+
       if (!map.containsKey(fp.getField("transactionId"))
           && !fp.getField("markSelectedId").isEmpty()) {
         BigDecimal payAmt = new BigDecimal(fp.getField("paymentAmount"));
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ReconciliationGrid.srpt	Thu May 30 11:45:18 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ReconciliationGrid.srpt	Thu May 30 09:30:09 2013 +0200
@@ -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) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -28,6 +28,7 @@
     <td class="DataGrid_Body_Cell" title="zz" id="fieldDescription">xxDescription</td>
     <td class="DataGrid_Body_Cell_Amount" id="fieldPaymentAmount">xx150.00</td>
     <td class="DataGrid_Body_Cell_Amount" id="fieldDepositAmount">xx60.00</td>
-    <td class="DataGrid_Body_LineNoCell"><input type="checkbox" name="inpTransactionId" value="" id="fieldTransactionId" onclick="saveTransactionLineStatus(this.checked, this.value); updateAmounts(this.value, this.checked); unselectClearAll(this.checked); return true;"/></td>
+    <td class="DataGrid_Body_LineNoCell">
+    <input type="checkbox" name="inpTransactionId" value="" id="fieldTransactionId_xx" onclick="saveTransactionLineStatus(this.checked, 'xx'); updateAmounts(this.value, this.checked); unselectClearAll(this.checked); return true;"/></td>
   </tr>
-</span>
+</span>
\ No newline at end of file
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ReconciliationGrid.xml	Thu May 30 11:45:18 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ReconciliationGrid.xml	Thu May 30 09:30:09 2013 +0200
@@ -42,6 +42,10 @@
     <FIELD id="fieldRecordDepositAmt" attribute="value" format="euroEdition">depositAmount</FIELD>
     <FIELD id="fieldRecordPaymentAmt" attribute="name" replace="xx">transactionId</FIELD>
     <FIELD id="fieldRecordDepositAmt" attribute="name" replace="xx">transactionId</FIELD>
+   
+    <FIELD id="fieldTransactionId_xx" attribute="value">transactionId</FIELD>
+    <FIELD id="fieldTransactionId_xx" attribute="id">transactionId</FIELD>
+    <FIELD id="fieldTransactionId_xx" attribute="onclick" replace="xx">transactionId</FIELD>
     
     <SECTION id="sectionLinesDetail"/>
   </structure>