Issue 24615: false API change
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Mon, 09 Dec 2013 12:04:12 +0100
changeset 527 5f21f98bdbde
parent 526 c4b23df10e10
child 528 18d67f75f0d5
Issue 24615: false API change
model/src-db/database/model/functions/C_GETTAX.xml
model/src-db/database/model/tables/AD_ORGINFO.xml
model/src-db/database/model/tables/C_ACCTSCHEMA_DEFAULT.xml
model/src-db/database/model/tables/C_TAX.xml
--- a/model/src-db/database/model/functions/C_GETTAX.xml	Tue Nov 19 13:44:12 2013 +0530
+++ b/model/src-db/database/model/functions/C_GETTAX.xml	Mon Dec 09 12:04:12 2013 +0100
@@ -28,6 +28,9 @@
       <parameter name="p_glitem_id" type="VARCHAR" mode="in">
         <default><![CDATA[NULL]]></default>
       </parameter>
+      <parameter name="p_forcedcashvat" type="CHAR" mode="in">
+        <default><![CDATA[NULL]]></default>
+      </parameter>
       <body><![CDATA[/*************************************************************************
 * The contents of this file are subject to the Openbravo  Public  License
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
@@ -40,7 +43,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2001-2012 Openbravo SLU
+* All portions are Copyright (C) 2001-2013 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -56,6 +59,7 @@
   v_shipTo        VARCHAR2(32) ;
   v_aux           VARCHAR2(32) ;
   v_BPTaxCategory VARCHAR2(32);
+  v_IsCashVAT     AD_ORGINFO.ISCASHVAT%TYPE;
   TYPE RECORD IS REF CURSOR;
     BILLTO RECORD;
   BEGIN
@@ -92,7 +96,7 @@
       (SELECT il.C_Location_ID AS billToC_Location_ID,
         b.SO_BP_TaxCategory_ID,
         b.PO_BP_TaxCategory_ID,
-        b.IsTaxExempt
+        b.IsTaxExempt, coalesce(p_forcedcashvat, b.IsCashVat) as IsCashVat
       FROM C_BPartner_Location il,
            C_BPartner b
       WHERE il.C_BPartner_ID = b.C_BPartner_ID
@@ -101,9 +105,18 @@
       IF p_IsSOTrx = 'Y' THEN
         v_isTaxExempt := COALESCE(BILLTO.IsTaxExempt, 'N') ;
         v_BPTaxCategory := BILLTO.SO_BP_TaxCategory_ID;
+        IF p_forcedcashvat IS NULL THEN
+          select coalesce(oi.isCashVAT, 'N')
+          into v_IsCashVAT
+          from ad_orginfo oi
+          where oi.ad_org_id = ad_get_org_le_bu(p_org_id, 'LE');
+        ELSE
+          v_IsCashVAT := p_forcedcashvat;
+        END IF;
       ELSE
         v_isTaxExempt := 'N';
         v_BPTaxCategory := BILLTO.PO_BP_TaxCategory_ID;
+        v_IsCashVAT := BILLTO.isCashVAT;
       END IF;
       EXIT;
     END LOOP;
@@ -174,13 +187,15 @@
           (SELECT t.C_Tax_ID, '' AS billToC_Location_ID, '' AS IsTaxExempt
           FROM  (SELECT C_Tax_ID, C_Country_ID, C_Region_ID, To_Country_Id,
                    To_Region_ID, ValidFrom, C_TaxCategory_ID,
-                   Parent_Tax_ID, C_BP_TaxCategory_ID, SoPoType, c_Tax.ad_org_id,c_Tax.ad_client_id,IsDefault
+                   Parent_Tax_ID, C_BP_TaxCategory_ID, SoPoType, c_Tax.ad_org_id,c_Tax.ad_client_id,IsDefault,
+                   isCashVAT
                  FROM c_Tax
                 WHERE c_Tax.isActive = 'Y'
                  UNION
                  SELECT tz.C_Tax_ID, tz.From_Country_ID, tz.From_Region_ID, tz.To_Country_ID,
                    tz.To_Region_ID, ValidFrom, C_TaxCategory_ID,
-                   Parent_Tax_Id, C_BP_TaxCategory_ID, ct.SoPoType, ct.ad_org_id,ct.ad_client_id,ct.IsDefault
+                   Parent_Tax_Id, C_BP_TaxCategory_ID, ct.SoPoType, ct.ad_org_id,ct.ad_client_id,ct.IsDefault,
+                   isCashVAT
                  FROM c_Tax_Zone tz,
                       c_Tax ct
                  WHERE tz.C_Tax_ID = ct.C_Tax_ID
@@ -201,6 +216,7 @@
          --   AND ((t.C_BP_TaxCategory_ID = v_BPTaxCategory) OR (v_BPTaxCategory IS NULL))
             AND ((t.C_BP_TaxCategory_ID IS NOT NULL AND t.C_BP_TaxCategory_ID = v_BPTaxCategory) OR (t.C_BP_TaxCategory_ID IS NULL))
             AND (SoPoType = 'B' OR (SoPoType =(case when p_IsSOTrx='Y' then 'S' else 'P' end)))
+            AND t.isCashVAT = v_IsCashVAT
           ORDER BY ad_isorgincluded(p_org_id, t.ad_org_id,t.ad_client_id),t.C_BP_TaxCategory_ID, t.IsDefault DESC,t.C_Country_ID, t.To_Country_ID, t.C_Region_ID, t.To_Region_ID, t.ValidFrom DESC
           )
         LOOP
@@ -213,13 +229,15 @@
             FROM
               (SELECT C_Tax_ID, C_Country_ID, C_Region_ID, To_Country_Id,
                 To_Region_ID, ValidFrom, C_TaxCategory_ID,
-                Parent_Tax_ID, C_BP_TaxCategory_ID, SoPoType, c_Tax.ad_org_id,c_Tax.ad_client_id,IsDefault
+                Parent_Tax_ID, C_BP_TaxCategory_ID, SoPoType, c_Tax.ad_org_id,c_Tax.ad_client_id,IsDefault,
+                isCashVAT
               FROM c_Tax
               WHERE c_Tax.isActive = 'Y'
               UNION
               SELECT tz.C_Tax_ID, tz.From_Country_ID, tz.From_Region_ID, tz.To_Country_ID,
                 tz.To_Region_ID, ValidFrom, C_TaxCategory_ID,
-                Parent_Tax_Id, C_BP_TaxCategory_ID, SoPoType, ct.ad_org_id, ct.ad_client_id,ct.IsDefault
+                Parent_Tax_Id, C_BP_TaxCategory_ID, SoPoType, ct.ad_org_id, ct.ad_client_id,ct.IsDefault,
+                isCashVAT
               FROM c_Tax_Zone tz,
                 c_Tax ct
               WHERE tz.C_Tax_ID = ct.C_Tax_ID
@@ -241,6 +259,7 @@
               --AND ((t.C_BP_TaxCategory_ID = v_BPTaxCategory) OR (v_BPTaxCategory IS NULL))
               AND ((t.C_BP_TaxCategory_ID IS NOT NULL AND t.C_BP_TaxCategory_ID = v_BPTaxCategory) OR (t.C_BP_TaxCategory_ID IS NULL))
               AND (SoPoType = 'B' OR (SoPoType =(case when p_IsSOTrx='Y' then 'S' else 'P' end)))
+              AND t.isCashVAT = v_IsCashVAT
             ORDER BY ad_isorgincluded(p_org_id, t.ad_org_id,t.ad_client_id),t.C_BP_TaxCategory_ID,t.IsDefault DESC,t.C_Country_ID, t.C_Region_ID, t.ValidFrom DESC
             )
           LOOP
@@ -262,6 +281,7 @@
               AND (SoPoType = 'B' OR (SoPoType =(case when p_IsSOTrx='Y' then 'S' else 'P' end)))
               AND t.isActive = 'Y'
               AND ad_isorgincluded(p_org_id, t.ad_org_id,t.ad_client_id) <> -1
+              AND t.isCashVAT = v_IsCashVAT
             ORDER BY ad_isorgincluded(p_org_id, t.ad_org_id,t.ad_client_id),t.C_BP_TaxCategory_ID, t.ValidFrom DESC
             )
           LOOP
--- a/model/src-db/database/model/tables/AD_ORGINFO.xml	Tue Nov 19 13:44:12 2013 +0530
+++ b/model/src-db/database/model/tables/AD_ORGINFO.xml	Mon Dec 09 12:04:12 2013 +0100
@@ -73,6 +73,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="ISCASHVAT" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_ORG" name="AD_ORG_AD_ORGINFO" onDelete="cascade">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
@@ -95,6 +99,7 @@
         <reference local="C_LOCATION_ID" foreign="C_LOCATION_ID"/>
       </foreign-key>
       <check name="AD_ORGINFO_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
+      <check name="AD_ORGINFO_ISCASHVAT_CH"><![CDATA[((ISCASHVAT = 'Y') AND (ISTAXUNDEDUCTABLE = 'N')) OR (ISCASHVAT = 'N')]]></check>
       <check name="AD_ORGINFO_ISTAXUNDEDUCTABLE"><![CDATA[ISTAXUNDEDUCTABLE IN ('Y', 'N')]]></check>
     </table>
   </database>
--- a/model/src-db/database/model/tables/C_ACCTSCHEMA_DEFAULT.xml	Tue Nov 19 13:44:12 2013 +0530
+++ b/model/src-db/database/model/tables/C_ACCTSCHEMA_DEFAULT.xml	Mon Dec 09 12:04:12 2013 +0100
@@ -169,10 +169,18 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="T_DUE_TRANS_ACCT" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <column name="T_CREDIT_ACCT" primaryKey="false" required="true" type="VARCHAR" size="32" autoIncrement="false">
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="T_CREDIT_TRANS_ACCT" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <column name="B_INTRANSIT_ACCT" primaryKey="false" required="true" type="VARCHAR" size="32" autoIncrement="false">
         <default/>
         <onCreateDefault/>
@@ -492,7 +500,13 @@
       <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_ACCTSCHEMA_DEFAULT_T_CREDIT_">
         <reference local="T_CREDIT_ACCT" foreign="C_VALIDCOMBINATION_ID"/>
       </foreign-key>
+      <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_ACCTSCHEMA_DEFAULT_T_CREDITT">
+        <reference local="T_CREDIT_TRANS_ACCT" foreign="C_VALIDCOMBINATION_ID"/>
+      </foreign-key>
       <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_ACCTSCHEMA_DEFAULT_T_DUE_ACC">
+        <reference local="T_DUE_TRANS_ACCT" foreign="C_VALIDCOMBINATION_ID"/>
+      </foreign-key>
+      <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_ACCTSCHEMA_DEFAULT_T_DUETACC">
         <reference local="T_DUE_ACCT" foreign="C_VALIDCOMBINATION_ID"/>
       </foreign-key>
       <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_ACCTSCHEMA_DEFAULT_T_EXPENSE">
--- a/model/src-db/database/model/tables/C_TAX.xml	Tue Nov 19 13:44:12 2013 +0530
+++ b/model/src-db/database/model/tables/C_TAX.xml	Mon Dec 09 12:04:12 2013 +0100
@@ -145,6 +145,10 @@
         <default><![CDATA[D]]></default>
         <onCreateDefault/>
       </column>
+      <column name="ISCASHVAT" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="C_COUNTRY" name="C_COUNTRY_C_TAX">
         <reference local="C_COUNTRY_ID" foreign="C_COUNTRY_ID"/>
       </foreign-key>
@@ -182,6 +186,7 @@
         <unique-column name="PARENT_TAX_ID"/>
       </unique>
       <check name="C_TAX_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
+      <check name="C_TAX_ISCASHVAT_WH_CH"><![CDATA[((ISCASHVAT = 'Y') AND (ISWITHHOLDINGTAX = 'N')) OR (ISCASHVAT = 'N')]]></check>
       <check name="C_TAX_ISTAXDEDUCTABLE"><![CDATA[ISTAXDEDUCTABLE IN ('Y', 'N')]]></check>
     </table>
   </database>