Fixes bug 20275
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Tue, 17 Apr 2012 19:34:56 +0200
changeset 16509 0e2e1d733f08
parent 16091 4a4cc349c6ba
child 16510 0f6fea21f041
Fixes bug 20275
src-util/modulescript/build/classes/org/openbravo/modulescript/PaymentZeroAmount.class
src-util/modulescript/build/classes/org/openbravo/modulescript/PaymentZeroAmountData.class
src-util/modulescript/src/org/openbravo/modulescript/PaymentZeroAmount.java
src-util/modulescript/src/org/openbravo/modulescript/PaymentZeroAmount_data.xsql
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/PaymentZeroAmount.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/PaymentZeroAmountData.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/PaymentZeroAmount.java	Tue Apr 17 19:34:56 2012 +0200
@@ -0,0 +1,36 @@
+/*
+ *************************************************************************
+ * 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) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.modulescript;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class PaymentZeroAmount extends ModuleScript {
+
+  //This module script has ben created due to issue 20275
+  @Override
+  public void execute() {
+    try {
+      ConnectionProvider cp = getConnectionProvider();
+      PaymentZeroAmountData.updatePaymentPostedValue(cp);
+      
+    } catch (Exception e) {
+      handleError(e);
+    }
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/modulescript/src/org/openbravo/modulescript/PaymentZeroAmount_data.xsql	Tue Apr 17 19:34:56 2012 +0200
@@ -0,0 +1,40 @@
+<?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) 2012 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="PaymentZeroAmountData" package="org.openbravo.modulescript">
+  <SqlClassComment></SqlClassComment>
+  <SqlMethod name="select" type="preparedStatement" return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+      SELECT '' as ad_client_id FROM DUAL;
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="updatePaymentPostedValue" type="preparedStatement" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+        update fin_payment set posted = 'N', processing = 'N'
+        where processed = 'Y'
+        and status in ('PWNC', 'RPR', 'RPPC', 'PPM', 'RDNC')
+        and posted not in ('N', 'Y')
+        and amount=0
+      ]]>
+    </Sql>
+  </SqlMethod>
+</SqlClass>
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Fri Apr 13 12:38:42 2012 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Tue Apr 17 19:34:56 2012 +0200
@@ -324,12 +324,14 @@
         }
       }
       FIN_Payment payment = OBDal.getInstance().get(FIN_Payment.class, Record_ID);
-      fact.createLine(
-          null,
-          getAccount(conn, payment.getPaymentMethod(), payment.getAccount(), as,
-              payment.isReceipt()), C_Currency_ID, (payment.isReceipt() ? Amounts[AMTTYPE_Gross]
-              : ""), (payment.isReceipt() ? "" : Amounts[AMTTYPE_Gross]), Fact_Acct_Group_ID,
-          "999999", DocumentType, conn);
+      if (BigDecimal.ZERO.compareTo(new BigDecimal(Amounts[AMTTYPE_Gross])) != 0) {
+        fact.createLine(
+            null,
+            getAccount(conn, payment.getPaymentMethod(), payment.getAccount(), as,
+                payment.isReceipt()), C_Currency_ID, (payment.isReceipt() ? Amounts[AMTTYPE_Gross]
+                : ""), (payment.isReceipt() ? "" : Amounts[AMTTYPE_Gross]), Fact_Acct_Group_ID,
+            "999999", DocumentType, conn);
+      }
       // Pre-payment is consumed when Used Credit Amount not equals Zero. When consuming Credit no
       // credit is generated
       if (new BigDecimal(usedAmount).compareTo(ZERO) != 0