Related to issue 29201: reveting the commit. This change should be included in q3 (not in q2)
authorNaiara Martinez <naiara.martinez@openbravo.com>
Fri, 13 Mar 2015 14:32:45 +0100
changeset 26179 1ab24bb1a8cb
parent 26177 a102d4101225
child 26180 ee85914ad233
Related to issue 29201: reveting the commit. This change should be included in q3 (not in q2)
src-db/database/model/functions/C_INVOICE_CREATE.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_PROCESS_PARA.xml
src-db/database/sourcedata/AD_VAL_RULE.xml
--- a/src-db/database/model/functions/C_INVOICE_CREATE.xml	Fri Mar 13 11:57:34 2015 +0100
+++ b/src-db/database/model/functions/C_INVOICE_CREATE.xml	Fri Mar 13 14:32:45 2015 +0100
@@ -48,7 +48,6 @@
     v_AD_Org_ID VARCHAR2(32):=NULL;
     v_C_Order_ID VARCHAR2(32):=NULL;
     v_BPartner_ID VARCHAR2(32):=NULL;
-    v_IncludeChildOrgs VARCHAR2(1):='N';
     v_Selection VARCHAR2(1):='N';
     v_DateInvoiced_aux DATE:=NULL;
     v_DateOrdered DATE:=NULL;
@@ -209,9 +208,6 @@
             ELSIF(Cur_Parameter.ParameterName='C_BPartner_ID') THEN
               v_BPartner_ID:=Cur_Parameter.P_String;
               DBMS_OUTPUT.PUT_LINE('  C_BPartner_ID=' || v_BPartner_ID) ;
-            ELSIF(Cur_Parameter.ParameterName='IncludeChildOrgs') THEN
-              v_IncludeChildOrgs:=Cur_Parameter.P_String;
-              DBMS_OUTPUT.PUT_LINE('  IncludeChildOrgs=' || v_IncludeChildOrgs) ;
             ELSIF(Cur_Parameter.ParameterName='Selection') THEN
               v_Selection:=Cur_Parameter.P_String;
               DBMS_OUTPUT.PUT_LINE('  Selection=' || v_Selection) ;
@@ -818,7 +814,6 @@
             Cur_InvoiceSchedule RECORD;
             v_Partner_ID VARCHAR2(32):='-1';
             v_InOut_ID VARCHAR2(32):='-1';
-            v_invOrg_ID VARCHAR2(32) ;
             v_gOrg_ID VARCHAR2(32) ;
             v_gOrder_ID VARCHAR2(32) ;
             v_gInOut_ID VARCHAR2(32) ;
@@ -869,7 +864,6 @@
                 o.C_Project_ID,
                 ol.C_Project_ID as line_C_Project_ID,
                 o.C_Activity_ID,
-                o.ad_org_id as order_org_id,
                 o.AD_OrgTrx_ID,
                 o.User1_ID,
                 ol.User1_ID as line_User1_ID,
@@ -948,8 +942,7 @@
                 AND(v_BPartner_ID IS NULL
                 OR sh.C_BPartner_ID=v_BPartner_ID) -- for all Organizations or a specific
                 AND(v_AD_Org_ID IS NULL
-                OR (v_IncludeChildOrgs = 'N' AND v_AD_Org_ID = sh.AD_Org_ID)
-                OR (v_IncludeChildOrgs = 'Y' AND AD_ISORGINCLUDED(sh.AD_Org_ID, v_AD_Org_ID, sh.ad_client_id) <> -1)) -- completed shipments
+                OR sh.AD_Org_ID=v_AD_Org_ID) -- completed shipments
                 AND o.DocStatus IN('CO', 'CL')
                 AND o.IsSOTrx='Y'  -- completed orders
                 AND sh.DocStatus IN('CO', 'CL') -- we need to invoice - and not invoiced
@@ -1085,11 +1078,6 @@
               14.-User dimension 1 (User1_ID)
               15.-User dimension 2 (User2_ID)
               */
-              IF (SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 1, 1)='0' AND v_AD_Org_ID IS NOT NULL) THEN
-                v_invOrg_ID := v_AD_Org_ID;
-              ELSE 
-                v_invOrg_ID := Cur_InvoiceSchedule.AD_Org_ID;
-              END IF;
               IF((v_Partner_ID<>Cur_InvoiceSchedule.C_BPartner_ID) OR (v_istaxincluded <> cur_invoiceschedule.istaxincluded) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 1, 1)='1' AND v_gOrg_ID<>Cur_InvoiceSchedule.AD_Org_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 2, 1)='1' AND v_gOrder_ID<>Cur_InvoiceSchedule.C_Order_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 3, 1)='1' AND v_gInOut_ID<>Cur_InvoiceSchedule.M_InOut_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 4, 1)='1' AND v_gBillTo_ID<>Cur_InvoiceSchedule.BillTo_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 5, 1)='1' AND v_gBPartner_Location_ID<>Cur_InvoiceSchedule.C_BPartner_Location_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 6, 1)='1' AND v_gSalesRep_ID<>Cur_InvoiceSchedule.SalesRep_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 7, 1)='1' AND v_gPaymentRule<>Cur_InvoiceSchedule.PaymentRule) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 8, 1)='1' AND v_gPaymentTerm_ID<>Cur_InvoiceSchedule.C_PaymentTerm_ID) OR(SUBSTR(
                 Cur_InvoiceSchedule.InvoiceGrouping, 9, 1)='1' AND v_gCurrency_ID<>Cur_InvoiceSchedule.C_Currency_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 10, 1)='1' AND v_gCampaign_ID<>Cur_InvoiceSchedule.C_Campaign_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 11, 1)='1' AND ((v_gProject_ID<>Cur_InvoiceSchedule.C_Project_ID) OR (v_gProject_ID IS NULL AND Cur_InvoiceSchedule.C_Project_ID IS NOT NULL) OR (v_gProject_ID IS NOT NULL AND Cur_InvoiceSchedule.C_Project_ID IS NULL))) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 12, 1)='1' AND v_gActivitiy_ID<>Cur_InvoiceSchedule.C_Activity_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 13, 1)='1' AND v_gOrgTrx_ID<>Cur_InvoiceSchedule.AD_OrgTrx_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 14, 1)='1' AND v_gUser1_ID<>Cur_InvoiceSchedule.User1_ID) OR(SUBSTR(Cur_InvoiceSchedule.InvoiceGrouping, 15, 1)='1' AND v_gUser2_ID<>Cur_InvoiceSchedule.User2_ID)) THEN
                 v_Partner_ID:=Cur_InvoiceSchedule.C_BPartner_ID;
@@ -1132,9 +1120,9 @@
                 END IF;
                 -- Get Document Type for Invoice
                 v_ResultStr:='GetDocumentType';
-                IF(Cur_InvoiceSchedule.C_Order_ID IS NULL OR cur_invoiceschedule.order_org_id != v_invorg_id) THEN
+                IF(Cur_InvoiceSchedule.C_Order_ID IS NULL) THEN
                   BEGIN
-                    v_DocType_ID:=Ad_Get_Doctype(Cur_InvoiceSchedule.AD_Client_ID, v_invorg_id, 'ARI') ;
+                    v_DocType_ID:=Ad_Get_Doctype(Cur_InvoiceSchedule.AD_Client_ID, Cur_InvoiceSchedule.AD_Org_ID, 'ARI') ;                    --
                   EXCEPTION
                   WHEN OTHERS THEN
                     RAISE_APPLICATION_ERROR(-20000, '@NoDefaultInvoice@') ;
@@ -1191,7 +1179,7 @@
                     )
                     VALUES
                     (
-                      p_Invoice_ID, Cur_InvoiceSchedule.C_Order_ID, Cur_InvoiceSchedule.AD_Client_ID, v_invOrg_ID,
+                      p_Invoice_ID, Cur_InvoiceSchedule.C_Order_ID, Cur_InvoiceSchedule.AD_Client_ID, Cur_InvoiceSchedule.AD_Org_ID,
                        'Y', now(), v_ADUserId, now(),
                       v_ADUserId, 'Y', v_DocumentNo, 'DR',
                        'CO', 'N', 'N', v_DocType_ID,
@@ -1217,7 +1205,7 @@
                       v_Message:=SUBSTR(v_Message||', '|| v_DocumentNo, 0, 2000);
                   END IF;
                 END IF;
-              ELSIF (v_isfinaldoctype = 'N' AND cur_invoiceschedule.order_org_id = v_invorg_id) THEN --If docType is not a final one update it
+              ELSIF (v_isfinaldoctype = 'N') THEN --If docType is not a final one update it
                 BEGIN
                   v_DocType_ID:=NULL;
                   SELECT od.C_DocTypeInvoice_ID, CASE od.isreturn WHEN 'Y' THEN 'N' ELSE 'Y' END
@@ -1293,7 +1281,7 @@
                   )
                   VALUES
                   (
-                    v_NextNo, Cur_InvoiceSchedule.AD_Client_ID, v_invOrg_ID, 'Y',
+                    v_NextNo, Cur_InvoiceSchedule.AD_Client_ID, Cur_InvoiceSchedule.Line_AD_Org_ID, 'Y',
                     now(), v_ADUserId, now(), v_ADUserId,
                     p_Invoice_ID, Cur_InvoiceSchedule.C_OrderLine_ID, Cur_InvoiceSchedule.M_InOutLine_ID, v_LineNo,
                     Cur_InvoiceSchedule.Line_Description, Cur_InvoiceSchedule.M_Product_ID, Cur_InvoiceSchedule.MovementQty, Cur_InvoiceSchedule.PriceList,
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Mar 13 11:57:34 2015 +0100
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Fri Mar 13 14:32:45 2015 +0100
@@ -21054,18 +21054,6 @@
 <!--042A6ABD945A48A587CF3C14FEAE9CCC-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--042A6ABD945A48A587CF3C14FEAE9CCC--></AD_ELEMENT>
 
-<!--046DBDB9E87B0A01E050007F01000340--><AD_ELEMENT>
-<!--046DBDB9E87B0A01E050007F01000340-->  <AD_ELEMENT_ID><![CDATA[046DBDB9E87B0A01E050007F01000340]]></AD_ELEMENT_ID>
-<!--046DBDB9E87B0A01E050007F01000340-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--046DBDB9E87B0A01E050007F01000340-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--046DBDB9E87B0A01E050007F01000340-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--046DBDB9E87B0A01E050007F01000340-->  <COLUMNNAME><![CDATA[IncludeChildOrgs]]></COLUMNNAME>
-<!--046DBDB9E87B0A01E050007F01000340-->  <NAME><![CDATA[Include Child Organizations]]></NAME>
-<!--046DBDB9E87B0A01E050007F01000340-->  <PRINTNAME><![CDATA[Include Child Organizations]]></PRINTNAME>
-<!--046DBDB9E87B0A01E050007F01000340-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--046DBDB9E87B0A01E050007F01000340-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
-<!--046DBDB9E87B0A01E050007F01000340--></AD_ELEMENT>
-
 <!--05C19A393B104A858FCB3E1C3B731617--><AD_ELEMENT>
 <!--05C19A393B104A858FCB3E1C3B731617-->  <AD_ELEMENT_ID><![CDATA[05C19A393B104A858FCB3E1C3B731617]]></AD_ELEMENT_ID>
 <!--05C19A393B104A858FCB3E1C3B731617-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Mar 13 11:57:34 2015 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Mar 13 14:32:45 2015 +0100
@@ -289,7 +289,7 @@
 <!--145-->  <AD_PROCESS_ID><![CDATA[119]]></AD_PROCESS_ID>
 <!--145-->  <SEQNO><![CDATA[15]]></SEQNO>
 <!--145-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
-<!--145-->  <AD_VAL_RULE_ID><![CDATA[FDC45D1AE2404B8384D14DB6DED90DCF]]></AD_VAL_RULE_ID>
+<!--145-->  <AD_VAL_RULE_ID><![CDATA[130]]></AD_VAL_RULE_ID>
 <!--145-->  <COLUMNNAME><![CDATA[AD_Org_ID]]></COLUMNNAME>
 <!--145-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--145-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
@@ -4520,23 +4520,6 @@
 <!--97266E0DF6A24EC0BC6845B9E305F307-->  <AD_ELEMENT_ID><![CDATA[957]]></AD_ELEMENT_ID>
 <!--97266E0DF6A24EC0BC6845B9E305F307--></AD_PROCESS_PARA>
 
-<!--A06512891E7748F9A3F68341720B4B79--><AD_PROCESS_PARA>
-<!--A06512891E7748F9A3F68341720B4B79-->  <AD_PROCESS_PARA_ID><![CDATA[A06512891E7748F9A3F68341720B4B79]]></AD_PROCESS_PARA_ID>
-<!--A06512891E7748F9A3F68341720B4B79-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--A06512891E7748F9A3F68341720B4B79-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--A06512891E7748F9A3F68341720B4B79-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--A06512891E7748F9A3F68341720B4B79-->  <NAME><![CDATA[Include Child Organizations]]></NAME>
-<!--A06512891E7748F9A3F68341720B4B79-->  <AD_PROCESS_ID><![CDATA[119]]></AD_PROCESS_ID>
-<!--A06512891E7748F9A3F68341720B4B79-->  <SEQNO><![CDATA[16]]></SEQNO>
-<!--A06512891E7748F9A3F68341720B4B79-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
-<!--A06512891E7748F9A3F68341720B4B79-->  <COLUMNNAME><![CDATA[IncludeChildOrgs]]></COLUMNNAME>
-<!--A06512891E7748F9A3F68341720B4B79-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
-<!--A06512891E7748F9A3F68341720B4B79-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
-<!--A06512891E7748F9A3F68341720B4B79-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
-<!--A06512891E7748F9A3F68341720B4B79-->  <ISRANGE><![CDATA[N]]></ISRANGE>
-<!--A06512891E7748F9A3F68341720B4B79-->  <AD_ELEMENT_ID><![CDATA[046DBDB9E87B0A01E050007F01000340]]></AD_ELEMENT_ID>
-<!--A06512891E7748F9A3F68341720B4B79--></AD_PROCESS_PARA>
-
 <!--A49C24DB7D4E423183D1C18CA79F4861--><AD_PROCESS_PARA>
 <!--A49C24DB7D4E423183D1C18CA79F4861-->  <AD_PROCESS_PARA_ID><![CDATA[A49C24DB7D4E423183D1C18CA79F4861]]></AD_PROCESS_PARA_ID>
 <!--A49C24DB7D4E423183D1C18CA79F4861-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_VAL_RULE.xml	Fri Mar 13 11:57:34 2015 +0100
+++ b/src-db/database/sourcedata/AD_VAL_RULE.xml	Fri Mar 13 14:32:45 2015 +0100
@@ -319,7 +319,7 @@
 AND ((InvoiceRule = 'O'
 AND NOT EXISTS (SELECT 1 FROM C_OrderLine WHERE C_Order.C_Order_ID=C_OrderLine.C_Order_ID AND QtyOrdered <> QtyDelivered)
 AND EXISTS (SELECT 1 FROM C_OrderLine WHERE C_Order.C_Order_ID=C_OrderLine.C_Order_ID AND QtyOrdered <> QtyInvoiced))
-OR (InvoiceRule IN ('D', 'S')
+OR (InvoiceRule = 'D'
 AND EXISTS (SELECT 1 FROM C_OrderLine WHERE C_Order.C_Order_ID=C_OrderLine.C_Order_ID AND QtyOrdered <> QtyInvoiced AND QtyDelivered <> QtyInvoiced))
 OR (InvoiceRule = 'I'
 AND EXISTS (SELECT 1 FROM C_OrderLine WHERE C_Order.C_Order_ID=C_OrderLine.C_Order_ID AND QtyOrdered <> QtyInvoiced))))]]></CODE>