Fixes bug 8497 System wrongly generate Invoice for Volume discount even for inactive customers & Inactive Products
authorJayakumar Kasinathan <jayakumar.kasinathan@openbravo.com>
Sun, 03 May 2009 22:10:02 -0400
changeset 3793 cc54bc4c5bde
parent 3792 7c72d1b8a657
child 3794 0ace4de08524
Fixes bug 8497 System wrongly generate Invoice for Volume discount even for inactive customers & Inactive Products
src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml
--- a/src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml	Fri May 01 22:56:00 2009 +0200
+++ b/src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml	Sun May 03 22:10:02 2009 -0400
@@ -166,10 +166,10 @@
       )))
       AND((COALESCE(R.INCLUDE_PRODUCT, 'Y')='N' -- Just selected
       AND EXISTS
-      (SELECT 1 FROM M_RAPPEL_PRODUCT RP WHERE RP.M_PRODUCT_ID=IL.M_PRODUCT_ID))
+      (SELECT 1 FROM M_RAPPEL_PRODUCT RP WHERE RP.M_PRODUCT_ID=IL.M_PRODUCT_ID AND RP.ISACTIVE='Y'))
       OR (COALESCE(R.INCLUDE_PRODUCT, 'Y')='Y' -- Everyone except selected
       AND NOT EXISTS
-      (SELECT 1 FROM M_RAPPEL_PRODUCT RP  WHERE RP.M_PRODUCT_ID=IL.M_PRODUCT_ID)))
+      (SELECT 1 FROM M_RAPPEL_PRODUCT RP  WHERE RP.M_PRODUCT_ID=IL.M_PRODUCT_ID AND RP.ISACTIVE='Y')))
       AND RP.ISSOTRX=I.ISSOTRX
       AND RP.M_RAPPEL_BPARTNER_ID=v_Record_ID;
   EXCEPTION
@@ -188,6 +188,7 @@
     FROM M_RAPPEL R,
       M_RAPPEL_BPARTNER RP
     WHERE RP.M_RAPPEL_BPARTNER_ID=v_Record_ID
+    AND RP.ISACTIVE='Y'
       AND RP.M_RAPPEL_ID=R.M_RAPPEL_ID;
     IF v_Scaled='N' THEN
       SELECT MAX(DISCOUNT)
@@ -285,12 +286,14 @@
           M_RAPPEL R1
         WHERE R.M_RAPPEL_ID=RP.M_RAPPEL_ID
           AND  R1.M_RAPPEL_ID=RP.M_RAPPEL_ID
+          AND RP.ISACTIVE='Y'
           AND COALESCE(R1.INCLUDE_PRODUCT, 'Y')='N' MINUS
         SELECT M_PRODUCT_ID
         FROM M_RAPPEL_PRODUCT RP,
           M_RAPPEL R1
         WHERE R.M_RAPPEL_ID=RP.M_RAPPEL_ID
           AND  R1.M_RAPPEL_ID=RP.M_RAPPEL_ID
+          AND RP.ISACTIVE='Y'
           AND COALESCE(R1.INCLUDE_PRODUCT, 'Y')='Y'
         )
         AND I.C_BPARTNER_ID=PL.C_BPARTNER_ID