Fixes bug 22818
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Thu, 17 Jan 2013 12:44:05 +0100
changeset 19389 2ea55d9cc882
parent 19388 c8f2f781b915
child 19390 3874ea4d0665
Fixes bug 22818
src-db/database/model/functions/C_INVOICE_POST.xml
src-db/database/model/functions/C_ORDER_POST1.xml
src-db/database/model/functions/M_INOUT_POST.xml
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Mon Jan 21 10:31:14 2013 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Jan 17 12:44:05 2013 +0100
@@ -470,9 +470,9 @@
         INTO v_Count
       FROM C_INVOICE I, C_INVOICELINE IL
       WHERE I.C_INVOICE_ID = IL.C_INVOICE_ID
-        AND AD_ISORGINCLUDED(IL.AD_Org_ID, I.AD_Org_ID, I.AD_Client_ID) <> -1
+        AND AD_ISORGINCLUDED(IL.AD_Org_ID, I.AD_Org_ID, I.AD_Client_ID) = -1
         AND I.C_INVOICE_ID = v_Record_ID;
-      IF (v_Count=0) THEN
+      IF (v_Count>0) THEN
         RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
       END IF;
 
--- a/src-db/database/model/functions/C_ORDER_POST1.xml	Mon Jan 21 10:31:14 2013 +0100
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml	Thu Jan 17 12:44:05 2013 +0100
@@ -485,9 +485,9 @@
         INTO v_Count
       FROM C_ORDER C, C_ORDERLINE OL
       WHERE C.C_ORDER_ID = OL.C_ORDER_ID
-        AND AD_ISORGINCLUDED(OL.AD_Org_ID, C.AD_Org_ID, C.AD_Client_ID) <> -1
+        AND AD_ISORGINCLUDED(OL.AD_Org_ID, C.AD_Org_ID, C.AD_Client_ID) = -1
         AND C.C_ORDER_ID = v_Record_ID;
-      IF (v_Count=0) THEN
+      IF (v_Count>0) THEN
         RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
       END IF;
       
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Mon Jan 21 10:31:14 2013 +0100
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Thu Jan 17 12:44:05 2013 +0100
@@ -236,9 +236,9 @@
         INTO v_Count
         FROM M_INOUT IO, M_INOUTLINE IOL
         WHERE IO.M_INOUT_ID = IOL.M_INOUT_ID
-        AND AD_ISORGINCLUDED(IOL.AD_Org_ID, IO.AD_Org_ID, IO.AD_Client_ID) <> -1
+        AND AD_ISORGINCLUDED(IOL.AD_Org_ID, IO.AD_Org_ID, IO.AD_Client_ID) = -1
         AND IO.M_INOUT_ID = v_Record_ID;
-        IF (v_Count=0) THEN
+        IF (v_Count>0) THEN
           RAISE_APPLICATION_ERROR(-20000, '@NotCorrectOrgLines@') ;
         END IF;
       END IF;
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Mon Jan 21 10:31:14 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Thu Jan 17 12:44:05 2013 +0100
@@ -912,7 +912,7 @@
       sb.append("-").append(m_taxes[i].getAmount());
     }
     // - Lines
-    for (int i = 0; i < p_lines.length; i++) {
+    for (int i = 0; p_lines != null && i < p_lines.length; i++) {
       retValue = retValue.subtract(new BigDecimal(p_lines[i].getAmount()));
       sb.append("-").append(p_lines[i].getAmount());
     }