Fixed bug 19718 Catched exception when delete a line in complete sales invoice
authorSandra Huguet <sandra.huguet@openbravo.com>
Mon, 21 May 2012 10:44:36 +0200
changeset 17948 ed8fe55b2a08
parent 17947 6571cad79c4a
child 17949 5fab9bcac0ac
Fixed bug 19718 Catched exception when delete a line in complete sales invoice
src-db/database/model/triggers/C_INVOICELINETAX_TRG.xml
--- a/src-db/database/model/triggers/C_INVOICELINETAX_TRG.xml	Thu Sep 13 17:48:17 2012 +0200
+++ b/src-db/database/model/triggers/C_INVOICELINETAX_TRG.xml	Mon May 21 10:44:36 2012 +0200
@@ -31,6 +31,7 @@
 v_Prec C_CURRENCY.STDPRECISION%TYPE;
 v_DocTaxAmount C_TAX.DOCTAXAMOUNT%TYPE;
 v_Rate  C_TAX.RATE%TYPE;
+v_Processed   VARCHAR(60);
 v_Increment_Amount C_ORDERTAX.TAXAMT%TYPE ;
 v_Increment_Base C_ORDERTAX.TAXBASEAMT%TYPE ;
     
@@ -47,8 +48,8 @@
       v_C_Invoice_ID:=:OLD.C_INVOICE_ID;
     END IF;
 
-    SELECT C_CURRENCY.STDPRECISION
-    INTO v_Prec
+    SELECT C_CURRENCY.STDPRECISION, PROCESSED
+    INTO v_Prec, v_Processed
     FROM C_INVOICE, C_CURRENCY
     WHERE C_INVOICE.C_CURRENCY_ID = C_CURRENCY.C_CURRENCY_ID
     AND C_INVOICE_ID = v_C_Invoice_ID;
@@ -94,7 +95,9 @@
       :NEW.UPDATEDBY, :NEW.TAXBASEAMT, :NEW.TAXAMT, v_LineNo, 'Y');
     END IF;
   ELSE
-    
+  IF (v_Processed='Y') THEN 
+    RAISE_APPLICATION_ERROR(-20000, '@20501@') ;
+  ELSE
     UPDATE C_INVOICETAX SET TAXAMT = (CASE WHEN v_DocTaxAmount='D' THEN ROUND((TAXBASEAMT - :OLD.TAXBASEAMT) * v_Rate/100, v_Prec) ELSE (TAXAMT - :OLD.TAXAMT) END), TAXBASEAMT=TAXBASEAMT - :OLD.TAXBASEAMT
     WHERE C_INVOICE_ID = :OLD.C_Invoice_ID
     AND C_TAX_ID = :OLD.C_TAX_ID
@@ -104,6 +107,7 @@
     WHERE C_INVOICE_ID = :OLD.C_Invoice_ID
     AND C_TAX_ID = :OLD.C_TAX_ID
     AND TAXAMT=0 AND TAXBASEAMT=0;
+    END IF;
   END IF;
 END C_INVOICELINETAX_TRG
 ]]></body>