Fixes bug 21312
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Tue, 04 Sep 2012 17:35:13 +0200
changeset 17909 b1b0cc2cfdf3
parent 17908 41243b70efef
child 17910 d81ffac951d9
Fixes bug 21312
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentProcessedValue.java
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentProcessedValue_data.xsql
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentProcessedValueData.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
src-db/database/sourcedata/AD_REF_LIST.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml	Thu Sep 06 12:04:26 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml	Tue Sep 04 17:35:13 2012 +0200
@@ -29,7 +29,7 @@
 <!--575E470ABADB4C278132C957A78C47E3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--575E470ABADB4C278132C957A78C47E3-->  <NAME><![CDATA[Process Payment valid actions]]></NAME>
 <!--575E470ABADB4C278132C957A78C47E3-->  <TYPE><![CDATA[S]]></TYPE>
-<!--575E470ABADB4C278132C957A78C47E3-->  <CODE><![CDATA[((@EM_APRM_Process_Payment@ = 'P' AND AD_Ref_List.value='P') OR (@EM_APRM_Process_Payment@ = 'R' AND AD_Ref_List.value IN ('RE')) OR (@EM_APRM_Process_Payment@ = 'R' AND AD_Ref_List.value IN ('V') AND @Status@='RPAE') OR (@EM_APRM_Process_Payment@ is null))]]></CODE>
+<!--575E470ABADB4C278132C957A78C47E3-->  <CODE><![CDATA[((@EM_APRM_Process_Payment@ = 'P' AND AD_Ref_List.value='P') OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('RE','R')) OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('V') AND @Status@='RPAE') OR (@EM_APRM_Process_Payment@ is null)) AND AD_Ref_List.IsActive = 'Y']]></CODE>
 <!--575E470ABADB4C278132C957A78C47E3-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--575E470ABADB4C278132C957A78C47E3--></AD_VAL_RULE>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentProcessedValue.java	Tue Sep 04 17:35:13 2012 +0200
@@ -0,0 +1,35 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.advpaymentmngt.modulescript;
+
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.modulescript.ModuleScript;
+
+public class UpdatePaymentProcessedValue extends ModuleScript {
+
+  @Override
+  public void execute() {
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      UpdatePaymentProcessedValueData.update(cp);
+    } catch (Exception e) {
+      handleError(e);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentProcessedValue_data.xsql	Tue Sep 04 17:35:13 2012 +0200
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+-->
+<SqlClass name="UpdatePaymentProcessedValueData" package="org.openbravo.advpaymentmngt.modulescript">
+  <SqlClassComment></SqlClassComment>
+     <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        select 1 as name from dual
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="update" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        UPDATE FIN_PAYMENT SET EM_APRM_PROCESS_PAYMENT='RE' WHERE EM_APRM_PROCESS_PAYMENT='R'
+      ]]>
+    </Sql>
+  </SqlMethod>
+</SqlClass>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentProcessedValueData.java	Tue Sep 04 17:35:13 2012 +0200
@@ -0,0 +1,113 @@
+//Sqlc generated V1.O00-1
+package org.openbravo.advpaymentmngt.modulescript;
+
+import java.sql.*;
+
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.data.FieldProvider;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.data.UtilSql;
+import java.util.*;
+
+class UpdatePaymentProcessedValueData implements FieldProvider {
+static Logger log4j = Logger.getLogger(UpdatePaymentProcessedValueData.class);
+  private String InitRecordNumber="0";
+  public String name;
+
+  public String getInitRecordNumber() {
+    return InitRecordNumber;
+  }
+
+  public String getField(String fieldName) {
+    if (fieldName.equalsIgnoreCase("name"))
+      return name;
+   else {
+     log4j.debug("Field does not exist: " + fieldName);
+     return null;
+   }
+ }
+
+  public static UpdatePaymentProcessedValueData[] select(ConnectionProvider connectionProvider)    throws ServletException {
+    return select(connectionProvider, 0, 0);
+  }
+
+  public static UpdatePaymentProcessedValueData[] select(ConnectionProvider connectionProvider, int firstRegister, int numberRegisters)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "        select 1 as name from dual";
+
+    ResultSet result;
+    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
+    PreparedStatement st = null;
+
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+
+      result = st.executeQuery();
+      long countRecord = 0;
+      long countRecordSkip = 1;
+      boolean continueResult = true;
+      while(countRecordSkip < firstRegister && continueResult) {
+        continueResult = result.next();
+        countRecordSkip++;
+      }
+      while(continueResult && result.next()) {
+        countRecord++;
+        UpdatePaymentProcessedValueData objectUpdatePaymentProcessedValueData = new UpdatePaymentProcessedValueData();
+        objectUpdatePaymentProcessedValueData.name = UtilSql.getValue(result, "name");
+        objectUpdatePaymentProcessedValueData.InitRecordNumber = Integer.toString(firstRegister);
+        vector.addElement(objectUpdatePaymentProcessedValueData);
+        if (countRecord >= numberRegisters && numberRegisters != 0) {
+          continueResult = false;
+        }
+      }
+      result.close();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    UpdatePaymentProcessedValueData objectUpdatePaymentProcessedValueData[] = new UpdatePaymentProcessedValueData[vector.size()];
+    vector.copyInto(objectUpdatePaymentProcessedValueData);
+    return(objectUpdatePaymentProcessedValueData);
+  }
+
+  public static int update(ConnectionProvider connectionProvider)    throws ServletException {
+    String strSql = "";
+    strSql = strSql + 
+      "        UPDATE FIN_PAYMENT SET EM_APRM_PROCESS_PAYMENT='RE' WHERE EM_APRM_PROCESS_PAYMENT='R'";
+
+    int updateCount = 0;
+    PreparedStatement st = null;
+
+    try {
+    st = connectionProvider.getPreparedStatement(strSql);
+
+      updateCount = st.executeUpdate();
+    } catch(SQLException e){
+      log4j.error("SQL error in query: " + strSql + "Exception:"+ e);
+      throw new ServletException("@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage());
+    } catch(Exception ex){
+      log4j.error("Exception in query: " + strSql + "Exception:"+ ex);
+      throw new ServletException("@CODE=@" + ex.getMessage());
+    } finally {
+      try {
+        connectionProvider.releasePreparedStatement(st);
+      } catch(Exception ignore){
+        ignore.printStackTrace();
+      }
+    }
+    return(updateCount);
+  }
+}
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Thu Sep 06 12:04:26 2012 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Tue Sep 04 17:35:13 2012 +0200
@@ -218,7 +218,7 @@
 
           payment.setWriteoffAmount(paymentWriteOfAmount);
           payment.setProcessed(true);
-          payment.setAPRMProcessPayment("R");
+          payment.setAPRMProcessPayment("RE");
           if (payment.getGeneratedCredit() == null) {
             payment.setGeneratedCredit(BigDecimal.ZERO);
           }
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Thu Sep 06 12:04:26 2012 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Tue Sep 04 17:35:13 2012 +0200
@@ -8469,12 +8469,13 @@
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <AD_REF_LIST_ID><![CDATA[3946D07DF63C47E7A11BFADCF160D6B6]]></AD_REF_LIST_ID>
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--3946D07DF63C47E7A11BFADCF160D6B6-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--3946D07DF63C47E7A11BFADCF160D6B6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <VALUE><![CDATA[R]]></VALUE>
-<!--3946D07DF63C47E7A11BFADCF160D6B6-->  <NAME><![CDATA[Reactivate]]></NAME>
+<!--3946D07DF63C47E7A11BFADCF160D6B6-->  <NAME><![CDATA[Reactivate and Delete Lines]]></NAME>
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <DESCRIPTION><![CDATA[This option will reactivate the payment and remove its Details and amounts.]]></DESCRIPTION>
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <AD_REFERENCE_ID><![CDATA[36972531DA994BB38ECB91993058282F]]></AD_REFERENCE_ID>
 <!--3946D07DF63C47E7A11BFADCF160D6B6-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--3946D07DF63C47E7A11BFADCF160D6B6-->  <SEQNO><![CDATA[20]]></SEQNO>
 <!--3946D07DF63C47E7A11BFADCF160D6B6--></AD_REF_LIST>
 
 <!--3ABF54A29AF94B35AB205894C5ED319C--><AD_REF_LIST>
@@ -9267,6 +9268,7 @@
 <!--846C98032A894F1BB2F0991CF6D767F3-->  <DESCRIPTION><![CDATA[This option will reactivate the payment and will keep details and amounts for a later edition.]]></DESCRIPTION>
 <!--846C98032A894F1BB2F0991CF6D767F3-->  <AD_REFERENCE_ID><![CDATA[36972531DA994BB38ECB91993058282F]]></AD_REFERENCE_ID>
 <!--846C98032A894F1BB2F0991CF6D767F3-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--846C98032A894F1BB2F0991CF6D767F3-->  <SEQNO><![CDATA[10]]></SEQNO>
 <!--846C98032A894F1BB2F0991CF6D767F3--></AD_REF_LIST>
 
 <!--855D3B08CF8248ADB9BB84CF8D3FD9C5--><AD_REF_LIST>
@@ -10165,6 +10167,7 @@
 <!--C293E5B8BA954575B979A1DA586B89D8-->  <NAME><![CDATA[Process]]></NAME>
 <!--C293E5B8BA954575B979A1DA586B89D8-->  <AD_REFERENCE_ID><![CDATA[36972531DA994BB38ECB91993058282F]]></AD_REFERENCE_ID>
 <!--C293E5B8BA954575B979A1DA586B89D8-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C293E5B8BA954575B979A1DA586B89D8-->  <SEQNO><![CDATA[40]]></SEQNO>
 <!--C293E5B8BA954575B979A1DA586B89D8--></AD_REF_LIST>
 
 <!--C2D0715006EA46369DDA36BC0F161462--><AD_REF_LIST>
@@ -11078,6 +11081,7 @@
 <!--FF80818130BC11480130BC193B3F0012-->  <NAME><![CDATA[Void]]></NAME>
 <!--FF80818130BC11480130BC193B3F0012-->  <AD_REFERENCE_ID><![CDATA[36972531DA994BB38ECB91993058282F]]></AD_REFERENCE_ID>
 <!--FF80818130BC11480130BC193B3F0012-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FF80818130BC11480130BC193B3F0012-->  <SEQNO><![CDATA[30]]></SEQNO>
 <!--FF80818130BC11480130BC193B3F0012--></AD_REF_LIST>
 
 <!--FF80818130BC11480130BC1CEDD20021--><AD_REF_LIST>