fixed bug 18084
authorSalvador Zapata <salvador.zapata@openbravo.com>
Wed, 27 Jul 2011 15:34:23 +0200
changeset 13330 fb50d884949b
parent 13329 0ab8d290c95a
child 13331 6b145146b223
fixed bug 18084
src-db/database/model/triggers/C_CONVERSION_RATE_DOCUMENT_TRG.xml
src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/model/triggers/C_CONVERSION_RATE_DOCUMENT_TRG.xml	Wed Jul 13 16:49:45 2011 +0200
+++ b/src-db/database/model/triggers/C_CONVERSION_RATE_DOCUMENT_TRG.xml	Wed Jul 27 15:34:23 2011 +0200
@@ -27,6 +27,7 @@
     * Title: Check in deleting, invoice not processed
     ************************************************************************/
    v_Posted VARCHAR2(32) ;
+   v_HasReversal CHAR(1);
         
 BEGIN
     
@@ -86,6 +87,12 @@
 		SELECT POSTED INTO v_Posted 
 		FROM C_INVOICE
 		WHERE C_INVOICE_ID = :OLD.C_INVOICE_ID;
+
+		-- Looking if the invoice has reversal invoices
+		SELECT 'Y' as hasreversal
+		INTO v_HasReversal
+		FROM DUAL 
+		WHERE EXISTS (SELECT 1 FROM C_INVOICE_REVERSE WHERE C_INVOICE_ID = :OLD.C_INVOICE_ID);
 	END IF;
 
 	IF :OLD.FIN_PAYMENT_ID IS NOT NULL THEN
@@ -103,6 +110,12 @@
 	IF(v_Posted='Y')
 		THEN  RAISE_APPLICATION_ERROR(-20501, 'Document processed/posted');
 	END IF;
+	IF (v_HasReversal='Y') THEN
+		  RAISE_APPLICATION_ERROR(-20000, '@InvoiceHasReversal@');
+	END IF;
+
+	
+	
     END IF;
     
     
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jul 13 16:49:45 2011 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jul 27 15:34:23 2011 +0200
@@ -19720,4 +19720,15 @@
 <!--FF8081812F9C927B012F9CA0BF39000D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--FF8081812F9C927B012F9CA0BF39000D--></AD_MESSAGE>
 
+<!--FF808181316B7B2301316BB848590057--><AD_MESSAGE>
+<!--FF808181316B7B2301316BB848590057-->  <AD_MESSAGE_ID><![CDATA[FF808181316B7B2301316BB848590057]]></AD_MESSAGE_ID>
+<!--FF808181316B7B2301316BB848590057-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF808181316B7B2301316BB848590057-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF808181316B7B2301316BB848590057-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF808181316B7B2301316BB848590057-->  <VALUE><![CDATA[InvoiceHasReversal]]></VALUE>
+<!--FF808181316B7B2301316BB848590057-->  <MSGTEXT><![CDATA[The invoice has a reversed invoice linked. Please unlink the invoices before deleting exchange rates.]]></MSGTEXT>
+<!--FF808181316B7B2301316BB848590057-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--FF808181316B7B2301316BB848590057-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--FF808181316B7B2301316BB848590057--></AD_MESSAGE>
+
 </data>