Netting payments must have a finacc_txn_amount of 0
authorAsier Martirena <asier.martirena@openbravo.com>
Tue, 07 Mar 2017 18:39:59 +0100
changeset 31452 a3e51b7b0f07
parent 31451 5ddc6b8442aa
child 31453 0893eb4f4a85
Netting payments must have a finacc_txn_amount of 0
src-util/modulescript/src/org/openbravo/modulescript/UpdateFinTransactionAmount.java
src-util/modulescript/src/org/openbravo/modulescript/UpdateFinTransactionAmount_data.xsql
src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UpdateFinTransactionAmount.java	Tue Mar 07 18:39:59 2017 +0100
@@ -0,0 +1,49 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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) 2017 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.modulescript;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.UUID;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletException;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class UpdateFinTransactionAmount extends ModuleScript {
+
+  @Override
+  public void execute() {
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      UpdateFinTransactionAmountData.updateFinTransactionAmountData(cp);
+    } catch (Exception e) {
+      handleError(e);
+    }
+  }
+
+  //  @Override
+  //  protected ModuleScriptExecutionLimits getModuleScriptExecutionLimits() {
+  //    return new ModuleScriptExecutionLimits("0", null,
+  //        new OpenbravoVersion(2,50,17641));
+  //  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UpdateFinTransactionAmount_data.xsql	Tue Mar 07 18:39:59 2017 +0100
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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) 2017 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="updateFinTransactionAmountData" package="org.openbravo.modulescript">
+  <SqlClassComment></SqlClassComment>
+  <SqlMethod name="update" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        UPDATE FIN_Payment SET finacc_txn_amount = 0 WHERE amount = 0
+      ]]>
+    </Sql>
+  </SqlMethod>
+</SqlClass>
\ No newline at end of file
--- a/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java	Tue Mar 07 09:44:44 2017 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/CancelAndReplaceUtils.java	Tue Mar 07 18:39:59 2017 +0100
@@ -1058,6 +1058,7 @@
 
     // Set amount and used credit to zero
     nettingPayment.setAmount(BigDecimal.ZERO);
+    nettingPayment.setFinancialTransactionAmount(BigDecimal.ZERO);
     nettingPayment.setUsedCredit(BigDecimal.ZERO);
     String truncatedDescription = (description.length() > 255) ? description.substring(0, 252)
         .concat("...").toString() : description.toString();