details: https://code.openbravo.com/erp/devel/pi/rev/51d72e493b90
changeset: 22898:51d72e493b90
user: Atul Gaware <atul.gaware <at> openbravo.com>
date: Tue Apr 22 16:52:22 2014 +0530
summary: Fixes Issue 26121 Wrong Payment Schedule Detail amount when
reversing payment
diffstat:
modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail.class
| 0
modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetailData.class
| 0
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail.java
| 45 +
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail_data.xsql
| 87 +++
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetailData.java
| 280 ++++++++++
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
| 5 +-
6 files changed, 415 insertions(+), 2 deletions(-)
diffs (truncated from 451 to 300 lines):
diff -r 44096d49148a -r 51d72e493b90
modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail.class
Binary file
modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail.class
has changed
diff -r 44096d49148a -r 51d72e493b90
modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetailData.class
Binary file
modules/org.openbravo.advpaymentmngt/build/classes/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetailData.class
has changed
diff -r 44096d49148a -r 51d72e493b90
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail.java
Tue Apr 22 16:52:22 2014 +0530
@@ -0,0 +1,45 @@
+/*
+ *************************************************************************
+ * 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) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.advpaymentmngt.modulescript;
+
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.modulescript.ModuleScript;
+import java.math.BigDecimal;
+
+public class UpdatePaymentScheduledetail extends ModuleScript {
+ public void execute() {
+ try {
+ ConnectionProvider cp = getConnectionProvider();
+ boolean updateWrongPaymentScheduledetail =
UpdatePaymentScheduledetailData.updateWrongPaymentScheduledetail(cp);
+ if(!updateWrongPaymentScheduledetail) {
+ UpdatePaymentScheduledetailData[] data =
UpdatePaymentScheduledetailData.selectPSD(cp);
+ for (UpdatePaymentScheduledetailData upsd : data) {
+ if((new BigDecimal(upsd.outstandingamt)).compareTo(BigDecimal.ZERO) !=
0) {
+
UpdatePaymentScheduledetailData.updatePaymentScheduledetailAmount(cp,
upsd.outstandingamt, upsd.finPaymentScheduledetailId);
+ } else {
+ UpdatePaymentScheduledetailData.removePaymentScheduledetail(cp,
upsd.finPaymentScheduledetailId);
+ }
+ }
+ UpdatePaymentScheduledetailData.createPreference(cp);
+ }
+ } catch (Exception e) {
+ handleError(e);
+ }
+ }
+}
\ No newline at end of file
diff -r 44096d49148a -r 51d72e493b90
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail_data.xsql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetail_data.xsql
Tue Apr 22 16:52:22 2014 +0530
@@ -0,0 +1,87 @@
+<?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) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ *************************************************************************
+-->
+<SqlClass name="UpdatePaymentScheduledetailData"
package="org.openbravo.advpaymentmngt.modulescript">
+ <SqlClassComment></SqlClassComment>
+ <SqlMethod name="select" type="preparedStatement" return="multiple">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ SELECT '' as fin_payment_scheduledetail_id, '' as outstandingamt
+ FROM DUAL
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="selectPSD" type="preparedStatement" return="multiple">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ select psd.fin_payment_scheduledetail_id as
fin_payment_scheduledetail_id, ps.outstandingamt as outstandingamt from
fin_payment_scheduledetail
+ psd LEFT JOIN fin_payment_schedule ps ON ps.fin_payment_schedule_id =
COALESCE(psd.fin_payment_schedule_invoice,psd.fin_payment_schedule_order)
+ where psd.fin_payment_detail_id is null and psd.amount = 0 and
psd.writeoffamt = 0
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updatePaymentScheduledetailAmount" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE FIN_PAYMENT_SCHEDULEDETAIL SET AMOUNT=TO_NUMBER(?)
+ WHERE FIN_PAYMENT_SCHEDULEDETAIL_ID = ?
+ ]]>
+ </Sql>
+ <Parameter name="outStandingAmount"/>
+ <Parameter name="finPaymentScheduledetailId"/>
+ </SqlMethod>
+ <SqlMethod name="removePaymentScheduledetail" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql><![CDATA[
+ DELETE FROM FIN_PAYMENT_SCHEDULEDETAIL WHERE
FIN_PAYMENT_SCHEDULEDETAIL_ID = ?
+ ]]>
+ </Sql>
+ <Parameter name="finPaymentScheduledetailId"/>
+ </SqlMethod>
+ <SqlMethod name="updateWrongPaymentScheduledetail" type="preparedStatement"
return="boolean">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ SELECT count(*) as exist
+ FROM DUAL
+ WHERE EXISTS (SELECT 1 FROM ad_preference
+ WHERE attribute = 'updateWrongPaymentScheduledetail')
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="createPreference" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ INSERT INTO ad_preference (
+ ad_preference_id, ad_client_id, ad_org_id, isactive,
+ createdby, created, updatedby, updated,
+ attribute
+ ) VALUES (
+ get_uuid(), '0', '0', 'Y',
+ '0', NOW(), '0', NOW(),
+ 'updateWrongPaymentScheduledetail'
+ )
+ ]]>
+ </Sql>
+ </SqlMethod>
+ </SqlClass>
diff -r 44096d49148a -r 51d72e493b90
modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetailData.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/modules/org.openbravo.advpaymentmngt/src-util/modulescript/src/src/org/openbravo/advpaymentmngt/modulescript/UpdatePaymentScheduledetailData.java
Tue Apr 22 16:52:22 2014 +0530
@@ -0,0 +1,280 @@
+//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 UpdatePaymentScheduledetailData implements FieldProvider {
+static Logger log4j = Logger.getLogger(UpdatePaymentScheduledetailData.class);
+ private String InitRecordNumber="0";
+ public String finPaymentScheduledetailId;
+ public String outstandingamt;
+
+ public String getInitRecordNumber() {
+ return InitRecordNumber;
+ }
+
+ public String getField(String fieldName) {
+ if (fieldName.equalsIgnoreCase("fin_payment_scheduledetail_id") ||
fieldName.equals("finPaymentScheduledetailId"))
+ return finPaymentScheduledetailId;
+ else if (fieldName.equalsIgnoreCase("outstandingamt"))
+ return outstandingamt;
+ else {
+ log4j.debug("Field does not exist: " + fieldName);
+ return null;
+ }
+ }
+
+ public static UpdatePaymentScheduledetailData[] select(ConnectionProvider
connectionProvider) throws ServletException {
+ return select(connectionProvider, 0, 0);
+ }
+
+ public static UpdatePaymentScheduledetailData[] select(ConnectionProvider
connectionProvider, int firstRegister, int numberRegisters) throws
ServletException {
+ String strSql = "";
+ strSql = strSql +
+ " SELECT '' as fin_payment_scheduledetail_id, '' as
outstandingamt " +
+ " 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++;
+ UpdatePaymentScheduledetailData objectUpdatePaymentScheduledetailData
= new UpdatePaymentScheduledetailData();
+ objectUpdatePaymentScheduledetailData.finPaymentScheduledetailId =
UtilSql.getValue(result, "fin_payment_scheduledetail_id");
+ objectUpdatePaymentScheduledetailData.outstandingamt =
UtilSql.getValue(result, "outstandingamt");
+ objectUpdatePaymentScheduledetailData.InitRecordNumber =
Integer.toString(firstRegister);
+ vector.addElement(objectUpdatePaymentScheduledetailData);
+ 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();
+ }
+ }
+ UpdatePaymentScheduledetailData objectUpdatePaymentScheduledetailData[] =
new UpdatePaymentScheduledetailData[vector.size()];
+ vector.copyInto(objectUpdatePaymentScheduledetailData);
+ return(objectUpdatePaymentScheduledetailData);
+ }
+
+ public static UpdatePaymentScheduledetailData[] selectPSD(ConnectionProvider
connectionProvider) throws ServletException {
+ return selectPSD(connectionProvider, 0, 0);
+ }
+
+ public static UpdatePaymentScheduledetailData[] selectPSD(ConnectionProvider
connectionProvider, int firstRegister, int numberRegisters) throws
ServletException {
+ String strSql = "";
+ strSql = strSql +
+ " select psd.fin_payment_scheduledetail_id as
fin_payment_scheduledetail_id, ps.outstandingamt as outstandingamt from
fin_payment_scheduledetail " +
+ " psd LEFT JOIN fin_payment_schedule ps ON
ps.fin_payment_schedule_id =
COALESCE(psd.fin_payment_schedule_invoice,psd.fin_payment_schedule_order)" +
+ " where psd.fin_payment_detail_id is null and psd.amount = 0 and
psd.writeoffamt = 0";
+
+ 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++;
+ UpdatePaymentScheduledetailData objectUpdatePaymentScheduledetailData
= new UpdatePaymentScheduledetailData();
+ objectUpdatePaymentScheduledetailData.finPaymentScheduledetailId =
UtilSql.getValue(result, "fin_payment_scheduledetail_id");
+ objectUpdatePaymentScheduledetailData.outstandingamt =
UtilSql.getValue(result, "outstandingamt");
+ objectUpdatePaymentScheduledetailData.InitRecordNumber =
Integer.toString(firstRegister);
+ vector.addElement(objectUpdatePaymentScheduledetailData);
+ 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();
+ }
+ }
+ UpdatePaymentScheduledetailData objectUpdatePaymentScheduledetailData[] =
new UpdatePaymentScheduledetailData[vector.size()];
+ vector.copyInto(objectUpdatePaymentScheduledetailData);
+ return(objectUpdatePaymentScheduledetailData);
+ }
+
+ public static int updatePaymentScheduledetailAmount(ConnectionProvider
connectionProvider, String outStandingAmount, String
finPaymentScheduledetailId) throws ServletException {
+ String strSql = "";
+ strSql = strSql +
+ " UPDATE FIN_PAYMENT_SCHEDULEDETAIL SET AMOUNT=TO_NUMBER(?) " +
+ " WHERE FIN_PAYMENT_SCHEDULEDETAIL_ID = ?";
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits