Fixes bug 22466
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Wed, 05 Dec 2012 18:15:54 +0100
changeset 18979 ac04563218d6
parent 18978 931f2eb6df55
child 18980 9d5b68fafd0b
Fixes bug 22466
.project
src-util/modulescript/build/classes/org/openbravo/modulescript/UniqueValidCombination.class
src-util/modulescript/build/classes/org/openbravo/modulescript/UniqueValidCombinationData.class
src-util/modulescript/src/org/openbravo/modulescript/UniqueValidCombination.java
src-util/modulescript/src/org/openbravo/modulescript/UniqueValidCombination_data.xsql
--- a/.project	Wed Dec 05 17:07:37 2012 +0100
+++ b/.project	Wed Dec 05 18:15:54 2012 +0100
@@ -15,6 +15,11 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
+		<buildCommand>
+			<name>com.eclipsesource.jshint.ui.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	<natures>
 		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/UniqueValidCombination.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/UniqueValidCombinationData.class has changed
--- a/src-util/modulescript/src/org/openbravo/modulescript/UniqueValidCombination.java	Wed Dec 05 17:07:37 2012 +0100
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UniqueValidCombination.java	Wed Dec 05 18:15:54 2012 +0100
@@ -29,10 +29,12 @@
   public void execute() {
     try {
       ConnectionProvider cp = getConnectionProvider();
-      if(UniqueValidCombinationData.selectDuplicates(cp)){
+      if(UniqueValidCombinationData.selectMissingValidCombination(cp)){
         UniqueValidCombinationData.updateJournalLineDimensions(cp);
         UniqueValidCombinationData.updateValidCombinationDeactivate(cp);
-        UniqueValidCombinationData.updateValidCombinationDeactivateDuplicated(cp);
+        if(UniqueValidCombinationData.selectDuplicates(cp)){
+          UniqueValidCombinationData.updateValidCombinationDeactivateDuplicated(cp);
+        }
         UniqueValidCombinationData.insertValidCombinations(cp);
       }
       
--- a/src-util/modulescript/src/org/openbravo/modulescript/UniqueValidCombination_data.xsql	Wed Dec 05 17:07:37 2012 +0100
+++ b/src-util/modulescript/src/org/openbravo/modulescript/UniqueValidCombination_data.xsql	Wed Dec 05 18:15:54 2012 +0100
@@ -40,11 +40,36 @@
         and C_ACTIVITY_ID is null
         and USER1_ID is null
         and USER2_ID is null
+        and isactive = 'Y'
         group by account_id, ad_client_id
         having count(account_id) > 1) a
       ]]>
     </Sql>
   </SqlMethod>
+  <SqlMethod name="selectMissingValidCombination" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql><![CDATA[
+        select count(1) as count
+        from dual 
+        where exists (select 1 
+                    from c_elementvalue 
+                    where not exists(select 1 
+                                    from c_validcombination 
+                                    where c_validcombination.account_id = c_elementvalue_id 
+                                    and isactive='Y' 
+                                    and M_PRODUCT_ID is null
+                                    and C_BPARTNER_ID is null
+                                    and C_PROJECT_ID is null
+                                    and C_CAMPAIGN_ID is null
+                                    and C_SALESREGION_ID is null
+                                    and C_ACTIVITY_ID is null
+                                    and USER1_ID is null
+                                    and USER2_ID is null)
+                     and elementlevel = 'S'
+                     and isactive = 'Y')
+      ]]>
+    </Sql>
+  </SqlMethod>
   <SqlMethod name="updateJournalLineDimensions" type="preparedStatement" return="rowcount">
     <SqlMethodComment></SqlMethodComment>
     <Sql><![CDATA[