details: https://code.openbravo.com/erp/devel/pi/rev/74df619a7316
changeset: 22357:74df619a7316
user: Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at>
openbravo.com>
date: Wed Mar 05 22:49:04 2014 +0530
summary: Fixes Issue 25785: Wrong grandtotal in invoices when you void it
diffstat:
src-db/database/model/functions/C_INVOICE_POST.xml
| 1 +
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateGrandTotal.class
| 0
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateGrandTotalData.class
| 0
src-util/modulescript/src/org/openbravo/modulescript/UpdateGrandTotal.java
| 44 +++
src-util/modulescript/src/org/openbravo/modulescript/UpdateGrandTotal_data.xsql
| 122 ++++++++++
5 files changed, 167 insertions(+), 0 deletions(-)
diffs (190 lines):
diff -r 4435c76bc9e6 -r 74df619a7316
src-db/database/model/functions/C_INVOICE_POST.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml Wed Mar 05
18:18:08 2014 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml Wed Mar 05
22:49:04 2014 +0530
@@ -513,6 +513,7 @@
UPDATE C_INVOICELINE
SET QtyInvoiced=0,
LineNetAmt=0,
+ line_gross_amount=0,
Updated=now(),
UpdatedBy=v_UpdatedBy
WHERE C_Invoice_ID=v_Record_ID;
diff -r 4435c76bc9e6 -r 74df619a7316
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateGrandTotal.class
Binary file
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateGrandTotal.class
has changed
diff -r 4435c76bc9e6 -r 74df619a7316
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateGrandTotalData.class
Binary file
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateGrandTotalData.class
has changed
diff -r 4435c76bc9e6 -r 74df619a7316
src-util/modulescript/src/org/openbravo/modulescript/UpdateGrandTotal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateGrandTotal.java
Wed Mar 05 22:49:04 2014 +0530
@@ -0,0 +1,44 @@
+/*
+ *************************************************************************
+ * 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) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.modulescript;
+
+import org.apache.log4j.Logger;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.utils.FormatUtilities;
+
+public class UpdateGrandTotal extends ModuleScript {
+
+ @Override
+ public void execute() {
+ try {
+ ConnectionProvider cp = getConnectionProvider();
+ boolean isUpdated= UpdateGrandTotalData.isExecuted(cp);
+ if (!isUpdated){
+ UpdateGrandTotalData.updateInvoiceLineTax(cp);
+ UpdateGrandTotalData.updateInvoiceTax(cp);
+ UpdateGrandTotalData.updateInvoiceLine(cp);
+ UpdateGrandTotalData.updateInvoice(cp);
+ UpdateGrandTotalData.createPreference(cp);
+ }
+ } catch (Exception e) {
+ handleError(e);
+ }
+ }
+}
diff -r 4435c76bc9e6 -r 74df619a7316
src-util/modulescript/src/org/openbravo/modulescript/UpdateGrandTotal_data.xsql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateGrandTotal_data.xsql
Wed Mar 05 22:49:04 2014 +0530
@@ -0,0 +1,122 @@
+<?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) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="UpdateGrandTotalData" package="org.openbravo.modulescript">
+ <SqlMethod name="select" type="preparedStatement" return="multiple">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql><![CDATA[
+ SELECT '' AS grossAmount
+ FROM DUAL
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updateInvoiceLineTax" type="preparedStatement"
return="rowCount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE c_invoicelinetax
+ SET taxamt=0
+ WHERE c_invoiceline_id IN (
+ SELECT c_invoiceline_id
+ FROM c_invoiceline il
+ WHERE il.line_gross_amount <> '0'
+ AND il.C_Invoice_ID IN (
+ SELECT C_Invoice_ID
+ FROM C_Invoice i
+ WHERE i.docstatus = 'VO'
+ AND i.totallines = '0'
+ AND i.c_doctype_id = '0'
+ AND i.grandtotal <> '0'
+ )
+ )
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updateInvoiceTax" type="preparedStatement"
return="rowCount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE c_invoicetax it
+ SET taxamt=0
+ WHERE it.C_Invoice_ID IN (
+ SELECT C_Invoice_ID
+ FROM C_Invoice i
+ WHERE i.docstatus = 'VO'
+ AND i.totallines = '0'
+ AND i.c_doctype_id = '0'
+ AND i.grandtotal <> '0'
+ )
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updateInvoiceLine" type="preparedStatement"
return="rowCount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE c_invoiceline il
+ SET line_gross_amount=0
+ WHERE il.line_gross_amount <> '0'
+ AND il.C_Invoice_ID IN (
+ SELECT C_Invoice_ID
+ FROM C_Invoice i
+ WHERE i.docstatus = 'VO'
+ AND i.totallines = '0'
+ AND i.c_doctype_id = '0'
+ AND i.grandtotal <> '0'
+ )
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updateInvoice" type="preparedStatement" return="rowCount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE c_invoice i
+ SET grandtotal=0
+ WHERE i.docstatus = 'VO'
+ AND i.totallines = '0'
+ AND i.c_doctype_id = '0'
+ AND i.grandtotal <> '0'
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="isExecuted" type="preparedStatement" return="boolean">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ SELECT count(*) as exist
+ FROM DUAL
+ WHERE EXISTS (SELECT 1 FROM ad_preference
+ WHERE attribute = 'GrossUpdated')
+ ]]>
+ </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(),'GrossUpdated')
+ ]]>
+ </Sql>
+ </SqlMethod>
+</SqlClass>
\ No newline at end of file
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits