Related to issue 23994
authorSandra Huguet <sandra.huguet@openbravo.com>
Wed, 30 Jul 2014 10:11:10 +0200
changeset 24142 c08c6475d0c5
parent 24141 6b960d4ca8bb
child 24143 d302a0eab5d3
Related to issue 23994
src-util/modulescript/build/classes/org/openbravo/modulescript/DeleteDuplicateMatchInvoice.class
src-util/modulescript/build/classes/org/openbravo/modulescript/DeleteDuplicateMatchInvoiceData.class
src-util/modulescript/src/org/openbravo/modulescript/DeleteDuplicateMatchInvoice.java
src-util/modulescript/src/org/openbravo/modulescript/DeleteDuplicateMatchInvoice_data.xsql
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/DeleteDuplicateMatchInvoice.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/DeleteDuplicateMatchInvoiceData.class has changed
--- a/src-util/modulescript/src/org/openbravo/modulescript/DeleteDuplicateMatchInvoice.java	Tue Jul 29 12:31:47 2014 +0200
+++ b/src-util/modulescript/src/org/openbravo/modulescript/DeleteDuplicateMatchInvoice.java	Wed Jul 30 10:11:10 2014 +0200
@@ -26,9 +26,13 @@
   public void execute() {
     try {
       ConnectionProvider cp = getConnectionProvider();
-      DeleteDuplicateMatchInvoiceData.deletePurchase(cp);
-      DeleteDuplicateMatchInvoiceData.deleteSalesFirstPart(cp);
-      DeleteDuplicateMatchInvoiceData.deleteSalesSecondPart(cp);
+      boolean isDuplicateMatchInvoiceExecuted= DeleteDuplicateMatchInvoiceData.isDuplicateMatchInvoiceExecuted(cp);
+      if (!isDuplicateMatchInvoiceExecuted){
+        DeleteDuplicateMatchInvoiceData.deletePurchase(cp);
+        DeleteDuplicateMatchInvoiceData.deleteSalesFirstPart(cp);
+        DeleteDuplicateMatchInvoiceData.deleteSalesSecondPart(cp);
+        DeleteDuplicateMatchInvoiceData.createPreference(cp);
+      }
     } catch (Exception e) {
       handleError(e);
     }
--- a/src-util/modulescript/src/org/openbravo/modulescript/DeleteDuplicateMatchInvoice_data.xsql	Tue Jul 29 12:31:47 2014 +0200
+++ b/src-util/modulescript/src/org/openbravo/modulescript/DeleteDuplicateMatchInvoice_data.xsql	Wed Jul 30 10:11:10 2014 +0200
@@ -67,4 +67,27 @@
       ]]>
     </Sql>
   </SqlMethod>
+  <SqlMethod name="isDuplicateMatchInvoiceExecuted" type="preparedStatement" return="boolean">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        SELECT count(*) as exist
+        FROM DUAL
+        WHERE EXISTS (SELECT 1 FROM ad_preference
+                      WHERE attribute = 'DuplicateMatchInvoiceExecuted')
+      ]]>
+    </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(),'DuplicateMatchInvoiceExecuted')
+         ]]>
+        </Sql>
+   </SqlMethod>
 </SqlClass>