details:   https://code.openbravo.com/erp/devel/main/rev/e11362bfc38c
changeset: 21534:e11362bfc38c
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Wed Dec 04 10:40:35 2013 +0100
summary:   Fixes issue 25232: Using instance variables on the 
GeneralAccountingReport

details:   https://code.openbravo.com/erp/devel/main/rev/ab4229c84e10
changeset: 21535:ab4229c84e10
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Thu Nov 28 11:24:57 2013 +0100
summary:   [cashvat] Fixed issue 24615: Cash VAT Management

Any legal entity can define whether it is subscribed to the Cash VAT 
management. By default organizations
are not subscribed to Cash VAT. To subscribe it, go to Organization | 
Information and set the Cash VAT flag to Yes.
Since that moment, the Sales flows (orders and invoices) will work with Cash VAT

Vendors can be subscribed to Cash VAT. This can be configured in the ERP at 
Business Partner | Vendor tab. Note that
each vendor registered into the system may be subscribed to Cash VAT or not.
For Purchase flows (orders and invoices), the system will detect whether the 
vendor is subscribed to Cash VAT and, in
this case, it will activate the Cash VAT support.

Both Sales and Purchase flows (orders and invoices) can override the Cash VAT 
configuration defined at the Organization and
Business Partner respectively by setting/unsetting the Cash VAT flag at the 
document header.

The C_GetTax function now accepts a new optional parameter to override the Cash 
VAT configuration defined at the Organization
or the Business Partner. This allows to properly purpose the right tax when 
entering order/invoice lines.


Created new tab Cash VAT under Sales/Purchase Invoice | Tax. It manages the tax 
amount that has been
paid for the invoice. It takes the percentage of the invoice that has been paid 
in a payment and it
calculates the correspondent tax amount and taxable amount for each tax 
included into the invoice.



Two new transitory tax accounts have been created to manage the Cash VAT. When 
an invoice is not yet paid/collected, the tax
amount is accounted to these transitory accounts. Once we pay/receive a 
payment, the correspondent amount is moved from the
transitory tax account to the final one. The Invoice, Payment, Transaction and 
Reconciliation accounting engines have been
modified to support the Cash VAT flows.

When an invoice has been paid from an order (prepayment), the accounting will 
use the final tax accounts instead of the transitory ones.

The COA importer now supports the new two transitory tax account defaults: 
T_CREDIT_TRANS_ACCT and T_DUE_TRANS_ACCT


The invoice's JRXML now prints a "Cash VAT Invoice" (at the footer) to fulfill 
the law

details:   https://code.openbravo.com/erp/devel/main/rev/2e3be692607f
changeset: 21536:2e3be692607f
user:      Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at> 
openbravo.com>
date:      Wed Dec 04 11:23:46 2013 +0530
summary:   Related to Issue 24615: Openbravo 3 needs to allow Cash VAT 
management

details:   https://code.openbravo.com/erp/devel/main/rev/e5d9223ba5d3
changeset: 21537:e5d9223ba5d3
user:      Eduardo Argal Guibert <eduardo.argal <at> openbravo.com>
date:      Mon Dec 09 15:45:03 2013 +0530
summary:   Related to Issue 24615

details:   https://code.openbravo.com/erp/devel/main/rev/eaaff0469b9b
changeset: 21538:eaaff0469b9b
user:      Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at> 
openbravo.com>
date:      Mon Dec 09 16:17:44 2013 +0530
summary:   Related to Issue 24615

diffstat:

 
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
 |    48 +-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
     |    23 +-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
 |     2 +-
 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
 |     4 +-
 src-db/database/model/functions/C_GETTAX.xml                                   
                       |    32 +-
 src-db/database/model/functions/C_INVOICE_POST.xml                             
                       |    17 +-
 src-db/database/model/functions/C_ORDER_POST1.xml                              
                       |    21 +-
 src-db/database/model/tables/AD_ORGINFO.xml                                    
                       |     5 +
 src-db/database/model/tables/C_ACCTSCHEMA_DEFAULT.xml                          
                       |    14 +
 src-db/database/model/tables/C_BPARTNER.xml                                    
                       |     5 +
 src-db/database/model/tables/C_INVOICE.xml                                     
                       |     5 +
 src-db/database/model/tables/C_INVOICETAX_CASHVAT.xml                          
                       |    70 +
 src-db/database/model/tables/C_ORDER.xml                                       
                       |     5 +
 src-db/database/model/tables/C_TAX.xml                                         
                       |     5 +
 src-db/database/model/tables/C_TAX_ACCT.xml                                    
                       |    14 +
 src-db/database/model/triggers/C_INVOICELINE_TRG.xml                           
                       |    28 +-
 src-db/database/model/triggers/C_TAX_TRG.xml                                   
                       |     8 +-
 src-db/database/model/views/C_INVOICETAX_CASHVAT_V.xml                         
                       |     4 +
 src-db/database/sourcedata/AD_AUXILIARINPUT.xml                                
                       |    11 +
 src-db/database/sourcedata/AD_CALLOUT.xml                                      
                       |    36 +
 src-db/database/sourcedata/AD_COLUMN.xml                                       
                       |  1635 +++++++++-
 src-db/database/sourcedata/AD_ELEMENT.xml                                      
                       |    70 +
 src-db/database/sourcedata/AD_FIELD.xml                                        
                       |  1261 +++++++
 src-db/database/sourcedata/AD_MESSAGE.xml                                      
                       |    36 +
 src-db/database/sourcedata/AD_MODEL_OBJECT.xml                                 
                       |    48 +
 src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml                         
                       |    40 +
 src-db/database/sourcedata/AD_TAB.xml                                          
                       |    60 +
 src-db/database/sourcedata/AD_TABLE.xml                                        
                       |    50 +
 src-db/database/sourcedata/AD_TEXTINTERFACES.xml                               
                       |    11 +
 src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java               
                       |    20 +-
 src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_Organization.java           
                       |    49 +
 src/org/openbravo/erpCommon/ad_callouts/SE_Order_BPartner.java                 
                       |    16 +-
 src/org/openbravo/erpCommon/ad_callouts/SE_Order_Organization.java             
                       |    48 +
 src/org/openbravo/erpCommon/ad_callouts/SE_Organization_NotTaxDeductable.java  
                       |    40 +
 src/org/openbravo/erpCommon/ad_callouts/SE_TaxRate_Withholding.java            
                       |    40 +
 src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Product.java                
                       |     2 +-
 src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Tax_data.xsql               
                       |     5 +-
 src/org/openbravo/erpCommon/ad_callouts/SL_Order_Product.java                  
                       |     3 +-
 src/org/openbravo/erpCommon/ad_callouts/SL_Order_Tax_data.xsql                 
                       |     4 +-
 src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java              
                       |     6 +
 src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java                        
                       |     6 +
 src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java                 
                       |    11 +-
 src/org/openbravo/erpCommon/ad_forms/DocInvoice.java                           
                       |   114 +-
 src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql                      
                       |     7 +-
 
src/org/openbravo/erpCommon/ad_forms/DocLineCashVATReady_PaymentTransactionReconciliation.java
        |    77 +
 src/org/openbravo/erpCommon/ad_forms/DocLine_FINFinAccTransaction.java         
                       |     4 +-
 src/org/openbravo/erpCommon/ad_forms/DocLine_FINPayment.java                   
                       |     4 +-
 src/org/openbravo/erpCommon/ad_forms/DocLine_FINReconciliation.java            
                       |     4 +-
 src/org/openbravo/erpCommon/ad_forms/DocTax.java                               
                       |    14 +-
 src/org/openbravo/erpCommon/ad_forms/DocTax_data.xsql                          
                       |     4 +-
 src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java           
                       |    26 +-
 src/org/openbravo/erpCommon/businessUtility/InitialSetupUtility.java           
                       |    10 +-
 src/org/openbravo/erpCommon/businessUtility/Tax.java                           
                       |    22 +-
 src/org/openbravo/erpCommon/businessUtility/Tax_data.xsql                      
                       |    18 +-
 src/org/openbravo/erpCommon/utility/CashVATUtil.java                           
                       |   425 ++
 src/org/openbravo/erpReports/RptC_Invoice_new.jrxml                            
                       |    14 +-
 56 files changed, 4445 insertions(+), 116 deletions(-)

diffs (truncated from 6705 to 300 lines):

diff -r c8fabbf7108e -r eaaff0469b9b 
modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
--- 
a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
     Wed Dec 04 14:38:23 2013 +0000
+++ 
b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
     Mon Dec 09 16:17:44 2013 +0530
@@ -81,6 +81,7 @@
 v_finacct_currency VARCHAR2(32);
 v_rate NUMBER;
 v_PricePr NUMBER;
+v_IsCashVAT C_Invoice.IsCashVAT%TYPE;
 
 TYPE RECORD IS REF CURSOR;
 Cur_Params RECORD;
@@ -117,12 +118,14 @@
       grandtotal, C_PaymentTerm_ID, PaymentRule, C_Currency_ID,
       C_BPartner_ID, DateInvoiced, totallines, fin_paymentmethod_id,
       fin_payment_priority_id, documentNo, poreference,
-      c_project_id, c_campaign_id, c_activity_id, user1_id, user2_id, 
c_costcenter_id
+      c_project_id, c_campaign_id, c_activity_id, user1_id, user2_id, 
c_costcenter_id,
+      IsCashVAT
   INTO v_Client_ID, v_Org_ID, v_DocTypeTarget_ID, v_IsSOTrx,
       v_GrandTotal, v_PaymentTerm, v_PaymentRule, v_Currency_ID,
       v_BPartner_ID, v_DateInvoiced, v_totallines, v_PaymentMethod,
       v_PaymentPriority, v_documentno, v_poreference,
-      v_project_id, v_campaign_id, v_activity_id, v_user1, v_user2, 
v_costcenter
+      v_project_id, v_campaign_id, v_activity_id, v_user1, v_user2, 
v_costcenter,
+      v_IsCashVAT
   FROM c_invoice
   WHERE c_invoice_id=p_record_id;
   
@@ -192,6 +195,8 @@
       v_paymentCount NUMBER:= 0;
       v_negativePS NUMBER:= 1;
       v_psdbreakbypartialpayment BOOLEAN:=TRUE;
+      cur_cinvoicetax RECORD;
+      v_PercentageCashVAT NUMBER;
 
       CURSOR cur_order_schdet (invoice_id VARCHAR) IS
       SELECT DISTINCT c_orderline.c_order_id AS order_id, 
fin_payment_scheduledetail.amount + 
COALESCE(fin_payment_scheduledetail.writeoffamt,0) AS amount,
@@ -482,6 +487,25 @@
 
               v_scheduledamount := v_scheduledamount - v_scheduledetailamount;
 
+             -- Create C_InvoiceTax_CashVAT records
+             IF (v_IsCashVAT = 'Y' AND order_schdet.fin_payment_detail_id IS 
NOT NULL) THEN
+                v_PercentageCashVAT := 
abs(c_currency_round(v_scheduledetailamount * 100 / v_GrandTotal, 
v_Currency_ID, null));
+               FOR cur_cinvoicetax IN (
+                 SELECT it.C_InvoiceTax_ID, it.taxamt, it.taxbaseamt
+                  FROM C_InvoiceTax it
+                 WHERE it.c_invoice_id = p_record_id
+                )
+                LOOP
+                 INSERT INTO c_invoicetax_cashvat(
+                  c_invoicetax_cashvat_id, ad_client_id, ad_org_id, isactive, 
created,
+                  createdby, updated, updatedby, c_invoicetax_id, percentage, 
taxamt,
+                  taxbaseamt, fin_payment_detail_id)
+                  VALUES (get_uuid(), v_Client_ID, v_Org_ID, 'Y', now(),
+                  p_user, now(), p_user, cur_cinvoicetax.C_InvoiceTax_ID, 
v_PercentageCashVAT, c_currency_round(v_PercentageCashVAT * 
cur_cinvoicetax.taxamt / 100, v_Currency_ID, null),
+                  c_currency_round(v_PercentageCashVAT * 
cur_cinvoicetax.taxbaseamt / 100, v_Currency_ID, null), 
order_schdet.fin_payment_detail_id);
+                END LOOP;
+             END IF;
+
               IF (v_scheduledamount * v_negativeps <= 0 AND v_paymentcount > 
0) THEN
                 -- actual invoice's payment schedule processed.
                 v_oldorder := order_schdet.order_id;
@@ -723,6 +747,26 @@
                 SET FIN_PAYMENT_DETAIL_ID = v_FIN_PAYMENT_DETAIL_ID
                 WHERE FIN_PAYMENT_SCHEDULEDETAIL_ID = 
cur_linktopayment_scheddetails.FIN_PAYMENT_SCHEDULEDETAIL_ID
                   AND FIN_PAYMENT_DETAIL_ID IS NULL;
+                  
+                -- Create C_InvoiceTax_CashVAT records
+             IF (v_IsCashVAT = 'Y') THEN
+                v_PercentageCashVAT := 
abs(c_currency_round(cur_linktopayment_scheddetails.AMOUNT * 100 / 
v_GrandTotal, v_Currency_ID, null));
+                FOR cur_cinvoicetax IN (
+                  SELECT it.C_InvoiceTax_ID, it.taxamt, it.taxbaseamt
+                              FROM C_InvoiceTax it
+                  WHERE it.c_invoice_id = p_record_id
+                )
+                LOOP
+                  INSERT INTO c_invoicetax_cashvat(
+                        c_invoicetax_cashvat_id, ad_client_id, ad_org_id, 
isactive, created,
+                        createdby, updated, updatedby, c_invoicetax_id, 
percentage, taxamt,
+                        taxbaseamt, fin_payment_detail_id)
+                        VALUES (get_uuid(), v_Client_ID, v_Org_ID, 'Y', now(),
+                        p_user, now(), p_user, 
cur_cinvoicetax.C_InvoiceTax_ID, v_PercentageCashVAT, 
c_currency_round(v_PercentageCashVAT * cur_cinvoicetax.taxamt / 100, 
v_Currency_ID, null),
+                        c_currency_round(v_PercentageCashVAT * 
cur_cinvoicetax.taxbaseamt / 100, v_Currency_ID, null), 
v_FIN_PAYMENT_DETAIL_ID);
+                END LOOP;
+             END IF;
+        
               END LOOP;
 
               --Fixes 14403 defect 
diff -r c8fabbf7108e -r eaaff0469b9b 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
 Wed Dec 04 14:38:23 2013 +0000
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
 Mon Dec 09 16:17:44 2013 +0530
@@ -50,6 +50,7 @@
 import org.openbravo.dal.service.OBDao;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.utility.CashVATUtil;
 import org.openbravo.erpCommon.utility.FieldProviderFactory;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.Utility;
@@ -1099,7 +1100,7 @@
 
   /**
    * Update Payment Schedule amounts with the amount of the Payment Schedule 
Detail or Payment
-   * Detail
+   * Detail. Useful when paying orders
    * 
    * @param paymentSchedule
    *          Payment Schedule to be updated
@@ -1110,6 +1111,25 @@
    */
   public static void updatePaymentScheduleAmounts(FIN_PaymentSchedule 
paymentSchedule,
       BigDecimal amount, BigDecimal writeOffAmount) {
+    updatePaymentScheduleAmounts(null, paymentSchedule, amount, 
writeOffAmount);
+  }
+
+  /**
+   * Update Payment Schedule amounts with the amount of the Payment Schedule 
Detail or Payment
+   * Detail. Useful when paying invoices. It supports Invoices with Cash VAT, 
creating the records
+   * into the Cash VAT management table (InvoiceTaxCashVAT)
+   * 
+   * @param paymentDetail
+   *          payment
+   * @param paymentSchedule
+   *          Payment Schedule to be updated
+   * @param amount
+   *          Amount of the Payment Schedule Detail or Payment Detail
+   * @param writeOffAmount
+   *          Write off amount, null or 0 if not applicable.
+   */
+  public static void updatePaymentScheduleAmounts(FIN_PaymentDetail 
paymentDetail,
+      FIN_PaymentSchedule paymentSchedule, BigDecimal amount, BigDecimal 
writeOffAmount) {
     paymentSchedule.setPaidAmount(paymentSchedule.getPaidAmount().add(amount));
     
paymentSchedule.setOutstandingAmount(paymentSchedule.getOutstandingAmount().subtract(amount));
     if (writeOffAmount != null && writeOffAmount.compareTo(BigDecimal.ZERO) != 
0) {
@@ -1118,6 +1138,7 @@
           writeOffAmount));
     }
     OBDal.getInstance().save(paymentSchedule);
+    CashVATUtil.createInvoiceTaxCashVAT(paymentDetail, paymentSchedule, 
amount.add(writeOffAmount));
     if (paymentSchedule.getInvoice() != null) {
       updateInvoicePaymentMonitor(paymentSchedule, amount, writeOffAmount);
     }
diff -r c8fabbf7108e -r eaaff0469b9b 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
     Wed Dec 04 14:38:23 2013 +0000
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
     Mon Dec 09 16:17:44 2013 +0530
@@ -252,7 +252,7 @@
           creditUsed = creditUsed.subtract(amountWithSign);
           bPartner.setCreditUsed(creditUsed);
           OBDal.getInstance().save(bPartner);
-          
FIN_AddPayment.updatePaymentScheduleAmounts(psd.getInvoicePaymentSchedule(),
+          FIN_AddPayment.updatePaymentScheduleAmounts(pDetail, 
psd.getInvoicePaymentSchedule(),
               psd.getAmount(), psd.getWriteoffAmount());
         }
         if (psd.getOrderPaymentSchedule() != null) {
diff -r c8fabbf7108e -r eaaff0469b9b 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
     Wed Dec 04 14:38:23 2013 +0000
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
     Mon Dec 09 16:17:44 2013 +0530
@@ -389,7 +389,7 @@
                   } else {
                     increaseCustomerCredit(businessPartner, amount);
                   }
-                  FIN_AddPayment.updatePaymentScheduleAmounts(
+                  FIN_AddPayment.updatePaymentScheduleAmounts(paymentDetail,
                       paymentScheduleDetail.getInvoicePaymentSchedule(),
                       paymentScheduleDetail.getAmount(), 
paymentScheduleDetail.getWriteoffAmount());
                 }
@@ -766,7 +766,7 @@
                   }
                 }
                 if (restorePaidAmounts) {
-                  FIN_AddPayment.updatePaymentScheduleAmounts(
+                  FIN_AddPayment.updatePaymentScheduleAmounts(paymentDetail,
                       paymentScheduleDetail.getInvoicePaymentSchedule(), 
psdAmount.negate(),
                       psdWriteoffAmount.negate());
                   // BP SO_CreditUsed
diff -r c8fabbf7108e -r eaaff0469b9b 
src-db/database/model/functions/C_GETTAX.xml
--- a/src-db/database/model/functions/C_GETTAX.xml      Wed Dec 04 14:38:23 
2013 +0000
+++ b/src-db/database/model/functions/C_GETTAX.xml      Mon Dec 09 16:17:44 
2013 +0530
@@ -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
diff -r c8fabbf7108e -r eaaff0469b9b 
src-db/database/model/functions/C_INVOICE_POST.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml        Wed Dec 04 
14:38:23 2013 +0000
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml        Mon Dec 09 
16:17:44 2013 +0530
@@ -170,6 +170,8 @@
   v_invoiceBlocking VARCHAR2(1):='N';

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to