details:   https://code.openbravo.com/erp/devel/pi/rev/2f2212e431cc
changeset: 20256:2f2212e431cc
user:      Javier Etxarri <javier.echarri <at> openbravo.com>
date:      Thu May 02 16:01:10 2013 +0200
summary:   Fixes issue 23164: It is possible to create a two price
 list versions with same name and same valid from date

diffstat:

 src-db/database/model/tables/M_PRICELIST_VERSION.xml                           
                           |    5 +
 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/DuplicatedPriceListVersion.class
     |    0 
 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/DuplicatedPriceListVersionData.class
 |    0 
 
src-util/buildvalidation/src/org/openbravo/buildvalidation/DuplicatedPriceListVersion.java
                |   52 ++++++++++
 
src-util/buildvalidation/src/org/openbravo/buildvalidation/DuplicatedPriceListVersion_data.xsql
           |   32 ++++++
 5 files changed, 89 insertions(+), 0 deletions(-)

diffs (111 lines):

diff -r d078b2330b3c -r 2f2212e431cc 
src-db/database/model/tables/M_PRICELIST_VERSION.xml
--- a/src-db/database/model/tables/M_PRICELIST_VERSION.xml      Tue Apr 30 
12:54:12 2013 +0200
+++ b/src-db/database/model/tables/M_PRICELIST_VERSION.xml      Thu May 02 
16:01:10 2013 +0200
@@ -80,6 +80,11 @@
       <foreign-key foreignTable="M_PRICELIST" 
name="M_PRICELIST_VERSION_M_PRICELIS" onDelete="cascade">
         <reference local="M_PRICELIST_ID" foreign="M_PRICELIST_ID"/>
       </foreign-key>
+      <unique name="M_PRICELIST_NAME_VALIDFROM">
+        <unique-column name="NAME"/>
+        <unique-column name="VALIDFROM"/>
+        <unique-column name="M_PRICELIST_ID"/>
+      </unique>
       <check name="M_PRICELIST_VERSION_ISACTI_CHK"><![CDATA[ISACTIVE IN ('Y', 
'N')]]></check>
       <check 
name="M_PRICELIST_VERSION_M_PRIC_CHK"><![CDATA[M_PRICELIST_VERSION_GENERATE IN 
('Y', 'N')]]></check>
     </table>
diff -r d078b2330b3c -r 2f2212e431cc 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/DuplicatedPriceListVersion.class
Binary file 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/DuplicatedPriceListVersion.class
 has changed
diff -r d078b2330b3c -r 2f2212e431cc 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/DuplicatedPriceListVersionData.class
Binary file 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/DuplicatedPriceListVersionData.class
 has changed
diff -r d078b2330b3c -r 2f2212e431cc 
src-util/buildvalidation/src/org/openbravo/buildvalidation/DuplicatedPriceListVersion.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/src-util/buildvalidation/src/org/openbravo/buildvalidation/DuplicatedPriceListVersion.java
        Thu May 02 16:01:10 2013 +0200
@@ -0,0 +1,52 @@
+/*
+ *************************************************************************
+ * 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) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.buildvalidation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openbravo.database.ConnectionProvider;
+
+/**
+ * This validation is related to this issue: 23164: It is possible to create a 
+ * two price list versions with same name and same valid from date
+ */
+public class DuplicatedPriceListVersion extends BuildValidation {
+
+  @Override
+  public List<String> execute() {
+    ConnectionProvider cp = getConnectionProvider();
+    ArrayList<String> errors = new ArrayList<String>();
+    try {
+      if (DuplicatedPriceListVersionData.existsDuplicatedPriceListVersion(cp)) 
{
+        errors
+            .add("Due to a database constraint modification, is no longer 
allowed " +
+                       "to create two price list versions with same name and 
same valid from date" +
+                       " to one price list. " +
+                       "There exists data in your database that do not fit 
this new constraint. " +
+                       "Please fix it in M_PRICELIST_VERSION table as 
M_PRICELIST_ID, NAME AND " +
+                       "VALIDFROM columns have not got duplicated values");
+      }
+    } catch (Exception e) {
+      return handleError(e);
+    }
+    return errors;
+  }
+
+}
diff -r d078b2330b3c -r 2f2212e431cc 
src-util/buildvalidation/src/org/openbravo/buildvalidation/DuplicatedPriceListVersion_data.xsql
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/src-util/buildvalidation/src/org/openbravo/buildvalidation/DuplicatedPriceListVersion_data.xsql
   Thu May 02 16:01:10 2013 +0200
@@ -0,0 +1,32 @@
+<?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="DuplicatedPriceListVersionData" 
package="org.openbravo.buildvalidation">
+  <SqlMethod name="existsDuplicatedPriceListVersion" type="preparedStatement" 
return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+         SELECT count(*) AS EXISTING
+         FROM m_pricelist_version
+         GROUP BY m_pricelist_id, name, validfrom
+         HAVING count(*)>1
+      ]]>
+    </Sql>
+  </SqlMethod>
+</SqlClass>

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to