details: https://code.openbravo.com/erp/devel/pi/rev/4d6b7da16e31
changeset: 21238:4d6b7da16e31
user: Carlos Aristu <carlos.aristu <at> openbravo.com>
date: Mon Oct 07 08:50:00 2013 +0200
summary: fixes issue 24856: Module script is needed for non
updated m_reservation quantities
diffstat:
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReservationQtys.class
| 0
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReservationQtysData.class
| 0
src-util/modulescript/src/org/openbravo/modulescript/UpdateReservationQtys.java
| 43 ++++
src-util/modulescript/src/org/openbravo/modulescript/UpdateReservationQtys_data.xsql
| 98 ++++++++++
4 files changed, 141 insertions(+), 0 deletions(-)
diffs (155 lines):
diff -r 4d91babc9e09 -r 4d6b7da16e31
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReservationQtys.class
Binary file
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReservationQtys.class
has changed
diff -r 4d91babc9e09 -r 4d6b7da16e31
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReservationQtysData.class
Binary file
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateReservationQtysData.class
has changed
diff -r 4d91babc9e09 -r 4d6b7da16e31
src-util/modulescript/src/org/openbravo/modulescript/UpdateReservationQtys.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateReservationQtys.java
Mon Oct 07 08:50:00 2013 +0200
@@ -0,0 +1,43 @@
+/*
+ *************************************************************************
+ * 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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.modulescript;
+
+import java.sql.PreparedStatement;
+
+import org.openbravo.modulescript.ModuleScript;
+import org.openbravo.database.ConnectionProvider;
+
+public class UpdateReservationQtys extends ModuleScript{
+ @Override
+ public void execute() {
+ try {
+ ConnectionProvider cp = getConnectionProvider();
+ // If the preference does not exist in the database yet the modulescript
must be executed.
+ boolean areQtysUpdated = UpdateReservationQtysData.existsPreference(cp);
+ if (!areQtysUpdated){
+ UpdateReservationQtysData.deleteNotReleased(cp);
+ UpdateReservationQtysData.updateReleased(cp);
+ UpdateReservationQtysData.updateReservationQtys(cp);
+ UpdateReservationQtysData.createPreference(cp);
+ }
+ } catch(Exception e){
+ handleError(e);
+ }
+ }
+}
\ No newline at end of file
diff -r 4d91babc9e09 -r 4d6b7da16e31
src-util/modulescript/src/org/openbravo/modulescript/UpdateReservationQtys_data.xsql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateReservationQtys_data.xsql
Mon Oct 07 08:50:00 2013 +0200
@@ -0,0 +1,98 @@
+<?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) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+-->
+<SqlClass name="UpdateReservationQtysData"
package="org.openbravo.modulescript">
+ <SqlClassComment></SqlClassComment>
+ <SqlMethod name="existsPreference" type="preparedStatement"
return="boolean">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ SELECT count(*) as exist
+ FROM DUAL
+ WHERE EXISTS (SELECT 1 FROM ad_preference
+ WHERE attribute = 'Reservation_Qtys_Updated')
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="deleteNotReleased" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ DELETE FROM m_reservation_stock
+ WHERE m_reservation_id IN
+ (SELECT m.m_reservation_id FROM m_reservation m, c_orderline ol,
c_order o
+ WHERE m.c_orderline_id = ol.c_orderline_id
+ AND ol.c_order_id = o.c_order_id
+ AND ol.qtyordered = 0
+ AND o.docstatus = 'CL'
+ AND (m.quantity != 0 OR m.reservedqty != 0 OR
m.releasedqty != 0))
+ AND COALESCE(releasedqty, 0) = 0
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updateReleased" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE m_reservation_stock
+ SET quantity = releasedqty
+ WHERE m_reservation_id IN
+ (SELECT m.m_reservation_id FROM m_reservation m, c_orderline ol,
c_order o
+ WHERE m.c_orderline_id = ol.c_orderline_id
+ AND ol.c_order_id = o.c_order_id
+ AND ol.qtyordered = 0
+ AND o.docstatus = 'CL'
+ AND (m.quantity != 0 OR m.reservedqty != 0 OR
m.releasedqty != 0))
+ AND COALESCE(releasedqty, 0) != 0
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="updateReservationQtys" type="preparedStatement"
return="rowcount">
+ <SqlMethodComment></SqlMethodComment>
+ <Sql>
+ <![CDATA[
+ UPDATE m_reservation
+ SET quantity = 0
+ WHERE m_reservation_id IN
+ (SELECT m.m_reservation_id FROM m_reservation m, c_orderline ol,
c_order o
+ WHERE m.c_orderline_id = ol.c_orderline_id
+ AND ol.c_order_id = o.c_order_id
+ AND ol.qtyordered = 0
+ AND o.docstatus = 'CL'
+ AND (m.quantity != 0 OR m.reservedqty != 0 OR
m.releasedqty != 0))
+ ]]>
+ </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(),
+ 'Reservation_Qtys_Updated'
+ )
+ ]]>
+ </Sql>
+ </SqlMethod>
+</SqlClass>
\ No newline at end of file
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits