[pool] Merge with pi
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Mon, 27 Jul 2015 19:05:39 +0200
changeset 27262 822b21bc1946
parent 27261 79a71a5ae594 (current diff)
parent 27149 f9a8f174d429 (diff)
child 27263 74d62d368b8e
[pool] Merge with pi
build.xml
legal/Licensing.txt
modules/org.openbravo.base.weld/lib/test/arquillian-api-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/arquillian-impl-base-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/arquillian-junit-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/arquillian-protocol-local-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/arquillian-spi-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/arquillian-testenricher-cdi-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha4.jar
modules/org.openbravo.base.weld/lib/test/shrinkwrap-api-1.0.0-alpha-11.jar
modules/org.openbravo.base.weld/lib/test/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar
modules/org.openbravo.base.weld/lib/test/shrinkwrap-impl-base-1.0.0-alpha-11.jar
modules/org.openbravo.base.weld/lib/test/shrinkwrap-spi-1.0.0-alpha-11.jar
src-db/database/lib/dbsourcemanager.jar
src-db/database/model/triggers/A_AMORTIZATIONLINE_TRG2.xml
src-util/modulescript/src/org/openbravo/modulescript/OpenbravoVersion.java
--- a/build.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/build.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -597,6 +597,10 @@
     <ant dir="${base.src.test}" target="run.quick.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
+  <target name="run.test" depends="init">
+    <ant dir="${base.src.test}" target="run.test" inheritAll="true" inheritRefs="true" />
+  </target>
+
   <target name="run.api.test.javascript">
     <ant dir="${base.src.test}" target="run.api.test.javascript" inheritAll="true" inheritRefs="true" />
   </target>
--- a/legal/Licensing.txt	Wed Jul 22 17:54:36 2015 +0200
+++ b/legal/Licensing.txt	Mon Jul 27 19:05:39 2015 +0200
@@ -215,6 +215,7 @@
 # ejb-api-3.0.jar
 # jboss-interceptor-api-3.1.0-CR3.jar
 # jboss-ejb3-api-3.1.0.jar
+# jboss-el-api_2.2_spec-1.0.0.Final.jar
 Under the LGPL license (included as LGPL-2.1.txt in this folder)
 
 # cal10n-api-0.7.4.jar
@@ -230,17 +231,28 @@
 # weld-core-1.1.24.Final.jar
 # weld-servlet-core-1.1.24.Final.jar
 # weld-spi.jar
-# arquillian-api-1.0.0.Alpha4.jar
-# arquillian-impl-base-1.0.0.Alpha4.jar
-# arquillian-junit-1.0.0.Alpha4.jar
-# arquillian-protocol-local-1.0.0.Alpha4.jar
-# arquillian-spi-1.0.0.Alpha4.jar
-# arquillian-testenricher-cdi-1.0.0.Alpha4.jar
-# arquillian-weld-ee-embedded-1.1-1.0.0.Alpha4.jar
-# shrinkwrap-api-1.0.0-alpha-11.jar
-# shrinkwrap-extension-classloader-1.0.0-alpha-11.jar
-# shrinkwrap-impl-base-1.0.0-alpha-11.jar
-# shrinkwrap-spi-1.0.0-alpha-11.jar
+# arquillian-config-api-1.1.8.Final.jar
+# arquillian-config-impl-base-1.1.8.Final.jar
+# arquillian-container-impl-base-1.1.8.Final.jar
+# arquillian-container-spi-1.1.8.Final.jar
+# arquillian-container-test-api-1.1.8.Final.jar
+# arquillian-container-test-impl-base-1.1.8.Final.jar
+# arquillian-container-test-spi-1.1.8.Final.jar
+# arquillian-core-api-1.1.8.Final.jar
+# arquillian-core-impl-base-1.1.8.Final.jar
+# arquillian-core-spi-1.1.8.Final.jar
+# arquillian-junit-container-1.1.8.Final.jar
+# arquillian-junit-core-1.1.8.Final.jar
+# arquillian-test-api-1.1.8.Final.jar
+# arquillian-testenricher-cdi-1.0.2.Final.jar
+# arquillian-test-impl-base-1.1.8.Final.jar
+# arquillian-test-spi-1.1.8.Final.jar
+# arquillian-weld-ee-embedded-1.1-1.0.0.CR8.jar
+# shrinkwrap-api-1.2.2.jar
+# shrinkwrap-descriptors-api-base-2.0.0-alpha-7.jar
+# shrinkwrap-descriptors-spi-2.0.0-alpha-7.jar
+# shrinkwrap-impl-base-1.2.2.jar
+# shrinkwrap-spi-1.2.2.jar
 # validation-api-1.0.0.GA.jar
 # jsmin.0.2.4.jar
 # httpcore-4.0.1.jar
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -151,6 +151,31 @@
 <!--0E18ACB41550424A83A62E33C2D83FB3-->  <DISPLAYTITLE><![CDATA[N]]></DISPLAYTITLE>
 <!--0E18ACB41550424A83A62E33C2D83FB3--></OBUIAPP_PARAMETER>
 
+<!--0F44A3B0971F47A1B509A50377BEB383--><OBUIAPP_PARAMETER>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <OBUIAPP_PARAMETER_ID><![CDATA[0F44A3B0971F47A1B509A50377BEB383]]></OBUIAPP_PARAMETER_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <NAME><![CDATA[Accounting Date]]></NAME>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <DESCRIPTION><![CDATA[The date this transaction is recorded for in the general ledger.]]></DESCRIPTION>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <HELP><![CDATA[The date this transaction is recorded on in the general ledger. This date also indicates which accounting period within the fiscal year this transaction will be part of.]]></HELP>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <COLUMNNAME><![CDATA[dateAcct]]></COLUMNNAME>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <FIELDLENGTH><![CDATA[19]]></FIELDLENGTH>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <DEFAULTVALUE><![CDATA[OB.getSession().getAttribute('#DATE')]]></DEFAULTVALUE>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <AD_ELEMENT_ID><![CDATA[263]]></AD_ELEMENT_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <OBUIAPP_PROCESS_ID><![CDATA[4CE463C04CA0412CAC57EF58FE0F8498]]></OBUIAPP_PROCESS_ID>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--0F44A3B0971F47A1B509A50377BEB383-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--0F44A3B0971F47A1B509A50377BEB383--></OBUIAPP_PARAMETER>
+
 <!--111000BF6C4445E785AA08331A268E1B--><OBUIAPP_PARAMETER>
 <!--111000BF6C4445E785AA08331A268E1B-->  <OBUIAPP_PARAMETER_ID><![CDATA[111000BF6C4445E785AA08331A268E1B]]></OBUIAPP_PARAMETER_ID>
 <!--111000BF6C4445E785AA08331A268E1B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -811,7 +836,7 @@
 <!--74479AE073FF4FA5A527DC79EC0A1C82-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--74479AE073FF4FA5A527DC79EC0A1C82-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--74479AE073FF4FA5A527DC79EC0A1C82-->  <NAME><![CDATA[Payment]]></NAME>
-<!--74479AE073FF4FA5A527DC79EC0A1C82-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--74479AE073FF4FA5A527DC79EC0A1C82-->  <SEQNO><![CDATA[30]]></SEQNO>
 <!--74479AE073FF4FA5A527DC79EC0A1C82-->  <AD_REFERENCE_ID><![CDATA[FF80818132D8F0F30132D9BC395D0038]]></AD_REFERENCE_ID>
 <!--74479AE073FF4FA5A527DC79EC0A1C82-->  <AD_REFERENCE_VALUE_ID><![CDATA[D9B6068A6D3E4B7487470E7D2F033A54]]></AD_REFERENCE_VALUE_ID>
 <!--74479AE073FF4FA5A527DC79EC0A1C82-->  <COLUMNNAME><![CDATA[payments]]></COLUMNNAME>
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddMultiplePaymentsHandler.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddMultiplePaymentsHandler.java	Mon Jul 27 19:05:39 2015 +0200
@@ -52,6 +52,7 @@
       final JSONArray selectedPayments = jsonparams.getJSONObject("payments").getJSONArray(
           "_selection");
       final Date statementDate = jsDateFormat.parse(jsonparams.getString("statementDate"));
+      final Date dateAcct = jsDateFormat.parse(jsonparams.getString("dateAcct"));
       final String strAccountId = jsonData.getString("Fin_Financial_Account_ID");
 
       int selectedPaymentsLength = selectedPayments.length();
@@ -62,7 +63,7 @@
 
       for (int i = 0; i < selectedPaymentsLength; i++) {
         final JSONObject paymentJS = selectedPayments.getJSONObject(i);
-        createAndProcessTransactionFromPayment(paymentJS, statementDate, strAccountId);
+        createAndProcessTransactionFromPayment(paymentJS, statementDate, dateAcct, strAccountId);
       }
       // Success Message
       return getSuccessMessage(String.format(
@@ -87,7 +88,7 @@
    * Creates a new transaction from the payment and then it processes the transaction
    */
   private void createAndProcessTransactionFromPayment(final JSONObject paymentJS,
-      final Date transactionDate, String strAccountId) throws JSONException {
+      final Date transactionDate, final Date acctDate, String strAccountId) throws JSONException {
 
     try {
       OBContext.setAdminMode(true);
@@ -100,6 +101,7 @@
       if (payment != null) {
         final FIN_FinaccTransaction transaction = TransactionsDao.createFinAccTransaction(payment);
         transaction.setTransactionDate(transactionDate);
+        transaction.setDateAcct(acctDate);
         transaction.setAccount(account);
         FIN_TransactionProcess.doTransactionProcess(ACTION_PROCESS_TRANSACTION, transaction);
       }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java	Mon Jul 27 19:05:39 2015 +0200
@@ -296,14 +296,20 @@
             // If the invoice grand total is ZERO or already has payments (due to
             // payment method automation) or the business partner does not have a default financial
             // account defined or invoice's payment method is not inside BP's financial
-            // account do not cancel credit
+            // account or the business partner's currency is not equal to the invoice's currency do
+            // not cancel credit
             if (BigDecimal.ZERO.compareTo(invoice.getGrandTotalAmount()) != 0
                 && isPaymentMethodConfigured(invoice)
                 && !isInvoiceWithPayments(invoice)
                 && (AcctServer.DOCTYPE_ARInvoice.equals(invoiceDocCategory) || AcctServer.DOCTYPE_APInvoice
-                    .equals(invoiceDocCategory))) {
-              creditPayments = dao.getCustomerPaymentsWithCredit(invoice.getOrganization(),
-                  invoice.getBusinessPartner(), invoice.isSalesTransaction());
+                    .equals(invoiceDocCategory))
+                && (invoice.getBusinessPartner().getCurrency() != null && StringUtils.equals(
+                    invoice.getCurrency().getId(), invoice.getBusinessPartner().getCurrency()
+                        .getId()))) {
+              creditPayments = dao
+                  .getCustomerPaymentsWithCredit(invoice.getOrganization(),
+                      invoice.getBusinessPartner(), invoice.isSalesTransaction(),
+                      invoice.getCurrency());
               if (creditPayments != null && !creditPayments.isEmpty()) {
                 printPageCreditPaymentGrid(response, vars, strC_Invoice_ID, strdocaction, strTabId,
                     strC_Invoice_ID, strdocaction, strWindowId, strTabId, invoice.getInvoiceDate(),
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Mon Jul 27 19:05:39 2015 +0200
@@ -1895,8 +1895,14 @@
   }
 
   public BigDecimal getCustomerCredit(BusinessPartner bp, boolean isReceipt, Organization Org) {
+    return getCustomerCredit(bp, isReceipt, Org, null);
+  }
+
+  public BigDecimal getCustomerCredit(BusinessPartner bp, boolean isReceipt, Organization Org,
+      Currency currency) {
     BigDecimal creditAmount = BigDecimal.ZERO;
-    for (FIN_Payment payment : getCustomerPaymentsWithCredit(Org, bp, isReceipt))
+    List<FIN_Payment> paymentList = getCustomerPaymentsWithCredit(Org, bp, isReceipt, currency);
+    for (FIN_Payment payment : paymentList)
       creditAmount = creditAmount.add(payment.getGeneratedCredit()).subtract(
           payment.getUsedCredit());
     return creditAmount;
@@ -1923,6 +1929,15 @@
    */
   public List<FIN_Payment> getCustomerPaymentsWithCredit(Organization org, BusinessPartner bp,
       boolean isReceipt) {
+    return getCustomerPaymentsWithCredit(org, bp, isReceipt, null);
+  }
+
+  /**
+   * Returns the list of credit payments for the selected business partner that belongs to the legal
+   * entity's natural tree of the given organization
+   */
+  public List<FIN_Payment> getCustomerPaymentsWithCredit(Organization org, BusinessPartner bp,
+      boolean isReceipt, Currency currency) {
 
     try {
       OBContext.setAdminMode(true);
@@ -1936,6 +1951,9 @@
       Set<String> orgIds = OBContext.getOBContext().getOrganizationStructureProvider()
           .getChildTree(legalEntity.getId(), true);
       obcPayment.add(Restrictions.in("organization.id", orgIds));
+      if (currency != null) {
+        obcPayment.add(Restrictions.eq(FIN_Payment.PROPERTY_CURRENCY, currency));
+      }
       obcPayment.addOrderBy(FIN_Payment.PROPERTY_PAYMENTDATE, true);
       obcPayment.addOrderBy(FIN_Payment.PROPERTY_DOCUMENTNO, true);
 
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 
@@ -59,7 +60,9 @@
     BusinessPartner bpartner = paymentIn.getBusinessPartner();
     if (bpartner != null) {
       Organization org = paymentIn.getOrganization();
-      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+      Currency currency = paymentIn.getCurrency();
+      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org,
+          currency);
       return customerCredit.signum() > 0;
     } else {
       return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.financialmgmt.payment.FIN_Payment;
 
@@ -59,7 +60,9 @@
       BusinessPartner bpartner = paymentOut.getBusinessPartner();
       if (bpartner != null) {
         Organization org = paymentOut.getOrganization();
-        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+        Currency currency = paymentOut.getCurrency();
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org,
+            currency);
         return customerCredit.signum() > 0;
       } else {
         return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.invoice.Invoice;
 
@@ -60,7 +61,9 @@
       BusinessPartner bpartner = invoice.getBusinessPartner();
       if (bpartner != null) {
         Organization org = invoice.getOrganization();
-        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+        Currency currency = invoice.getCurrency();
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org,
+            currency);
         return customerCredit.signum() > 0;
       } else {
         return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.order.Order;
 
@@ -60,7 +61,9 @@
       BusinessPartner bpartner = order.getBusinessPartner();
       if (bpartner != null) {
         Organization org = order.getOrganization();
-        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+        Currency currency = order.getCurrency();
+        BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org,
+            currency);
         return (customerCredit.signum() > 0);
       } else {
         return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesInvoiceAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.invoice.Invoice;
 
@@ -59,7 +60,9 @@
     BusinessPartner bpartner = invoice.getBusinessPartner();
     if (bpartner != null) {
       Organization org = invoice.getOrganization();
-      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+      Currency currency = invoice.getCurrency();
+      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org,
+          currency);
       return customerCredit.signum() > 0;
     } else {
       return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/SalesOrderAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.order.Order;
 
@@ -60,7 +61,9 @@
     BusinessPartner bpartner = order.getBusinessPartner();
     if (bpartner != null) {
       Organization org = order.getOrganization();
-      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+      Currency currency = order.getCurrency();
+      BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org,
+          currency);
       return customerCredit.signum() > 0;
     } else {
       return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDisplayLogics.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDisplayLogics.java	Mon Jul 27 19:05:39 2015 +0200
@@ -28,6 +28,7 @@
 import org.openbravo.client.kernel.ComponentProvider;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.currency.Currency;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
 
@@ -67,8 +68,9 @@
         BusinessPartner bpartner = OBDal.getInstance().get(BusinessPartner.class,
             strBusinessPartner);
         Organization org = OBDal.getInstance().get(Organization.class, context.get("ad_org_id"));
+        Currency currency = OBDal.getInstance().get(Currency.class, context.get("c_currency_id"));
         BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner,
-            "RCIN".equals(document), org);
+            "RCIN".equals(document), org, currency);
         return customerCredit.signum() > 0;
       } else {
         return false;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/hqlinjections/CreditToUseTransformer.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/hqlinjections/CreditToUseTransformer.java	Mon Jul 27 19:05:39 2015 +0200
@@ -36,11 +36,16 @@
     transformedHQL = transformedHQL.replace("@whereClause@",
         getWhereClause(requestParameters, queryNamedParameters));
 
+    // Sets parameters
+    queryNamedParameters.put("currencyId", requestParameters.get("c_currency_id"));
+
     return transformedHQL;
   }
 
   private CharSequence getWhereClause(Map<String, String> requestParameters,
       Map<String, Object> queryNamedParameters) {
-    return " ";
+    StringBuffer whereClause = new StringBuffer();
+    whereClause.append(" and f.currency.id = :currencyId ");
+    return whereClause;
   }
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournal.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPaymentFromJournal.java	Mon Jul 27 19:05:39 2015 +0200
@@ -19,9 +19,7 @@
 
 package org.openbravo.advpaymentmngt.process;
 
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
@@ -29,7 +27,6 @@
 
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.VariablesSecureApp;
-import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -48,10 +45,6 @@
   protected void doExecute(ProcessBundle bundle) throws Exception {
     int cont = 0;
 
-    String dateFormatString = OBPropertiesProvider.getInstance().getOpenbravoProperties()
-        .getProperty("dateFormat.java");
-    SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString);
-
     // Recover context and variables
     ConnectionProvider conn = bundle.getConnection();
     VariablesSecureApp varsAux = bundle.getContext().toVars();
@@ -86,11 +79,6 @@
           }
         }
       }
-      if (!"".equals(relatedPayments)) {
-        relatedPayments = relatedPayments.substring(0, relatedPayments.length() - 2);
-        throw new OBException("@FIN_JournalLineRelatedPayments@: " + relatedPayments);
-      }
-
       try {
         // Call GL_Journal_Post method from the database.
         final List<Object> parameters = new ArrayList<Object>();
@@ -107,7 +95,6 @@
       }
 
       OBDal.getInstance().refresh(journal);
-      Date date = journal.getDocumentDate();
 
       // Complete the Journal
       if ("CO".equals(docAction)) {
@@ -146,6 +133,13 @@
       if (cont > 0) {
         msg.setMessage(" @FIN_NumberOfPayments@: " + cont);
       }
+      if (!"".equals(relatedPayments) && "RE".equals(docAction)) {
+        relatedPayments = relatedPayments.substring(0, relatedPayments.length() - 2);
+        msg.setType("Warning");
+        msg.setTitle("@Success@");
+        msg.setMessage("@Warning@: @FIN_JournalLineRelatedPayments@: " + relatedPayments
+            + ". @ModifyGLJournalLine@");
+      }
       bundle.setResult(msg);
       OBDal.getInstance().commitAndClose();
     } catch (final OBException e) {
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Mon Jul 27 19:05:39 2015 +0200
@@ -283,10 +283,6 @@
     DocumentType outDocType = null;
     Client client = null;
 
-    OBCriteria<DocumentType> obcDoc = OBDal.getInstance().createCriteria(DocumentType.class);
-    obcDoc.setFilterOnReadableClients(false);
-    obcDoc.setFilterOnReadableOrganization(false);
-
     if ("0".equals(org.getId())) {
       client = OBContext.getOBContext().getCurrentClient();
       if ("0".equals(client.getId())) {
@@ -295,18 +291,29 @@
     } else {
       client = org.getClient();
     }
-    obcDoc.add(Restrictions.eq(DocumentType.PROPERTY_CLIENT, client));
 
-    obcDoc
-        .add(Restrictions.in("organization.id",
-            OBContext.getOBContext().getOrganizationStructureProvider(org.getClient().getId())
-                .getParentTree(org.getId(), true)));
-    obcDoc.add(Restrictions.eq(DocumentType.PROPERTY_DOCUMENTCATEGORY, docCategory));
-    obcDoc.addOrderBy(DocumentType.PROPERTY_DEFAULT, false);
-    obcDoc.addOrderBy(DocumentType.PROPERTY_ID, false);
-    List<DocumentType> docTypeList = obcDoc.list();
-    if (docTypeList != null && docTypeList.size() > 0) {
-      outDocType = docTypeList.get(0);
+    OBContext.setAdminMode(false);
+    try {
+      StringBuilder whereOrderByClause = new StringBuilder();
+      whereOrderByClause.append(" as dt where dt.organization.id in (");
+      whereOrderByClause.append(Utility.getInStrSet(new OrganizationStructureProvider()
+          .getParentTree(org.getId(), true)));
+      whereOrderByClause.append(") and dt.client.id = '" + client.getId()
+          + "' and dt.documentCategory = '" + docCategory + "' order by ad_isorgincluded('"
+          + org.getId() + "', dt.organization.id, '" + client.getId()
+          + "') , dt.default desc, dt.id desc");
+      OBQuery<DocumentType> dt = OBDal.getInstance().createQuery(DocumentType.class,
+          whereOrderByClause.toString());
+      dt.setFilterOnReadableClients(false);
+      dt.setFilterOnReadableOrganization(false);
+      dt.setMaxResult(1);
+
+      List<DocumentType> dtList = dt.list();
+      if (dtList != null && !dtList.isEmpty()) {
+        outDocType = dtList.get(0);
+      }
+    } finally {
+      OBContext.restorePreviousMode();
     }
     return outDocType;
   }
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-api-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-config-api-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-config-impl-base-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-container-impl-base-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-container-spi-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-container-test-api-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-container-test-impl-base-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-container-test-spi-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-core-api-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-core-impl-base-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-core-spi-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-impl-base-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-junit-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-junit-container-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-junit-core-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-protocol-local-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-spi-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-test-api-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-test-impl-base-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-test-spi-1.1.8.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-testenricher-cdi-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-testenricher-cdi-1.0.2.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-weld-ee-embedded-1.1-1.0.0.Alpha4.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/arquillian-weld-ee-embedded-1.1-1.0.0.CR8.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/jboss-el-api_2.2_spec-1.0.0.Final.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-api-1.0.0-alpha-11.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-api-1.2.2.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-descriptors-api-base-2.0.0-alpha-7.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-descriptors-spi-2.0.0-alpha-7.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-extension-classloader-1.0.0-alpha-11.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-impl-base-1.0.0-alpha-11.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-impl-base-1.2.2.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-spi-1.0.0-alpha-11.jar has changed
Binary file modules/org.openbravo.base.weld/lib/test/shrinkwrap-spi-1.2.2.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/ParameterCdiTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,39 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines which field in a cdi test class will take the parameter values set by
+ * {@link ParameterCdiTestRule}. There should be a single field with this annotation per class.
+ * 
+ * @see ParameterCdiTestRule
+ * 
+ * @author alostale
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.FIELD })
+public @interface ParameterCdiTest {
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/ParameterCdiTestRule.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,103 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Rule to make possible to run parameterized test cases with Arquillian runner. The Rule field
+ * defines the parameter values which will be taken by the field annotated with @ParameterCdiTest.
+ * 
+ * Based on https://gist.github.com/poolik/8764414
+ * 
+ * @see ParameterCdiTest
+ * 
+ * @author alostale
+ */
+public class ParameterCdiTestRule<T> implements MethodRule {
+  private final List<T> params;
+  private static final Logger log = LoggerFactory.getLogger(ParameterCdiTestRule.class);
+
+  public ParameterCdiTestRule(List<T> params) {
+    if (params == null || params.size() == 0) {
+      throw new IllegalArgumentException(
+          "'params' must be specified and have more than zero length!");
+    }
+    this.params = params;
+  }
+
+  @Override
+  public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
+    return new Statement() {
+      @Override
+      public void evaluate() throws Throwable {
+        evaluateParamsToTarget(base, target, method);
+      }
+    };
+  }
+
+  private void evaluateParamsToTarget(Statement base, Object target, FrameworkMethod method)
+      throws Throwable {
+    Field targetField = getTargetField(target);
+    if (!targetField.isAccessible()) {
+      targetField.setAccessible(true);
+    }
+
+    for (Object param : params) {
+      targetField.set(target, param);
+
+      log.info(
+          "============================================================================================================");
+      log.info("   Paremeterized test {}.{} ", target.getClass().getName(), method.getName());
+      log.info("       {}: {}", targetField.getName(), param);
+      log.info(
+          "============================================================================================================");
+
+      base.evaluate();
+    }
+  }
+
+  private Field getTargetField(Object target) throws NoSuchFieldException {
+    Field[] allFields = target.getClass().getDeclaredFields();
+    Field paramField = null;
+    for (Field field : allFields) {
+      if (field.getAnnotation(ParameterCdiTest.class) != null) {
+        if (paramField != null) {
+          throw new IllegalStateException(
+              "More than one field with @ParameterCdiTest. There should be a single @ParameterCdiTest field.");
+        }
+
+        paramField = field;
+      }
+    }
+    if (paramField == null) {
+      throw new IllegalStateException(
+          "No field with @ParameterCdiTest annotation found. There should be a single @ParameterCdiTest field.");
+    }
+    return paramField;
+  }
+}
\ No newline at end of file
--- a/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/WeldBaseTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2010-2014 Openbravo SLU
+ * All portions are Copyright (C) 2010-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -24,16 +24,23 @@
 import javax.enterprise.util.AnnotationLiteral;
 import javax.inject.Inject;
 
-import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
 import org.jboss.shrinkwrap.api.importer.ExplodedImporter;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.After;
+import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.openbravo.base.session.OBPropertiesProvider;
+import org.openbravo.base.session.SessionFactoryController;
+import org.openbravo.base.weld.WeldUtils;
+import org.openbravo.client.kernel.KernelInitializer;
+import org.openbravo.dal.core.OBInterceptor;
 import org.openbravo.test.base.OBBaseTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Base test for weld, provides access to the weld container.
@@ -42,14 +49,34 @@
  */
 @RunWith(Arquillian.class)
 public class WeldBaseTest extends OBBaseTest {
+  private static final Logger log = LoggerFactory.getLogger(WeldBaseTest.class);
+
+  private static boolean initialized = false;
+  private static JavaArchive archive = null;
 
   @Deployment
   public static JavaArchive createTestArchive() {
-    final String sourcePath = OBPropertiesProvider.getInstance().getOpenbravoProperties()
-        .getProperty("source.path");
-    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
-    archive.as(ExplodedImporter.class).importDirectory(sourcePath + "/build/classes");
-    archive.addDirectory(sourcePath + "/WebContent/WEB-INF/lib");
+    if (archive == null) {
+      log.info("Creating cdi archive...");
+      final String sourcePath = OBPropertiesProvider.getInstance().getOpenbravoProperties()
+          .getProperty("source.path");
+      archive = ShrinkWrap.create(JavaArchive.class);
+
+      // add all beans without exclusions so cdi can also be used for *test* packages
+      archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+      // include all classes deployed in webapp container
+      archive.as(ExplodedImporter.class).importDirectory(sourcePath + "/build/classes/");
+
+      // ...and all the jUnit ones
+      archive.as(ExplodedImporter.class).importDirectory(sourcePath + "/src-test/build/classes/");
+
+      // include all libraries deployed in webapp container
+      archive.addAsDirectory(sourcePath + "/WebContent/WEB-INF/lib");
+
+      log.debug(archive.toString(true));
+      log.info("... cdi archive created");
+    }
     return archive;
   }
 
@@ -60,6 +87,39 @@
   @Inject
   private BeanManager beanManager;
 
+  @Inject
+  private KernelInitializer kernelInitializer;
+
+  /**
+   * Sets static instance bean manager in WeldUtils so it is globally accessible and initializes
+   * kernel.
+   * 
+   * Arquillian creates a new cdi container for each test class but keeps existent one for all tests
+   * within same class, let's initialize it once per class but we cannot use @BeforeClass at this
+   * point because we require of beanManager to be injected.
+   */
+  @Before
+  public void setManager() {
+    if (!initialized) {
+      WeldUtils.setStaticInstanceBeanManager(beanManager);
+      kernelInitializer.setInterceptor();
+      initialized = true;
+    }
+  }
+
+  /**
+   * Once we are done with the class execution, OBInterceptor needs to be reset other case when
+   * executing a suite it will reuse the container created for the previous classes instead of the
+   * new one.
+   */
+  @AfterClass
+  public static void resetOBInterceptors() {
+    final OBInterceptor interceptor = (OBInterceptor) SessionFactoryController.getInstance()
+        .getConfiguration().getInterceptor();
+    interceptor.setInterceptorListener(null);
+    initialized = false;
+  }
+
   @SuppressWarnings("unchecked")
   protected <U extends Object> U getWeldComponent(Class<U> clz) {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/ApplicationScopedBean.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,36 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test.testinfrastructure;
+
+import javax.enterprise.context.ApplicationScoped;
+
+/** Simple application scoped bean */
+@ApplicationScoped
+public class ApplicationScopedBean {
+  private String value;
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+
+  public String getValue() {
+    return value;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/CdiInfrastructure.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,80 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test.testinfrastructure;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.junit.InSequence;
+import org.junit.Test;
+import org.openbravo.base.weld.test.WeldBaseTest;
+
+/**
+ * Test cases for cdi infrastructure. Checking Arquillian works fine and it is possible to inject
+ * beans.
+ * 
+ * @author alostale
+ *
+ */
+public class CdiInfrastructure extends WeldBaseTest {
+
+  @Inject
+  private ApplicationScopedBean applicationBean;
+
+  @Inject
+  private SessionScopedBean sessionBean;
+
+  @Inject
+  private RequestScopedBean requestBean;
+
+  /** beans are correctly injected */
+  @Test
+  public void beansAreInjected() {
+    assertThat("application bean is injected", applicationBean, notNullValue());
+    assertThat("session bean is injected", sessionBean, notNullValue());
+    assertThat("request bean is injected", requestBean, notNullValue());
+  }
+
+  /** starts application and session scopes */
+  @Test
+  @InSequence(1)
+  public void start() {
+    applicationBean.setValue("application");
+    sessionBean.setValue("session");
+    requestBean.setValue("request");
+
+    assertThat(applicationBean.getValue(), equalTo("application"));
+    assertThat(sessionBean.getValue(), equalTo("session"));
+    assertThat(requestBean.getValue(), equalTo("request"));
+  }
+
+  /** application and session scopes are preserved but not request scope */
+  @Test
+  @InSequence(2)
+  public void applicationAndSessionShouldBeKept() {
+    assertThat(applicationBean.getValue(), equalTo("application"));
+    assertThat(sessionBean.getValue(), equalTo("session"));
+    assertThat(requestBean.getValue(), nullValue());
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/DalPersistanceEventTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,65 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test.testinfrastructure;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.weld.test.WeldBaseTest;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.common.geography.Country;
+
+/**
+ * Persistance observers require of cdi. Test cases covering observers are executed when using
+ * WeldBaseTest.
+ * 
+ * @author alostale
+ *
+ */
+public class DalPersistanceEventTest extends WeldBaseTest {
+  @Rule
+  public ExpectedException exception = ExpectedException.none();
+
+  @Test
+  public void persisntaceObserversShouldBeExecuted() {
+    try {
+      setSystemAdministratorContext();
+      Country newCountry = OBProvider.getInstance().get(Country.class);
+      newCountry.setName("Wonderland");
+      newCountry.setISOCountryCode("WL");
+      newCountry.setAddressPrintFormat("-");
+
+      newCountry.setDateformat("invalid date format");
+
+      // expecting exception thrown by by persistance observer, it will be thrown only if it is
+      // executed
+      exception.expect(OBException.class);
+      exception.expectMessage(OBMessageUtils.messageBD("InvalidDateFormat"));
+
+      OBDal.getInstance().save(newCountry);
+      OBDal.getInstance().flush();
+    } finally {
+      OBDal.getInstance().rollbackAndClose();
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/ParameterizedCdi.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,88 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test.testinfrastructure;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.openbravo.base.weld.test.ParameterCdiTest;
+import org.openbravo.base.weld.test.ParameterCdiTestRule;
+import org.openbravo.base.weld.test.WeldBaseTest;
+
+/**
+ * Test cases checking test case parameterization with cdi.
+ * 
+ * @author alostale
+ *
+ */
+public class ParameterizedCdi extends WeldBaseTest {
+  public static final List<String> PARAMS = Arrays.asList("param1", "param2", "param3");
+
+  /** defines the values the parameter will take. */
+  @Rule
+  public ParameterCdiTestRule<String> parameterValuesRule = new ParameterCdiTestRule<String>(
+      PARAMS);
+
+  /** this field will take the values defined by parameterValuesRule field. */
+  private @ParameterCdiTest String parameter;
+
+  private static int counterTest1 = 0;
+  private static int counterTest2 = 0;
+  private static String test1Execution = "";
+  private static String test2Execution = "";
+
+  /** Test case to be executed once per parameter value */
+  @Test
+  public void test1() {
+    assertThat("parameter value", parameter, equalTo(PARAMS.get(counterTest1)));
+    counterTest1++;
+    test1Execution += parameter;
+  }
+
+  /** Test case to be executed once per parameter value */
+  @Test
+  public void test2() {
+    assertThat("parameter value", parameter, equalTo(PARAMS.get(counterTest2)));
+
+    counterTest2++;
+    test2Execution += parameter;
+  }
+
+  /** Checks the previous test cases were executed as many times as parameter values in the list. */
+  @AfterClass
+  public static void testsShouldBeExecutedOncePerParameter() {
+    String expectedValue = "";
+    for (String paramValue : PARAMS) {
+      expectedValue += paramValue;
+    }
+    assertThat("# of executions for test 1", PARAMS.size(), is(counterTest1));
+    assertThat("# of executions for test 2", PARAMS.size(), is(counterTest2));
+
+    assertThat("test 1 result", test1Execution, equalTo(expectedValue));
+    assertThat("test 2 result", test2Execution, equalTo(expectedValue));
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/RequestScopedBean.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,36 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test.testinfrastructure;
+
+import javax.enterprise.context.RequestScoped;
+
+/** Simple request scoped bean */
+@RequestScoped
+public class RequestScopedBean {
+  private String value;
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+
+  public String getValue() {
+    return value;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.base.weld/src-test/org/openbravo/base/weld/test/testinfrastructure/SessionScopedBean.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,40 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2015 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.weld.test.testinfrastructure;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+
+/** Simple session scoped bean */
+@SuppressWarnings("serial")
+@SessionScoped
+public class SessionScopedBean implements Serializable {
+  private String value;
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+
+  public String getValue() {
+    return value;
+  }
+
+}
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_FIELD.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -65,6 +65,14 @@
         <default><![CDATA[D]]></default>
         <onCreateDefault><![CDATA['D']]></onCreateDefault>
       </column>
+      <column name="ISFKDROPDOWNUNFILTERED" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <onCreateDefault/>
+      </column>
+      <column name="DISABLEFKCOMBO" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_FIELD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_SYSTEM.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_SYSTEM.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -61,6 +61,14 @@
         <default><![CDATA[Y]]></default>
         <onCreateDefault><![CDATA['Y']]></onCreateDefault>
       </column>
+      <column name="ISFKDROPDOWNUNFILTERED" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
+      <column name="DISABLEFKCOMBO" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_SYSTEM_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
@@ -70,9 +78,11 @@
       <unique name="OBUIAPP_GC_SYS_UNIQUE_CLIENT">
         <unique-column name="AD_CLIENT_ID"/>
       </unique>
+      <check name="OBUIAPP_GC_SYS_DISCOMBO_CHK"><![CDATA[DISABLEFKCOMBO IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_GC_SYS_ISFILT_CHK"><![CDATA[ISFILTERABLE IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_GC_SYS_ISLAZY_CHK"><![CDATA[ISLAZYFILTERING IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_GC_SYS_ISSORT_CHK"><![CDATA[ISSORTABLE IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_GC_SYS_ONCHNG_CHK"><![CDATA[FILTERONCHANGE IN ('Y', 'N')]]></check>
+      <check name="OBUIAPP_GC_SYS_UNFILTDD_CHK"><![CDATA[ISFKDROPDOWNUNFILTERED IN ('Y', 'N')]]></check>
     </table>
   </database>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_GC_TAB.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -65,6 +65,14 @@
         <default><![CDATA[D]]></default>
         <onCreateDefault><![CDATA['D']]></onCreateDefault>
       </column>
+      <column name="ISFKDROPDOWNUNFILTERED" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <onCreateDefault/>
+      </column>
+      <column name="DISABLEFKCOMBO" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[D]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_GC_TAB_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -180,6 +180,42 @@
 <!--01F2D2DBBDA14758982AA7386FA8FF72-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--01F2D2DBBDA14758982AA7386FA8FF72--></AD_COLUMN>
 
+<!--02CB84907EA844568D4CE3597E1D6C69--><AD_COLUMN>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_COLUMN_ID><![CDATA[02CB84907EA844568D4CE3597E1D6C69]]></AD_COLUMN_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <NAME><![CDATA[DisableFkCombo]]></NAME>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <COLUMNNAME><![CDATA[Disablefkcombo]]></COLUMNNAME>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_TABLE_ID><![CDATA[5D50320222DD4865ADFD50364C84291D]]></AD_TABLE_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <SEQNO><![CDATA[170]]></SEQNO>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_ELEMENT_ID><![CDATA[1185A82966EA40ABA990B5DDBD9B8FBA]]></AD_ELEMENT_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <POSITION><![CDATA[17]]></POSITION>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--02CB84907EA844568D4CE3597E1D6C69-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--02CB84907EA844568D4CE3597E1D6C69--></AD_COLUMN>
+
 <!--03BD4945FDC64CF5AB4CD37BE6A74F81--><AD_COLUMN>
 <!--03BD4945FDC64CF5AB4CD37BE6A74F81-->  <AD_COLUMN_ID><![CDATA[03BD4945FDC64CF5AB4CD37BE6A74F81]]></AD_COLUMN_ID>
 <!--03BD4945FDC64CF5AB4CD37BE6A74F81-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2470,6 +2506,42 @@
 <!--40BF5714171243E0BF9928C4D08E1B17-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--40BF5714171243E0BF9928C4D08E1B17--></AD_COLUMN>
 
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2--><AD_COLUMN>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_COLUMN_ID><![CDATA[40C3D2FBF24A4094B5061F1D6F64C8D2]]></AD_COLUMN_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <NAME><![CDATA[IsFkDropDownUnfiltered]]></NAME>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <COLUMNNAME><![CDATA[Isfkdropdownunfiltered]]></COLUMNNAME>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_TABLE_ID><![CDATA[5D50320222DD4865ADFD50364C84291D]]></AD_TABLE_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <SEQNO><![CDATA[160]]></SEQNO>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <POSITION><![CDATA[16]]></POSITION>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--40C3D2FBF24A4094B5061F1D6F64C8D2--></AD_COLUMN>
+
 <!--416B600071A3481FAFF4B9CE6EB2B991--><AD_COLUMN>
 <!--416B600071A3481FAFF4B9CE6EB2B991-->  <AD_COLUMN_ID><![CDATA[416B600071A3481FAFF4B9CE6EB2B991]]></AD_COLUMN_ID>
 <!--416B600071A3481FAFF4B9CE6EB2B991-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2506,6 +2578,43 @@
 <!--416B600071A3481FAFF4B9CE6EB2B991-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--416B600071A3481FAFF4B9CE6EB2B991--></AD_COLUMN>
 
+<!--4651E1FC435744898055E3BE4D2F9A88--><AD_COLUMN>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_COLUMN_ID><![CDATA[4651E1FC435744898055E3BE4D2F9A88]]></AD_COLUMN_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <NAME><![CDATA[IsFkDropDownUnfiltered]]></NAME>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <COLUMNNAME><![CDATA[Isfkdropdownunfiltered]]></COLUMNNAME>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_TABLE_ID><![CDATA[8A16662B37184121A1EDAA89890E160C]]></AD_TABLE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <SEQNO><![CDATA[180]]></SEQNO>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <POSITION><![CDATA[17]]></POSITION>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--4651E1FC435744898055E3BE4D2F9A88-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--4651E1FC435744898055E3BE4D2F9A88--></AD_COLUMN>
+
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE--><AD_COLUMN>
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE-->  <AD_COLUMN_ID><![CDATA[4737ABA46AA14ACAB3BF0D8DB72F3EFE]]></AD_COLUMN_ID>
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -2542,6 +2651,43 @@
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--4737ABA46AA14ACAB3BF0D8DB72F3EFE--></AD_COLUMN>
 
+<!--48A069D3607C4ACEA7ACCBA679A00B75--><AD_COLUMN>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_COLUMN_ID><![CDATA[48A069D3607C4ACEA7ACCBA679A00B75]]></AD_COLUMN_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <NAME><![CDATA[IsFkDropdownUnfiltered]]></NAME>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <COLUMNNAME><![CDATA[Isfkdropdownunfiltered]]></COLUMNNAME>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_TABLE_ID><![CDATA[F167EB822B8A4284AC37D5B40B785D51]]></AD_TABLE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <SEQNO><![CDATA[190]]></SEQNO>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <POSITION><![CDATA[17]]></POSITION>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--48A069D3607C4ACEA7ACCBA679A00B75-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--48A069D3607C4ACEA7ACCBA679A00B75--></AD_COLUMN>
+
 <!--48FAAFCA11A143169FD7517D67531DD1--><AD_COLUMN>
 <!--48FAAFCA11A143169FD7517D67531DD1-->  <AD_COLUMN_ID><![CDATA[48FAAFCA11A143169FD7517D67531DD1]]></AD_COLUMN_ID>
 <!--48FAAFCA11A143169FD7517D67531DD1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -3153,6 +3299,43 @@
 <!--59E3FEE1ADB04DE9B889A4957BFB0438-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--59E3FEE1ADB04DE9B889A4957BFB0438--></AD_COLUMN>
 
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED--><AD_COLUMN>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_COLUMN_ID><![CDATA[5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED]]></AD_COLUMN_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <NAME><![CDATA[DisableFkCombo]]></NAME>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <COLUMNNAME><![CDATA[Disablefkcombo]]></COLUMNNAME>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_TABLE_ID><![CDATA[8A16662B37184121A1EDAA89890E160C]]></AD_TABLE_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <SEQNO><![CDATA[190]]></SEQNO>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_ELEMENT_ID><![CDATA[1185A82966EA40ABA990B5DDBD9B8FBA]]></AD_ELEMENT_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <POSITION><![CDATA[18]]></POSITION>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED--></AD_COLUMN>
+
 <!--5A92EE4131964B91857B07942228E4A5--><AD_COLUMN>
 <!--5A92EE4131964B91857B07942228E4A5-->  <AD_COLUMN_ID><![CDATA[5A92EE4131964B91857B07942228E4A5]]></AD_COLUMN_ID>
 <!--5A92EE4131964B91857B07942228E4A5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -3578,6 +3761,43 @@
 <!--6544F25DBDE74A9CB66C8E27F909556E-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--6544F25DBDE74A9CB66C8E27F909556E--></AD_COLUMN>
 
+<!--669F7189A86E4EBEB78165527CC81658--><AD_COLUMN>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_COLUMN_ID><![CDATA[669F7189A86E4EBEB78165527CC81658]]></AD_COLUMN_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--669F7189A86E4EBEB78165527CC81658-->  <NAME><![CDATA[DisableFkCombo]]></NAME>
+<!--669F7189A86E4EBEB78165527CC81658-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--669F7189A86E4EBEB78165527CC81658-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--669F7189A86E4EBEB78165527CC81658-->  <COLUMNNAME><![CDATA[Disablefkcombo]]></COLUMNNAME>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_TABLE_ID><![CDATA[F167EB822B8A4284AC37D5B40B785D51]]></AD_TABLE_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_REFERENCE_VALUE_ID><![CDATA[892231CFE03848758D74B0209B801C14]]></AD_REFERENCE_VALUE_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH>
+<!--669F7189A86E4EBEB78165527CC81658-->  <DEFAULTVALUE><![CDATA[D]]></DEFAULTVALUE>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--669F7189A86E4EBEB78165527CC81658-->  <SEQNO><![CDATA[200]]></SEQNO>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_ELEMENT_ID><![CDATA[1185A82966EA40ABA990B5DDBD9B8FBA]]></AD_ELEMENT_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--669F7189A86E4EBEB78165527CC81658-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--669F7189A86E4EBEB78165527CC81658-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--669F7189A86E4EBEB78165527CC81658-->  <POSITION><![CDATA[18]]></POSITION>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--669F7189A86E4EBEB78165527CC81658-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--669F7189A86E4EBEB78165527CC81658-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--669F7189A86E4EBEB78165527CC81658-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--669F7189A86E4EBEB78165527CC81658--></AD_COLUMN>
+
 <!--6ABD7441749B401D9C0504DDDF8FB7CA--><AD_COLUMN>
 <!--6ABD7441749B401D9C0504DDDF8FB7CA-->  <AD_COLUMN_ID><![CDATA[6ABD7441749B401D9C0504DDDF8FB7CA]]></AD_COLUMN_ID>
 <!--6ABD7441749B401D9C0504DDDF8FB7CA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -94,6 +94,20 @@
 <!--10922048465547F48765035389E22977-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--10922048465547F48765035389E22977--></AD_ELEMENT>
 
+<!--1185A82966EA40ABA990B5DDBD9B8FBA--><AD_ELEMENT>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <AD_ELEMENT_ID><![CDATA[1185A82966EA40ABA990B5DDBD9B8FBA]]></AD_ELEMENT_ID>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <COLUMNNAME><![CDATA[Disablefkcombo]]></COLUMNNAME>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <NAME><![CDATA[Disable Foreign Key Combo]]></NAME>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <PRINTNAME><![CDATA[Disable Foreign Key Filter Combo]]></PRINTNAME>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--1185A82966EA40ABA990B5DDBD9B8FBA--></AD_ELEMENT>
+
 <!--18EA6EC150C545AE8C5E0A3BD4BD4871--><AD_ELEMENT>
 <!--18EA6EC150C545AE8C5E0A3BD4BD4871-->  <AD_ELEMENT_ID><![CDATA[18EA6EC150C545AE8C5E0A3BD4BD4871]]></AD_ELEMENT_ID>
 <!--18EA6EC150C545AE8C5E0A3BD4BD4871-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -133,6 +147,20 @@
 <!--1DD68F7AE78B4F0EB010F507D4B7A0D4-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--1DD68F7AE78B4F0EB010F507D4B7A0D4--></AD_ELEMENT>
 
+<!--2D51BCE155184D34A5F38FFE515D5C23--><AD_ELEMENT>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_ELEMENT_ID><![CDATA[2D51BCE155184D34A5F38FFE515D5C23]]></AD_ELEMENT_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <COLUMNNAME><![CDATA[IsFkDropDownUnfiltered]]></COLUMNNAME>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <NAME><![CDATA[Unfiltered Foreign Key Combo]]></NAME>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <PRINTNAME><![CDATA[Is FK Dropdown Unfiltered]]></PRINTNAME>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--2D51BCE155184D34A5F38FFE515D5C23-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--2D51BCE155184D34A5F38FFE515D5C23--></AD_ELEMENT>
+
 <!--31DCDECE67A34C418930D50405D8057D--><AD_ELEMENT>
 <!--31DCDECE67A34C418930D50405D8057D-->  <AD_ELEMENT_ID><![CDATA[31DCDECE67A34C418930D50405D8057D]]></AD_ELEMENT_ID>
 <!--31DCDECE67A34C418930D50405D8057D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -76,6 +76,7 @@
 <!--03724122C8F744FDB387B47B7907E0D3-->  <AD_COLUMN_ID><![CDATA[7E5D4C62298D4310A12AB5F28B9D2C51]]></AD_COLUMN_ID>
 <!--03724122C8F744FDB387B47B7907E0D3-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--03724122C8F744FDB387B47B7907E0D3-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--03724122C8F744FDB387B47B7907E0D3-->  <DISPLAYLOGIC><![CDATA[(@Filterable@!'N' & @Disablefkcombo@!'Y')]]></DISPLAYLOGIC>
 <!--03724122C8F744FDB387B47B7907E0D3-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
 <!--03724122C8F744FDB387B47B7907E0D3-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--03724122C8F744FDB387B47B7907E0D3-->  <SEQNO><![CDATA[120]]></SEQNO>
@@ -1361,6 +1362,34 @@
 <!--27E751EB37C841EC930FD493AB2CF64B-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--27E751EB37C841EC930FD493AB2CF64B--></AD_FIELD>
 
+<!--287DDC4447C24C03BCE538328EC5BACE--><AD_FIELD>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <AD_FIELD_ID><![CDATA[287DDC4447C24C03BCE538328EC5BACE]]></AD_FIELD_ID>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <NAME><![CDATA[Disable Foreign Key Combo]]></NAME>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <AD_TAB_ID><![CDATA[13FE911F7F684A47801DF55525BAD4A1]]></AD_TAB_ID>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <AD_COLUMN_ID><![CDATA[02CB84907EA844568D4CE3597E1D6C69]]></AD_COLUMN_ID>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <SEQNO><![CDATA[120]]></SEQNO>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--287DDC4447C24C03BCE538328EC5BACE-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--287DDC4447C24C03BCE538328EC5BACE--></AD_FIELD>
+
 <!--2C3B28510C0544BC8BDA4461AE88C486--><AD_FIELD>
 <!--2C3B28510C0544BC8BDA4461AE88C486-->  <AD_FIELD_ID><![CDATA[2C3B28510C0544BC8BDA4461AE88C486]]></AD_FIELD_ID>
 <!--2C3B28510C0544BC8BDA4461AE88C486-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -1454,6 +1483,34 @@
 <!--2FF944B417B544C8A8F8757F1C9F3E35-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--2FF944B417B544C8A8F8757F1C9F3E35--></AD_FIELD>
 
+<!--30F306CF2BCC4E11AFB3E6B8AD901289--><AD_FIELD>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <AD_FIELD_ID><![CDATA[30F306CF2BCC4E11AFB3E6B8AD901289]]></AD_FIELD_ID>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <NAME><![CDATA[Disable Foreign Key Combo]]></NAME>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <AD_TAB_ID><![CDATA[49B33DC2EDFD45A48EECE139AD5E9AC9]]></AD_TAB_ID>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <AD_COLUMN_ID><![CDATA[5A8AC3A0A48C49A7A7CFD4AEF1E2C3ED]]></AD_COLUMN_ID>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <SEQNO><![CDATA[130]]></SEQNO>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--30F306CF2BCC4E11AFB3E6B8AD901289--></AD_FIELD>
+
 <!--312B596239AF498EBAF36C1B9A54D2A8--><AD_FIELD>
 <!--312B596239AF498EBAF36C1B9A54D2A8-->  <AD_FIELD_ID><![CDATA[312B596239AF498EBAF36C1B9A54D2A8]]></AD_FIELD_ID>
 <!--312B596239AF498EBAF36C1B9A54D2A8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -3297,7 +3354,7 @@
 <!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <AD_COLUMN_ID><![CDATA[26DAD0E63D554C5FA0493765032BA0B0]]></AD_COLUMN_ID>
 <!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <DISPLAYLOGIC><![CDATA[@IsLazyFiltering@='N'|(@IsLazyFiltering@='D'&@LazyFilteringSystemLevel@!'Y')]]></DISPLAYLOGIC>
+<!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <DISPLAYLOGIC><![CDATA[(@Filterable@!'N' & (@IsLazyFiltering@='N'|(@IsLazyFiltering@='D'&@LazyFilteringSystemLevel@!'Y')))]]></DISPLAYLOGIC>
 <!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--8E267DE7CA7E4C849CD0CF14C5E7AC25-->  <SEQNO><![CDATA[100]]></SEQNO>
@@ -3341,6 +3398,35 @@
 <!--8E499D659EDA4527B7E179CC4C065F04-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--8E499D659EDA4527B7E179CC4C065F04--></AD_FIELD>
 
+<!--90A8FCE2F0674325863B3F793AB79601--><AD_FIELD>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_FIELD_ID><![CDATA[90A8FCE2F0674325863B3F793AB79601]]></AD_FIELD_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <NAME><![CDATA[Unfiltered Foreign Key Combo]]></NAME>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_TAB_ID><![CDATA[D26230D6D21546C6970E79FF1C51165E]]></AD_TAB_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_COLUMN_ID><![CDATA[48A069D3607C4ACEA7ACCBA679A00B75]]></AD_COLUMN_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <DISPLAYLOGIC><![CDATA[(@Filterable@!'N' & @Disablefkcombo@!'Y')]]></DISPLAYLOGIC>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <SEQNO><![CDATA[130]]></SEQNO>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--90A8FCE2F0674325863B3F793AB79601-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--90A8FCE2F0674325863B3F793AB79601--></AD_FIELD>
+
 <!--92EDD1AEF5B545648BB0F8FE550ACF67--><AD_FIELD>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <AD_FIELD_ID><![CDATA[92EDD1AEF5B545648BB0F8FE550ACF67]]></AD_FIELD_ID>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -3354,7 +3440,7 @@
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <AD_COLUMN_ID><![CDATA[B85EDCE11C844C52904C24B4246BE515]]></AD_COLUMN_ID>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <DISPLAYLOGIC><![CDATA[@IsLazyFiltering@='N'|(@IsLazyFiltering@='D'&@LazyFilteringSystemLevel@!'Y')]]></DISPLAYLOGIC>
+<!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <DISPLAYLOGIC><![CDATA[(@Filterable@!'N' & (@IsLazyFiltering@='N'|(@IsLazyFiltering@='D'&@LazyFilteringSystemLevel@!'Y')))]]></DISPLAYLOGIC>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <DISPLAYLENGTH><![CDATA[2]]></DISPLAYLENGTH>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--92EDD1AEF5B545648BB0F8FE550ACF67-->  <SEQNO><![CDATA[110]]></SEQNO>
@@ -3803,6 +3889,7 @@
 <!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <AD_COLUMN_ID><![CDATA[F3D26B0C148D474BB6339A824DA96645]]></AD_COLUMN_ID>
 <!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <DISPLAYLOGIC><![CDATA[@Filterable@!'N']]></DISPLAYLOGIC>
 <!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
 <!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--A8B5F8D379694A84B2AA2C77E11C76BF-->  <SEQNO><![CDATA[70]]></SEQNO>
@@ -4662,6 +4749,34 @@
 <!--D6FC282E5E614AED8C301C8FEC0436FB-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--D6FC282E5E614AED8C301C8FEC0436FB--></AD_FIELD>
 
+<!--D8A9991BA87645D987BA8B8C9B1C956F--><AD_FIELD>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_FIELD_ID><![CDATA[D8A9991BA87645D987BA8B8C9B1C956F]]></AD_FIELD_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <NAME><![CDATA[Unfiltered Foreign Key Combo]]></NAME>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_TAB_ID><![CDATA[13FE911F7F684A47801DF55525BAD4A1]]></AD_TAB_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_COLUMN_ID><![CDATA[40C3D2FBF24A4094B5061F1D6F64C8D2]]></AD_COLUMN_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <SEQNO><![CDATA[110]]></SEQNO>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--D8A9991BA87645D987BA8B8C9B1C956F-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--D8A9991BA87645D987BA8B8C9B1C956F--></AD_FIELD>
+
 <!--D9056C5C10E548E1B9BB5FAC9B61AA1B--><AD_FIELD>
 <!--D9056C5C10E548E1B9BB5FAC9B61AA1B-->  <AD_FIELD_ID><![CDATA[D9056C5C10E548E1B9BB5FAC9B61AA1B]]></AD_FIELD_ID>
 <!--D9056C5C10E548E1B9BB5FAC9B61AA1B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4948,6 +5063,35 @@
 <!--E471F143087943A198BA43A95636E996-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--E471F143087943A198BA43A95636E996--></AD_FIELD>
 
+<!--E649C05D297F48C3B55C8F93991AE2C5--><AD_FIELD>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <AD_FIELD_ID><![CDATA[E649C05D297F48C3B55C8F93991AE2C5]]></AD_FIELD_ID>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <NAME><![CDATA[Disable Foreign Key Combo]]></NAME>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <DESCRIPTION><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></DESCRIPTION>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <HELP><![CDATA[If this flag is checked, the foreign key combo will be disabled and the column will be filtered like a standard text column]]></HELP>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <AD_TAB_ID><![CDATA[D26230D6D21546C6970E79FF1C51165E]]></AD_TAB_ID>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <AD_COLUMN_ID><![CDATA[669F7189A86E4EBEB78165527CC81658]]></AD_COLUMN_ID>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <DISPLAYLOGIC><![CDATA[@Filterable@!'N']]></DISPLAYLOGIC>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <SEQNO><![CDATA[115]]></SEQNO>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--E649C05D297F48C3B55C8F93991AE2C5-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--E649C05D297F48C3B55C8F93991AE2C5--></AD_FIELD>
+
 <!--E78C1117FDE742F8A566278AD2E0591C--><AD_FIELD>
 <!--E78C1117FDE742F8A566278AD2E0591C-->  <AD_FIELD_ID><![CDATA[E78C1117FDE742F8A566278AD2E0591C]]></AD_FIELD_ID>
 <!--E78C1117FDE742F8A566278AD2E0591C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -5179,6 +5323,34 @@
 <!--F684BC3FC0E64CFFA0D0A57A926DC043-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--F684BC3FC0E64CFFA0D0A57A926DC043--></AD_FIELD>
 
+<!--F71536CBC10F40BAAC048E466C2E8916--><AD_FIELD>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_FIELD_ID><![CDATA[F71536CBC10F40BAAC048E466C2E8916]]></AD_FIELD_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <NAME><![CDATA[Unfiltered Foreign Key Combo]]></NAME>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <DESCRIPTION><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table.]]></DESCRIPTION>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <HELP><![CDATA[If this flag if checked, the filter drop down will show the rows from the referenced table unfiltered by specific rows being referenced in the referencing table. The filters entered by the user in the grid filter editor will be applied.]]></HELP>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_TAB_ID><![CDATA[49B33DC2EDFD45A48EECE139AD5E9AC9]]></AD_TAB_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_COLUMN_ID><![CDATA[4651E1FC435744898055E3BE4D2F9A88]]></AD_COLUMN_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <SEQNO><![CDATA[120]]></SEQNO>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--F71536CBC10F40BAAC048E466C2E8916-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--F71536CBC10F40BAAC048E466C2E8916--></AD_FIELD>
+
 <!--F885A0CC89634D07A19F99F762702658--><AD_FIELD>
 <!--F885A0CC89634D07A19F99F762702658-->  <AD_FIELD_ID><![CDATA[F885A0CC89634D07A19F99F762702658]]></AD_FIELD_ID>
 <!--F885A0CC89634D07A19F99F762702658-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/DynamicExpressionParserTest.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/DynamicExpressionParserTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -21,12 +21,12 @@
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
+import org.openbravo.base.weld.test.WeldBaseTest;
 import org.openbravo.client.application.DynamicExpressionParser;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.model.ad.ui.Tab;
-import org.openbravo.test.base.OBBaseTest;
 
-public class DynamicExpressionParserTest extends OBBaseTest {
+public class DynamicExpressionParserTest extends WeldBaseTest {
 
   @Test
   public void testRegularExpression() {
--- a/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/MenuTemplateTest.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src-test/org/openbravo/client/application/test/MenuTemplateTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2010-2014 Openbravo SLU
+ * All portions are Copyright (C) 2010-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -24,28 +24,29 @@
 
 import org.junit.Test;
 import org.openbravo.base.weld.test.WeldBaseTest;
-import org.openbravo.client.kernel.ApplicationComponent;
+import org.openbravo.client.application.MainLayoutComponent;
 import org.openbravo.client.kernel.JSCompressor;
 import org.openbravo.client.kernel.JSLintChecker;
 
 /**
- * Tests the generating of the menu through a template
+ * Tests the generating of the menu through a template, menu is part of the MainLayoutComponent, so
+ * it is generated within there.
  * 
  * @author mtaal
  */
 public class MenuTemplateTest extends WeldBaseTest {
 
   @Inject
-  private ApplicationComponent appMenuComponent;
+  private MainLayoutComponent mainLayoutComponent;
 
   @Test
   public void testApplication() throws Exception {
     setTestAdminContext();
-    final String javascript = appMenuComponent.generate();
+    final String javascript = mainLayoutComponent.generate();
     System.err.println(javascript);
 
     // do jslint check
-    JSLintChecker.getInstance().check(appMenuComponent.getId(), javascript);
+    JSLintChecker.getInstance().check(mainLayoutComponent.getId(), javascript);
 
     // compress
     final String compressed = JSCompressor.getInstance().compress(javascript);
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Mon Jul 27 19:05:39 2015 +0200
@@ -468,6 +468,7 @@
     globalResources.add(createStaticResource("web/js/periodControlStatus.js", true));
     globalResources.add(createStaticResource("web/js/productCharacteristicsProcess.js", true));
     globalResources.add(createStaticResource("web/js/validateCostingRuleProcess.js", true));
+    globalResources.add(createStaticResource("web/js/checkAvailableCredit.js", true));
 
     return globalResources;
   }
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewUtil.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2010-2014 Openbravo SLU
+ * All portions are Copyright (C) 2010-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -177,13 +177,16 @@
     Boolean filterOnChange = null;
     Boolean lazyFiltering = null;
     Boolean allowFkFilterByIdentifier = null;
+    Boolean showFkDropdownUnfiltered = null;
+    Boolean disableFkDropdown = null;
     String operator = null;
     Long thresholdToFilter = null;
     JSONObject result = new JSONObject();
 
     if (field != null && field.getId() != null) {
       if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-          || thresholdToFilter == null || allowFkFilterByIdentifier == null) {
+          || thresholdToFilter == null || allowFkFilterByIdentifier == null
+          || showFkDropdownUnfiltered == null || disableFkDropdown == null) {
         List<Object> fieldParams = new ArrayList<Object>();
         String fieldConfsHql = " as p where p.field.id = ? ";
         fieldParams.add(field.getId());
@@ -225,6 +228,20 @@
               allowFkFilterByIdentifier = false;
             }
           }
+          if (showFkDropdownUnfiltered == null) {
+            if ("Y".equals(fieldConfs.get(0).getIsFkDropdownUnfiltered())) {
+              showFkDropdownUnfiltered = true;
+            } else if ("N".equals(fieldConfs.get(0).getIsFkDropdownUnfiltered())) {
+              showFkDropdownUnfiltered = false;
+            }
+          }
+          if (disableFkDropdown == null) {
+            if ("Y".equals(fieldConfs.get(0).getDisableFkCombo())) {
+              disableFkDropdown = true;
+            } else if ("N".equals(fieldConfs.get(0).getDisableFkCombo())) {
+              disableFkDropdown = false;
+            }
+          }
           if (thresholdToFilter == null) {
             thresholdToFilter = fieldConfs.get(0).getThresholdToFilter();
           }
@@ -233,7 +250,8 @@
     }
 
     if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-        || thresholdToFilter == null || allowFkFilterByIdentifier == null) {
+        || thresholdToFilter == null || allowFkFilterByIdentifier == null
+        || showFkDropdownUnfiltered == null) {
       List<Object> tabParams = new ArrayList<Object>();
       String tabConfsHql = " as p where p.tab.id = ? ";
       tabParams.add(tab.getId());
@@ -282,7 +300,20 @@
             allowFkFilterByIdentifier = false;
           }
         }
-
+        if (showFkDropdownUnfiltered == null) {
+          if ("Y".equals(tabConfs.get(0).getIsFkDropDownUnfiltered())) {
+            showFkDropdownUnfiltered = true;
+          } else if ("N".equals(tabConfs.get(0).getIsFkDropDownUnfiltered())) {
+            showFkDropdownUnfiltered = false;
+          }
+        }
+        if (disableFkDropdown == null) {
+          if ("Y".equals(tabConfs.get(0).getDisableFkCombo())) {
+            disableFkDropdown = true;
+          } else if ("N".equals(tabConfs.get(0).getDisableFkCombo())) {
+            disableFkDropdown = false;
+          }
+        }
         if (thresholdToFilter == null) {
           thresholdToFilter = tabConfs.get(0).getThresholdToFilter();
         }
@@ -290,7 +321,7 @@
     }
 
     if (canSort == null || canFilter == null || operator == null || filterOnChange == null
-        || thresholdToFilter == null) {
+        || thresholdToFilter == null || showFkDropdownUnfiltered == null) {
       // Trying to get parameters from "Grid Configuration (System)" window
       List<GCSystem> sysConfs = OBDal.getInstance().createQuery(GCSystem.class, "").list();
       if (!sysConfs.isEmpty()) {
@@ -315,6 +346,12 @@
         if (allowFkFilterByIdentifier == null) {
           allowFkFilterByIdentifier = sysConfs.get(0).isAllowFilterByIdentifier();
         }
+        if (showFkDropdownUnfiltered == null) {
+          showFkDropdownUnfiltered = sysConfs.get(0).isFkDropDownUnfiltered();
+        }
+        if (disableFkDropdown == null) {
+          disableFkDropdown = sysConfs.get(0).isDisableFkCombo();
+        }
       }
     }
 
@@ -357,6 +394,12 @@
       if (allowFkFilterByIdentifier != null) {
         result.put("allowFkFilterByIdentifier", allowFkFilterByIdentifier);
       }
+      if (showFkDropdownUnfiltered != null) {
+        result.put("showFkDropdownUnfiltered", showFkDropdownUnfiltered);
+      }
+      if (disableFkDropdown != null) {
+        result.put("disableFkDropdown", disableFkDropdown);
+      }
     } catch (JSONException e) {
       log.error("Couldn't get field property value");
     }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Mon Jul 27 19:05:39 2015 +0200
@@ -76,97 +76,105 @@
 
     }
 
-    this.pickListProperties = {
-      // 'showOverAsSelected' and 'bodyKeyPress' defined here until issue 28475 be fixed.
-      // After the fix the following two lines must be removed, since it will be inherited from
-      // OBListFilterItem  as usual
-      showOverAsSelected: this.pickListProperties.showOverAsSelected,
-      bodyKeyPress: this.pickListProperties.bodyKeyPress,
+    if (this.disableFkDropdown) {
+      this.showPickerIcon = false;
+      this.showPickListOnKeypress = false;
+      if (this.filterOnChange) {
+        this.actOnKeypress = true;
+      }
+    } else {
+      this.pickListProperties = {
+        // 'showOverAsSelected' and 'bodyKeyPress' defined here until issue 28475 be fixed.
+        // After the fix the following two lines must be removed, since it will be inherited from
+        // OBListFilterItem  as usual
+        showOverAsSelected: this.pickListProperties.showOverAsSelected,
+        bodyKeyPress: this.pickListProperties.bodyKeyPress,
 
-      // make sure that we send the same parameters as the grid
-      onFetchData: function (criteria, requestProperties) {
-        var gridView = grid.view;
-        requestProperties = requestProperties || {};
-        requestProperties.params = grid.getFetchRequestParams(requestProperties.params) || {};
-        if (gridView) {
-          requestProperties.params.tabId = gridView.tabId || (grid.viewProperties && grid.viewProperties.tabId) || (gridView.sourceView && gridView.sourceView.tabId);
-          if (gridView.buttonOwnerView && gridView.buttonOwnerView.tabId) {
-            requestProperties.params.buttonOwnerViewTabId = gridView.buttonOwnerView.tabId;
+        // make sure that we send the same parameters as the grid
+        onFetchData: function (criteria, requestProperties) {
+          var gridView = grid.view;
+          requestProperties = requestProperties || {};
+          requestProperties.params = grid.getFetchRequestParams(requestProperties.params) || {};
+          if (gridView) {
+            requestProperties.params.tabId = gridView.tabId || (grid.viewProperties && grid.viewProperties.tabId) || (gridView.sourceView && gridView.sourceView.tabId);
+            if (gridView.buttonOwnerView && gridView.buttonOwnerView.tabId) {
+              requestProperties.params.buttonOwnerViewTabId = gridView.buttonOwnerView.tabId;
+            }
           }
-        }
-        // send the display field in request params to add it to the list of fields to be fetched in DefaultJsonDataService.
-        // used for displaying table references properly. Refer issue https://issues.openbravo.com/view.php?id=26696
-        if (this.formItem && this.formItem.displayProperty) {
-          requestProperties.params.displayProperty = this.formItem.displayProperty;
-        }
-        delete me.forceReload;
-      },
+          // send the display field in request params to add it to the list of fields to be fetched in DefaultJsonDataService.
+          // used for displaying table references properly. Refer issue https://issues.openbravo.com/view.php?id=26696
+          if (this.formItem && this.formItem.displayProperty) {
+            requestProperties.params.displayProperty = this.formItem.displayProperty;
+          }
+          delete me.forceReload;
+        },
 
-      // drawAllMaxCells is set to 0 to prevent extra reads of data
-      // Smartclient will try to read until drawAllMaxCells has been reached
-      drawAllMaxCells: 0,
+        // drawAllMaxCells is set to 0 to prevent extra reads of data
+        // Smartclient will try to read until drawAllMaxCells has been reached
+        drawAllMaxCells: 0,
 
-      fetchDelay: 400,
-      // prevent aggressive local filtering by smartclient
-      filterLocally: false,
-      multipleValueSeparator: ' or ',
-      dataProperties: {
-        useClientFiltering: false
-      },
+        fetchDelay: 400,
+        // prevent aggressive local filtering by smartclient
+        filterLocally: false,
+        multipleValueSeparator: ' or ',
+        dataProperties: {
+          useClientFiltering: false
+        },
 
-      isSelected: function (record) {
-        var i, values = this.formItem.getValue();
-        if (values.length) {
-          for (i = 0; i < values.length; i++) {
-            if (record[me.displayField] === values[i]) {
-              return true;
+        isSelected: function (record) {
+          var i, values = this.formItem.getValue();
+          if (values.length) {
+            for (i = 0; i < values.length; i++) {
+              if (record[me.displayField] === values[i]) {
+                return true;
+              }
+            }
+          }
+          return record[me.displayField] === values;
+        },
+
+        // override data arrived to prevent the first entry from being
+        // selected
+        // this to handle the picklist in foreign key filter item. When a user
+        // types a partial value maybe he/she wants to filter by this partial
+        // value
+        // auto-selecting the first value makes this impossible.
+        // Therefore this option to prevent this.
+        // There are maybe nicer points to do this overriding but this was the
+        // place after the first item was selected.
+        // This first selection happens in ScrollingMenu.dataChanged
+        dataArrived: function (startRow, endRow) {
+          var record, rowNum, i, values = this.formItem.getValue(),
+              fixedValues = [],
+              value;
+          this.Super('dataArrived', arguments);
+          if (values) {
+            if (!isc.isA.Array(values)) {
+              values = [values];
+            }
+
+            // fix selected values before checking them in the data to re-select them
+            for (i = 0; i < values.length; i++) {
+              value = values[i];
+              if (isc.isAn.Array(value)) {
+                value = value[0];
+              }
+              fixedValues.push(value.startsWith('==') ? value.substring(2) : value);
+            }
+
+            for (rowNum = startRow; rowNum < (endRow + 1); rowNum++) {
+              record = this.getRecord(rowNum);
+              if (record && fixedValues.contains(record[me.displayField])) {
+                // selectRecord asynchronously invokes handleChanged, this should be
+                // managed as when the value is picked from the list by pickValue
+                this.formItem._pickingArrivedValue = true;
+                this.selectRecord(record, true);
+              }
             }
           }
         }
-        return record[me.displayField] === values;
-      },
-
-      // override data arrived to prevent the first entry from being
-      // selected
-      // this to handle the picklist in foreign key filter item. When a user
-      // types a partial value maybe he/she wants to filter by this partial
-      // value
-      // auto-selecting the first value makes this impossible.
-      // Therefore this option to prevent this.
-      // There are maybe nicer points to do this overriding but this was the
-      // place after the first item was selected.
-      // This first selection happens in ScrollingMenu.dataChanged
-      dataArrived: function (startRow, endRow) {
-        var record, rowNum, i, values = this.formItem.getValue(),
-            fixedValues = [],
-            value;
-        this.Super('dataArrived', arguments);
-        if (values) {
-          if (!isc.isA.Array(values)) {
-            values = [values];
-          }
-
-          // fix selected values before checking them in the data to re-select them
-          for (i = 0; i < values.length; i++) {
-            value = values[i];
-            if (isc.isAn.Array(value)) {
-              value = value[0];
-            }
-            fixedValues.push(value.startsWith('==') ? value.substring(2) : value);
-          }
-
-          for (rowNum = startRow; rowNum < (endRow + 1); rowNum++) {
-            record = this.getRecord(rowNum);
-            if (record && fixedValues.contains(record[me.displayField])) {
-              // selectRecord asynchronously invokes handleChanged, this should be
-              // managed as when the value is picked from the list by pickValue
-              this.formItem._pickingArrivedValue = true;
-              this.selectRecord(record, true);
-            }
-          }
-        }
-      }
-    };
+      };
+    }
     dataSource = OB.Datasource.create({
       dataURL: grid.getDataSource().dataURL,
       requestProperties: {
@@ -180,6 +188,9 @@
     if (grid.Class === 'OBTreeGrid') {
       dataSource.requestProperties.params.tabId = grid.view.tabId;
     }
+    if (this.showFkDropdownUnfiltered) {
+      dataSource.requestProperties.params._showFkDropdownUnfiltered = true;
+    }
     this.setOptionDataSource(dataSource);
 
     this.Super('init', arguments);
@@ -521,10 +532,19 @@
           value = identifier;
         }
       }
-      if (criterion.operator !== "iContains" && criterion.operator !== "contains" && criterion.operator !== "regexp") {
-        if (operators[criterion.operator] && (operators[criterion.operator].ID === criterion.operator) && operators[criterion.operator].symbol && value && (value.indexOf(operators[criterion.operator].symbol) === -1)) {
+      if (this.disableFkDropdown) {
+        // if the fk dropdown is disabled then the filter must behave like a text filter
+        // that means that the symbol of the default operator is not shown
+        if (criterion.operator !== this.getOperator()) {
           value = operators[criterion.operator].symbol + value;
         }
+
+      } else {
+        if (criterion.operator !== "iContains" && criterion.operator !== "contains" && criterion.operator !== "regexp") {
+          if (operators[criterion.operator] && (operators[criterion.operator].ID === criterion.operator) && operators[criterion.operator].symbol && value && (value.indexOf(operators[criterion.operator].symbol) === -1)) {
+            value = operators[criterion.operator].symbol + value;
+          }
+        }
       }
       this.setValue(value);
     }
@@ -557,6 +577,9 @@
   },
 
   refreshPickList: function () {
+    if (this.disableFkDropdown) {
+      return;
+    }
     if (this.valueIsExpression()) {
       return;
     }
@@ -690,5 +713,12 @@
       recordIdentifier = this.filterAuxCache.find(OB.Constants.ID, id)[OB.Constants.IDENTIFIER];
     }
     return recordIdentifier;
+  },
+
+  showPickList: function () {
+    if (this.disableFkDropdown) {
+      return;
+    }
+    this.Super('showPickList', arguments);
   }
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-tree-filter.js	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2013-2014 Openbravo SLU
+ * All portions are Copyright (C) 2013-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -75,24 +75,36 @@
       sortField: this.displayField,
 
       init: function () {
+        var theGrid;
         OB.Datasource.get(this.dataSourceId, this, null, true);
-        this.copyFunctionsFromViewGrid();
+        if (this.view.paramWindow) {
+          // the checkShowFilterFunnelIcon implementation of OBPickAndExecuteGrid requires the contentView to be defined
+          theGrid = this.view.theForm.getField(this.treePopup.filterItem.containerWidget.grid.parentElement.parameterName).canvas.viewGrid;
+          this.contentView = theGrid.contentView;
+          this.copyFunctionsFromGrid(theGrid);
+        } else {
+          this.copyFunctionsFromViewGrid();
+        }
         this.Super('init', arguments);
         this.filterNoRecordsEmptyMessage = '<span class="' + this.emptyMessageStyle + '">' + OB.I18N.getLabel('OBUIAPP_GridFilterNoResults') + '</span>' + '<span onclick="window[\'' + this.ID + '\'].clearFilter();" class="' + this.emptyMessageLinkStyle + '">' + OB.I18N.getLabel('OBUIAPP_GridClearFilter') + '</span>';
       },
 
       copyFunctionsFromViewGrid: function () {
-        this.filterEditorProperties = this.view.viewGrid.filterEditorProperties;
-        this.checkShowFilterFunnelIcon = this.view.viewGrid.checkShowFilterFunnelIcon;
-        this.isGridFiltered = this.view.viewGrid.isGridFiltered;
-        this.isGridFilteredWithCriteria = this.view.viewGrid.isGridFilteredWithCriteria;
-        this.isValidFilterField = this.view.viewGrid.isValidFilterField;
-        this.convertCriteria = this.view.viewGrid.convertCriteria;
-        this.resetEmptyMessage = this.view.viewGrid.resetEmptyMessage;
-        this.filterData = this.view.viewGrid.filterData;
-        this.loadingDataMessage = this.view.viewGrid.loadingDataMessage;
-        this.emptyMessage = this.view.viewGrid.emptyMessage;
-        this.noDataEmptyMessage = this.view.viewGrid.noDataEmptyMessage;
+        this.copyFunctionsFromGrid(this.view.viewGrid);
+      },
+
+      copyFunctionsFromGrid: function (grid) {
+        this.filterEditorProperties = grid.filterEditorProperties;
+        this.checkShowFilterFunnelIcon = grid.checkShowFilterFunnelIcon;
+        this.isGridFiltered = grid.isGridFiltered;
+        this.isGridFilteredWithCriteria = grid.isGridFilteredWithCriteria;
+        this.isValidFilterField = grid.isValidFilterField;
+        this.convertCriteria = grid.convertCriteria;
+        this.resetEmptyMessage = grid.resetEmptyMessage;
+        this.filterData = grid.filterData;
+        this.loadingDataMessage = grid.loadingDataMessage;
+        this.emptyMessage = grid.emptyMessage;
+        this.noDataEmptyMessage = grid.noDataEmptyMessage;
       },
 
       onFetchData: function (criteria, requestProperties) {
@@ -274,6 +286,7 @@
   filterDialogConstructor: isc.OBTreeItemPopupFilterWindow,
   lastValueFromPopup: null,
   pickerConstructor: 'ImgButton',
+  allowExpressions: true,
   pickerIconDefaults: {
     name: 'showDateRange',
     width: 21,
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Mon Jul 27 19:05:39 2015 +0200
@@ -868,7 +868,7 @@
     var filterField, criterion, filterLength = criteria.criteria.length,
         fkFilterAuxCache = [],
         innerCache = [],
-        filterEditForm, cacheElement, i;
+        filterEditForm, cacheElement, i, j;
     if (!this.filterEditor || !this.filterEditor.getEditForm()) {
       return fkFilterAuxCache;
     }
@@ -879,11 +879,11 @@
       innerCache = [];
       if (filterField && filterField.filterType === 'id') {
         if (criterion.criteria) {
-          for (i = 0; i < criterion.criteria.length; i++) {
+          for (j = 0; j < criterion.criteria.length; j++) {
             cacheElement = {};
-            cacheElement.fieldName = criterion.criteria[i].fieldName;
-            cacheElement[OB.Constants.ID] = criterion.criteria[i].value;
-            cacheElement[OB.Constants.IDENTIFIER] = filterField.getRecordIdentifierFromId(criterion.criteria[i].value);
+            cacheElement.fieldName = criterion.criteria[j].fieldName;
+            cacheElement[OB.Constants.ID] = criterion.criteria[j].value;
+            cacheElement[OB.Constants.IDENTIFIER] = filterField.getRecordIdentifierFromId(criterion.criteria[j].value);
             innerCache.add(cacheElement);
           }
         } else {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/materialmgmt/ob-reservation.js	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/materialmgmt/ob-reservation.js	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2012 Openbravo SLU
+ * All portions are Copyright (C) 2012-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,7 @@
       selectedRecords = item.grid.getSelectedRecords(),
       selectedRecordsLength = selectedRecords.length,
       editedRecord = null,
+      isQtyVariable = item.grid.view.sourceView.getContextInfo(false, true, true, true).isQuantityVariable,
       i;
 
   if (!isc.isA.Number(value)) {
@@ -56,7 +57,7 @@
       reservedQty = reservedQty.add(new BigDecimal(String(editedRecord.quantity)));
     }
   }
-  if (reservedQty.compareTo(totalQty) > 0) {
+  if (reservedQty.compareTo(totalQty) > 0 && isQtyVariable !== 'Y') {
     isc.warn(OB.I18N.getLabel('OBUIAPP_Res_MoreThanReservationQty', [totalQty.toString()]));
     return false;
   }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-user-profile-widget.js	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-user-profile-widget.js	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2010-2014 Openbravo SLU
+ * All portions are Copyright (C) 2010-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -287,7 +287,7 @@
           }
         }
         this.setWarehouseValueMap();
-        if (item.name !== 'warehouse' && item.name !== 'default') {
+        if (item.name !== 'warehouse' && item.name !== 'default' && item.name !== 'language') {
           if (this.getItem('warehouse').getClientPickListData().length > 0) {
             this.getItem('warehouse').moveToFirstValue();
           }
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/FreemarkerTemplateProcessorTest.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/FreemarkerTemplateProcessorTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -153,8 +153,8 @@
     template.setModule(getModule());
 
     for (Template dependency : dependencies) {
-      final TemplateDependency templateDependency = OBProvider.getInstance().get(
-          TemplateDependency.class);
+      final TemplateDependency templateDependency = OBProvider.getInstance()
+          .get(TemplateDependency.class);
       templateDependency.setObclkerTemplate(template);
       templateDependency.setDependsOnTemplate(dependency);
       template.getOBCLKERTemplateDependencyList().add(templateDependency);
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/GenerateComponentTest.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/GenerateComponentTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2009-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -23,6 +23,7 @@
 
 import javax.inject.Inject;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.openbravo.base.weld.test.WeldBaseTest;
 import org.openbravo.client.kernel.Component;
@@ -44,6 +45,7 @@
   private ComponentProvider kernelComponentProvider;
 
   @Test
+  @Ignore // TODO: failing, check why
   public void testApplication() throws Exception {
     generateComponent(KernelConstants.APPLICATION_COMPONENT_ID);
   }
--- a/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/LabelTest.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.kernel/src-test/org/openbravo/client/kernel/freemarker/test/LabelTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2009-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -67,6 +67,7 @@
     final Module module = OBDal.getInstance().get(Module.class,
         kernelComponentProvider.getModule().getId());
     module.setInDevelopment(true);
+    OBDal.getInstance().flush();
 
     final String msgKeyWithTranslation = "OBCLKER_MSG_WITH_TRANSLATION";
     final String msgTextWithTranslation = "WITH TRANSLATION";
@@ -84,8 +85,8 @@
     messageTrl.setMessage(messageWithTrl);
     messageTrl.setMessageText(msgTextTranslated);
     messageTrl.setTranslation(true);
-    messageTrl.setLanguage(OBDal.getInstance().get(Language.class,
-        OBContext.getOBContext().getLanguage().getId()));
+    messageTrl.setLanguage(
+        OBDal.getInstance().get(Language.class, OBContext.getOBContext().getLanguage().getId()));
     messageWithTrl.getADMessageTrlList().add(messageTrl);
     OBDal.getInstance().save(messageWithTrl);
 
@@ -98,8 +99,8 @@
     OBDal.getInstance().flush();
 
     // generate the javascript and check if the above strings are present
-    final Component component = kernelComponentProvider.getComponent(
-        KernelConstants.LABELS_COMPONENT_ID, new HashMap<String, Object>());
+    final Component component = kernelComponentProvider
+        .getComponent(KernelConstants.LABELS_COMPONENT_ID, new HashMap<String, Object>());
 
     final String output = ComponentGenerator.getInstance().generate(component);
     System.err.println(output);
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/ForeignKeyUIDefinition.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2010-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2010-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -63,9 +63,25 @@
       }
     }
 
-    Boolean allowFkFilterByIdentifier = (Boolean) readGridConfigurationSetting("allowFkFilterByIdentifier");
-    if (Boolean.FALSE.equals(allowFkFilterByIdentifier)) {
-      append = append + ", allowFkFilterByIdentifier: " + allowFkFilterByIdentifier.toString();
+    Boolean disableFkDropdown = (Boolean) readGridConfigurationSetting("disableFkDropdown");
+    if (Boolean.TRUE.equals(disableFkDropdown)) {
+      append = append + ", disableFkDropdown: " + disableFkDropdown.toString();
+      // if the fk drop down is disabled then the filter should behave like a text filter
+      // that means the filter could be trigger on editor change, if that configuration is enabled
+      if (Boolean.TRUE.equals(filterOnChange)) {
+        append = append + ", filterOnChange: " + filterOnChange.toString();
+      }
+    } else {
+      // these configurations only apply if the fk filter combo is enabled
+      Boolean allowFkFilterByIdentifier = (Boolean) readGridConfigurationSetting("allowFkFilterByIdentifier");
+      if (Boolean.FALSE.equals(allowFkFilterByIdentifier)) {
+        append = append + ", allowFkFilterByIdentifier: " + allowFkFilterByIdentifier.toString();
+      }
+
+      Boolean showFkDropdownUnfiltered = (Boolean) readGridConfigurationSetting("showFkDropdownUnfiltered");
+      if (Boolean.TRUE.equals(showFkDropdownUnfiltered)) {
+        append = append + ", showFkDropdownUnfiltered: " + showFkDropdownUnfiltered.toString();
+      }
     }
 
     return super.getFilterEditorPropertiesProperty(field) + append;
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2009-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -286,6 +286,22 @@
       }
 
       typedParameters.addAll(subEntityQueryBuilder.typedParameters);
+    } else if (filterParameters.containsKey(JsonConstants.SHOW_FK_DROPDOWN_UNFILTERED_PARAMETER)) {
+      // If the entity is Client or Organization, we need to add the readable Client or
+      // Organization filter manually, because the OBQuery will not be able to do it
+      // See issue https://issues.openbravo.com/view.php?id=29846
+      String subEntityClientOrg = "";
+      String whereClauseFirstWord = StringUtils.isEmpty(whereClause.trim()) ? "where" : "and";
+      if (entity.getMappingClass().isAssignableFrom(Organization.class)) {
+        subEntityClientOrg = " " + whereClauseFirstWord + " e.id "
+            + createInClause(OBContext.getOBContext().getReadableOrganizations());
+      } else if (entity.getMappingClass().isAssignableFrom(Client.class)) {
+        subEntityClientOrg = " " + whereClauseFirstWord + " e.id "
+            + createInClause(OBContext.getOBContext().getReadableClients());
+      }
+      if (!subEntityClientOrg.isEmpty()) {
+        whereClause += subEntityClientOrg;
+      }
     }
 
     return whereClause;
@@ -1566,8 +1582,15 @@
               + prefix.substring(0, prefix.lastIndexOf('.')) + " and t.language.language='"
               + OBContext.getOBContext().getLanguage().getLanguage() + "')), to_char("
               + replaceValueWithJoins(prefix + prop.getName()) + "), '')");
+        } else if (prop.isMandatory() && prop.isTextualType()) {
+          // if the property is mandatory there is no need to use coalesce to replace a possible
+          // null value with an empty string
+          // getting rid of the coalesce and to_char functions allow under certain circumstances
+          // to use indexes defined on that property
+          sb.append(replaceValueWithJoins(prefix + prop.getName()));
         } else {
           sb.append("COALESCE(to_char(" + replaceValueWithJoins(prefix + prop.getName()) + "),'')");
+
         }
 
       } else {
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Mon Jul 27 19:05:39 2015 +0200
@@ -327,71 +327,116 @@
       // this is the main entity of a 'contains' (used in FK drop down lists), it will create also
       // info for subentity
 
-      final String distinctPropertyPath = parameters.get(JsonConstants.DISTINCT_PARAMETER);
-      final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
-          .getEntity(entityName), distinctPropertyPath);
-      final Entity distinctEntity = distinctProperty.getTargetEntity();
+      if ("true".equals(parameters.get(JsonConstants.SHOW_FK_DROPDOWN_UNFILTERED_PARAMETER))) {
+        // Do not filter out the rows of the referenced tables if
+        // they are not referenced from the referencing tables
+        // Showing the records unfiltered improves the performance if the referenced table has just
+        // a few records and the referencing table has lots
+        final String distinctPropertyPath = parameters.get(JsonConstants.DISTINCT_PARAMETER);
+        final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
+            .getEntity(entityName), distinctPropertyPath);
+        final Entity distinctEntity = distinctProperty.getTargetEntity();
+        queryService.setEntityName(distinctEntity.getName());
+        queryService
+            .addFilterParameter(JsonConstants.SHOW_FK_DROPDOWN_UNFILTERED_PARAMETER, "true");
+        queryService.setFilterOnReadableOrganizations(filterOnReadableOrganizations);
+        if (parameters.containsKey(JsonConstants.USE_ALIAS)) {
+          queryService.setUseAlias();
+        }
 
-      // criteria needs to be split in two parts:
-      // -One for main entity (the one directly queried for)
-      // -Another one for subentity
-      String baseCriteria = "";
-      String subCriteria = "";
-      hasSubentity = true;
-      if (!StringUtils.isEmpty(parameters.get("criteria"))) {
-        String criteria = parameters.get("criteria");
-        for (String criterion : criteria.split(JsonConstants.IN_PARAMETER_SEPARATOR)) {
-          try {
-            JSONObject jsonCriterion = new JSONObject(criterion);
-            if (jsonCriterion.getString("fieldName").equals(
-                distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
-              jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
-              baseCriteria = jsonCriterion.toString();
-            } else {
-              subCriteria += subCriteria.length() > 0 ? JsonConstants.IN_PARAMETER_SEPARATOR : "";
-              subCriteria += criterion;
+        String baseCriteria = "";
+        // The main entity is now the referenced table, so each criterion that references it must be
+        // updated
+        // The criteria that does not apply to the referenced table can be ignored
+        if (!StringUtils.isEmpty(parameters.get("criteria"))) {
+          String criteria = parameters.get("criteria");
+          for (String criterion : criteria.split(JsonConstants.IN_PARAMETER_SEPARATOR)) {
+            try {
+              JSONObject jsonCriterion = new JSONObject(criterion);
+              if (jsonCriterion.getString("fieldName").equals(
+                  distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
+                jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
+                baseCriteria = jsonCriterion.toString();
+              }
+            } catch (JSONException e) {
+              log.error("Error obtaining 'distint' criterion for " + criterion, e);
             }
-          } catch (JSONException e) {
-            log.error("Error obtaining 'distint' criterion for " + criterion, e);
           }
         }
+        if (StringUtils.isEmpty(baseCriteria)) {
+          parameters.remove("criteria");
+        } else {
+          parameters.put("criteria", baseCriteria);
+        }
+        // The where clause of the referencing table no longer needs to be applied, as the query
+        // will be done on the referenced table
+        removeWhereParameter(parameters);
+      } else {
+
+        final String distinctPropertyPath = parameters.get(JsonConstants.DISTINCT_PARAMETER);
+        final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
+            .getEntity(entityName), distinctPropertyPath);
+        final Entity distinctEntity = distinctProperty.getTargetEntity();
+
+        // criteria needs to be split in two parts:
+        // -One for main entity (the one directly queried for)
+        // -Another one for subentity
+        String baseCriteria = "";
+        String subCriteria = "";
+        hasSubentity = true;
+        if (!StringUtils.isEmpty(parameters.get("criteria"))) {
+          String criteria = parameters.get("criteria");
+          for (String criterion : criteria.split(JsonConstants.IN_PARAMETER_SEPARATOR)) {
+            try {
+              JSONObject jsonCriterion = new JSONObject(criterion);
+              if (jsonCriterion.getString("fieldName").equals(
+                  distinctPropertyPath + "$" + JsonConstants.IDENTIFIER)) {
+                jsonCriterion.put("fieldName", JsonConstants.IDENTIFIER);
+                baseCriteria = jsonCriterion.toString();
+              } else {
+                subCriteria += subCriteria.length() > 0 ? JsonConstants.IN_PARAMETER_SEPARATOR : "";
+                subCriteria += criterion;
+              }
+            } catch (JSONException e) {
+              log.error("Error obtaining 'distint' criterion for " + criterion, e);
+            }
+          }
+        }
+
+        // params for subentity are based on main entity ones
+        @SuppressWarnings("unchecked")
+        Map<String, String> paramSubCriteria = (Map<String, String>) ((HashMap<String, String>) parameters)
+            .clone();
+
+        // set proper criteria for each case
+        if (StringUtils.isEmpty(subCriteria)) {
+          paramSubCriteria.remove("criteria");
+        } else {
+          paramSubCriteria.put("criteria", subCriteria);
+        }
+        if (StringUtils.isEmpty(baseCriteria)) {
+          parameters.remove("criteria");
+        } else {
+          parameters.put("criteria", baseCriteria);
+        }
+
+        // where parameter is only applied in subentity, remove it from main entity
+        removeWhereParameter(parameters);
+
+        // main entity ("me") settings
+        queryService.getQueryBuilder().setMainAlias("me");
+        queryService.setEntityName(distinctEntity.getName());
+
+        queryService.setFilterOnReadableClients(false);
+        queryService.setFilterOnReadableOrganizations(false);
+        queryService.setFilterOnActive(false);
+
+        // create now subentity
+        queryService.setSubEntity(
+            entityName,
+            createSetQueryService(paramSubCriteria, forCountOperation, true,
+                filterOnReadableOrganizations), distinctProperty, distinctPropertyPath);
       }
-
-      // params for subentity are based on main entity ones
-      @SuppressWarnings("unchecked")
-      Map<String, String> paramSubCriteria = (Map<String, String>) ((HashMap<String, String>) parameters)
-          .clone();
-
-      // set proper criteria for each case
-      if (StringUtils.isEmpty(subCriteria)) {
-        paramSubCriteria.remove("criteria");
-      } else {
-        paramSubCriteria.put("criteria", subCriteria);
-      }
-      if (StringUtils.isEmpty(baseCriteria)) {
-        parameters.remove("criteria");
-      } else {
-        parameters.put("criteria", baseCriteria);
-      }
-
-      // where parameter is only applied in subentity, remove it from main entity
-      if (parameters.containsKey(JsonConstants.WHERE_PARAMETER)) {
-        parameters.remove(JsonConstants.WHERE_PARAMETER);
-      }
-
-      // main entity ("me") settings
-      queryService.getQueryBuilder().setMainAlias("me");
-      queryService.setEntityName(distinctEntity.getName());
-
-      queryService.setFilterOnReadableClients(false);
-      queryService.setFilterOnReadableOrganizations(false);
-      queryService.setFilterOnActive(false);
-
-      // create now subentity
-      queryService.setSubEntity(
-          entityName,
-          createSetQueryService(paramSubCriteria, forCountOperation, true,
-              filterOnReadableOrganizations), distinctProperty, distinctPropertyPath);
     } else {
       queryService.setEntityName(entityName);
       queryService.setFilterOnReadableOrganizations(filterOnReadableOrganizations);
@@ -522,6 +567,12 @@
     return queryService;
   }
 
+  private void removeWhereParameter(Map<String, String> parameters) {
+    if (parameters.containsKey(JsonConstants.WHERE_PARAMETER)) {
+      parameters.remove(JsonConstants.WHERE_PARAMETER);
+    }
+  }
+
   // Given a map of parameters, returns a string with the pairs key:value
   private String convertParameterToString(Map<String, String> parameters) {
     String paramMsg = "";
@@ -702,13 +753,22 @@
         }
 
         // refresh the objects from the db as they can have changed
+        // put the refreshed objects into a new array as we are going to retrieve them using
+        // OBDal.getInstance().get as performs better than OBDal.getInstance().getSession().refresh
+        // See issue https://issues.openbravo.com/view.php?id=30308
+        final List<BaseOBObject> refreshedBobs = new ArrayList<BaseOBObject>();
         for (BaseOBObject bob : bobs) {
-          OBDal.getInstance().getSession().refresh(bob);
+          // Remove the bob instance from the session cache with evict
+          OBDal.getInstance().getSession().evict(bob);
+          // With get() we retrieve the object from db as we have cleared it from cache with evict()
+          BaseOBObject refreshedBob = OBDal.getInstance().get(bob.getEntityName(),
+              DalUtil.getId(bob));
           // if object has computed columns refresh from the database too
-          if (bob.getEntity().hasComputedColumns()) {
+          if (refreshedBob.getEntity().hasComputedColumns()) {
             OBDal.getInstance().getSession()
-                .refresh(bob.get(Entity.COMPUTED_COLUMNS_PROXY_PROPERTY));
+                .refresh(refreshedBob.get(Entity.COMPUTED_COLUMNS_PROXY_PROPERTY));
           }
+          refreshedBobs.add(refreshedBob);
         }
 
         // almost successfull, now create the response
@@ -716,7 +776,7 @@
         final DataToJsonConverter toJsonConverter = OBProvider.getInstance().get(
             DataToJsonConverter.class);
         toJsonConverter.setAdditionalProperties(JsonUtils.getAdditionalProperties(parameters));
-        final List<JSONObject> jsonObjects = toJsonConverter.toJsonObjects(bobs);
+        final List<JSONObject> jsonObjects = toJsonConverter.toJsonObjects(refreshedBobs);
 
         if (sendOriginalIdBack) {
           // now it is assumed that the jsonObjects are the same size and the same location
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java	Mon Jul 27 19:05:39 2015 +0200
@@ -11,7 +11,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) 2009-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2015 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -56,6 +56,7 @@
   public static final String WHERE_PARAMETER = "_where";
   public static final String SELECTEDPROPERTIES_PARAMETER = "_selectedProperties";
   public static final String DISTINCT_PARAMETER = "_distinct";
+  public static final String SHOW_FK_DROPDOWN_UNFILTERED_PARAMETER = "_showFkDropdownUnfiltered";
   public static final String SUMMARY_PARAMETER = "_summary";
   public static final String ORDERBY_PARAMETER = "_orderBy";
   public static final String FILTER_PARAMETER = "_filter";
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/FKSelectorUIDefinition.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/FKSelectorUIDefinition.java	Mon Jul 27 19:05:39 2015 +0200
@@ -106,32 +106,11 @@
     String displayFieldName = JsonConstants.IDENTIFIER;
     if (displayField != null && displayField.getProperty() != null) {
       displayFieldName = displayField.getProperty();
+      return displayFieldName.replace(".", DalUtil.FIELDSEPARATOR);
     } else {
       // fallback to the default
       return null;
     }
-
-    if (!prop.getReferencedProperty().getEntity().hasProperty(getFirstProperty(displayFieldName))) {
-      // If the first property of the display field name does not belong to the referenced entity,
-      // return the displayFieldName
-      // Otherwise trying to append the displayFieldName to the referenced property would later
-      // result in an error
-      return displayFieldName.replace(".", DalUtil.FIELDSEPARATOR);
-    } else {
-      final String result = (prop.getName() + DalUtil.FIELDSEPARATOR + displayFieldName).replace(
-          ".", DalUtil.FIELDSEPARATOR);
-      return result;
-    }
-
-  }
-
-  private String getFirstProperty(String displayFieldName) {
-    int dotPosition = displayFieldName.indexOf(DalUtil.DOT);
-    if (dotPosition == -1) {
-      return displayFieldName;
-    } else {
-      return displayFieldName.substring(0, dotPosition);
-    }
   }
 
   public String getFieldProperties(Field field) {
--- a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Wed Jul 22 17:54:36 2015 +0200
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Mon Jul 27 19:05:39 2015 +0200
@@ -752,7 +752,7 @@
     var currentValue = this.getValue(),
         identifierFieldName = this.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER,
         valueMapObj = {},
-        displayFieldValue, i;
+        valueToDisplay, i;
     this._notUpdatingManually = true;
     if (!record) {
       this.storeValue(null);
@@ -799,12 +799,11 @@
       }
 
       if (record[this.valueField]) { // it can be undefined in case of empty (null) entry
-        if (this.displayField.indexOf(OB.Constants.FIELDSEPARATOR) !== -1) {
-          displayFieldValue = this.displayField.substring(this.displayField.indexOf(OB.Constants.FIELDSEPARATOR) + 1, this.displayField.length);
-        } else {
-          displayFieldValue = this.displayField;
+        valueToDisplay = record[this.displayField];
+        if (valueToDisplay) {
+          valueToDisplay = valueToDisplay.replace(/[\n\r]/g, '');
         }
-        this.valueMap[record[this.valueField]] = record[displayFieldValue].replace(/[\n\r]/g, '');
+        this.valueMap[record[this.valueField]] = valueToDisplay;
       }
 
       this.updateValueMap();
--- a/referencedata/sampledata/QA_Testing/C_INVOICE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_INVOICE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -970,6 +970,57 @@
 </C_INVOICE>
 
 <C_INVOICE>
+  <C_INVOICE_ID><![CDATA[F889F6E61CA6454EA50BDD6DD75582E3]]></C_INVOICE_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[357947E87C284935AD1D783CF6F099A1]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:17:42.382]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:17:42.382]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <ISSOTRX><![CDATA[Y]]></ISSOTRX>
+  <DOCUMENTNO><![CDATA[Taxes Test Template]]></DOCUMENTNO>
+  <DOCSTATUS><![CDATA[DR]]></DOCSTATUS>
+  <DOCACTION><![CDATA[CO]]></DOCACTION>
+  <PROCESSING><![CDATA[N]]></PROCESSING>
+  <PROCESSED><![CDATA[N]]></PROCESSED>
+  <POSTED><![CDATA[N]]></POSTED>
+  <C_DOCTYPE_ID><![CDATA[0]]></C_DOCTYPE_ID>
+  <C_DOCTYPETARGET_ID><![CDATA[FF8080812C2ABFC6012C2B3BDF4B0050]]></C_DOCTYPETARGET_ID>
+  <ISPRINTED><![CDATA[N]]></ISPRINTED>
+  <DATEINVOICED><![CDATA[2015-04-21 00:00:00.0]]></DATEINVOICED>
+  <DATEACCT><![CDATA[2015-04-21 00:00:00.0]]></DATEACCT>
+  <C_BPARTNER_ID><![CDATA[4028E6C72959682B01295F40C3CB02EC]]></C_BPARTNER_ID>
+  <C_BPARTNER_LOCATION_ID><![CDATA[4028E6C72959682B01295F40C43802EE]]></C_BPARTNER_LOCATION_ID>
+  <ISDISCOUNTPRINTED><![CDATA[N]]></ISDISCOUNTPRINTED>
+  <C_CURRENCY_ID><![CDATA[102]]></C_CURRENCY_ID>
+  <PAYMENTRULE><![CDATA[4]]></PAYMENTRULE>
+  <C_PAYMENTTERM_ID><![CDATA[7B308C5CB9674BB3A56E63D85887058A]]></C_PAYMENTTERM_ID>
+  <CHARGEAMT><![CDATA[0]]></CHARGEAMT>
+  <TOTALLINES><![CDATA[3.00]]></TOTALLINES>
+  <GRANDTOTAL><![CDATA[3.00]]></GRANDTOTAL>
+  <M_PRICELIST_ID><![CDATA[4028E6C72959682B01295B03CE480243]]></M_PRICELIST_ID>
+  <ISTAXINCLUDED><![CDATA[N]]></ISTAXINCLUDED>
+  <CREATEFROM><![CDATA[N]]></CREATEFROM>
+  <GENERATETO><![CDATA[N]]></GENERATETO>
+  <AD_USER_ID><![CDATA[4028E6C72959682B01295F40C43802EF]]></AD_USER_ID>
+  <COPYFROM><![CDATA[N]]></COPYFROM>
+  <ISSELFSERVICE><![CDATA[N]]></ISSELFSERVICE>
+  <ISPAID><![CDATA[N]]></ISPAID>
+  <TOTALPAID><![CDATA[0]]></TOTALPAID>
+  <OUTSTANDINGAMT><![CDATA[0]]></OUTSTANDINGAMT>
+  <DAYSTILLDUE><![CDATA[0]]></DAYSTILLDUE>
+  <DUEAMT><![CDATA[0]]></DUEAMT>
+  <UPDATEPAYMENTMONITOR><![CDATA[N]]></UPDATEPAYMENTMONITOR>
+  <FIN_PAYMENTMETHOD_ID><![CDATA[42E87E97974E4B35849A430B8F6F2884]]></FIN_PAYMENTMETHOD_ID>
+  <CALCULATE_PROMOTIONS><![CDATA[N]]></CALCULATE_PROMOTIONS>
+  <ISCASHVAT><![CDATA[N]]></ISCASHVAT>
+  <PREPAYMENTAMT><![CDATA[0]]></PREPAYMENTAMT>
+  <EM_APRM_ADDPAYMENT><![CDATA[Y]]></EM_APRM_ADDPAYMENT>
+  <EM_APRM_PROCESSINVOICE><![CDATA[CO]]></EM_APRM_PROCESSINVOICE>
+</C_INVOICE>
+
+<C_INVOICE>
   <C_INVOICE_ID><![CDATA[FF808081328278B5013282A1A35800A0]]></C_INVOICE_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[5EFF95EB540740A3B10510D9814EFAD5]]></AD_ORG_ID>
--- a/referencedata/sampledata/QA_Testing/C_INVOICELINE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_INVOICELINE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -1784,6 +1784,43 @@
 </C_INVOICELINE>
 
 <C_INVOICELINE>
+  <C_INVOICELINE_ID><![CDATA[E6DAAB70A8734794B3A47403886844D3]]></C_INVOICELINE_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[357947E87C284935AD1D783CF6F099A1]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:18:10.466]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:18:10.466]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <C_INVOICE_ID><![CDATA[F889F6E61CA6454EA50BDD6DD75582E3]]></C_INVOICE_ID>
+  <LINE><![CDATA[10]]></LINE>
+  <FINANCIAL_INVOICE_LINE><![CDATA[N]]></FINANCIAL_INVOICE_LINE>
+  <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC1D07022A]]></M_PRODUCT_ID>
+  <QTYINVOICED><![CDATA[1]]></QTYINVOICED>
+  <PRICELIST><![CDATA[2]]></PRICELIST>
+  <PRICEACTUAL><![CDATA[3]]></PRICEACTUAL>
+  <PRICELIMIT><![CDATA[2]]></PRICELIMIT>
+  <LINENETAMT><![CDATA[3.00]]></LINENETAMT>
+  <CHARGEAMT><![CDATA[0.00]]></CHARGEAMT>
+  <C_UOM_ID><![CDATA[4028E6C72959682B01295ADC1A380221]]></C_UOM_ID>
+  <C_TAX_ID><![CDATA[BA7059430C0A43A9B86A21C4EECF3A21]]></C_TAX_ID>
+  <TAXAMT><![CDATA[0]]></TAXAMT>
+  <ISDESCRIPTION><![CDATA[N]]></ISDESCRIPTION>
+  <PRICESTD><![CDATA[3]]></PRICESTD>
+  <EXCLUDEFORWITHHOLDING><![CDATA[N]]></EXCLUDEFORWITHHOLDING>
+  <ISEDITLINENETAMT><![CDATA[N]]></ISEDITLINENETAMT>
+  <TAXBASEAMT><![CDATA[3]]></TAXBASEAMT>
+  <LINE_GROSS_AMOUNT><![CDATA[0]]></LINE_GROSS_AMOUNT>
+  <GROSS_UNIT_PRICE><![CDATA[0]]></GROSS_UNIT_PRICE>
+  <C_BPARTNER_ID><![CDATA[4028E6C72959682B01295F40C3CB02EC]]></C_BPARTNER_ID>
+  <GROSSPRICESTD><![CDATA[0]]></GROSSPRICESTD>
+  <GROSSPRICELIST><![CDATA[0]]></GROSSPRICELIST>
+  <ISDEFERRED><![CDATA[N]]></ISDEFERRED>
+  <EXPLODE><![CDATA[N]]></EXPLODE>
+  <MATCH_LCCOSTS><![CDATA[N]]></MATCH_LCCOSTS>
+</C_INVOICELINE>
+
+<C_INVOICELINE>
   <C_INVOICELINE_ID><![CDATA[E89AFBD23F4B4255A94FE764114EEC6D]]></C_INVOICELINE_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[357947E87C284935AD1D783CF6F099A1]]></AD_ORG_ID>
--- a/referencedata/sampledata/QA_Testing/C_TAX.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_TAX.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -30,6 +30,35 @@
 </C_TAX>
 
 <C_TAX>
+  <C_TAX_ID><![CDATA[37222B873B6447D7A1FEC837799B222F]]></C_TAX_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[43D590B4814049C6B85C6545E8264E37]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2013-07-04 23:38:16.958]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2013-07-04 23:38:16.958]]></UPDATED>
+  <NAME><![CDATA[Exempt]]></NAME>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <VALIDFROM><![CDATA[2000-01-01 00:00:00.0]]></VALIDFROM>
+  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+  <RATE><![CDATA[0.00]]></RATE>
+  <C_TAXCATEGORY_ID><![CDATA[E02F948001F44F479D709EBC6911E310]]></C_TAXCATEGORY_ID>
+  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <ISTAXEXEMPT><![CDATA[Y]]></ISTAXEXEMPT>
+  <SOPOTYPE><![CDATA[B]]></SOPOTYPE>
+  <CASCADE><![CDATA[N]]></CASCADE>
+  <LINE><![CDATA[10]]></LINE>
+  <ISWITHHOLDINGTAX><![CDATA[N]]></ISWITHHOLDINGTAX>
+  <ISNOTAXABLE><![CDATA[N]]></ISNOTAXABLE>
+  <ISTAXUNDEDUCTABLE><![CDATA[N]]></ISTAXUNDEDUCTABLE>
+  <ISTAXDEDUCTABLE><![CDATA[N]]></ISTAXDEDUCTABLE>
+  <ISNOVAT><![CDATA[N]]></ISNOVAT>
+  <BASEAMOUNT><![CDATA[LNA]]></BASEAMOUNT>
+  <DOCTAXAMOUNT><![CDATA[D]]></DOCTAXAMOUNT>
+  <ISCASHVAT><![CDATA[N]]></ISCASHVAT>
+</C_TAX>
+
+<C_TAX>
   <C_TAX_ID><![CDATA[5690F12F2C934F5384FA94F063F63C5F]]></C_TAX_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[357947E87C284935AD1D783CF6F099A1]]></AD_ORG_ID>
@@ -248,6 +277,35 @@
 </C_TAX>
 
 <C_TAX>
+  <C_TAX_ID><![CDATA[D85D2465A01C464BA75E053D36FC28EC]]></C_TAX_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-20 16:35:13.925]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-20 16:35:13.925]]></UPDATED>
+  <NAME><![CDATA[As Per BOM]]></NAME>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <VALIDFROM><![CDATA[2000-01-01 00:00:00.0]]></VALIDFROM>
+  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+  <RATE><![CDATA[0]]></RATE>
+  <C_TAXCATEGORY_ID><![CDATA[1955F4CC846840D4832A49BAAC67A45C]]></C_TAXCATEGORY_ID>
+  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <ISTAXEXEMPT><![CDATA[N]]></ISTAXEXEMPT>
+  <SOPOTYPE><![CDATA[B]]></SOPOTYPE>
+  <CASCADE><![CDATA[N]]></CASCADE>
+  <LINE><![CDATA[10]]></LINE>
+  <ISWITHHOLDINGTAX><![CDATA[N]]></ISWITHHOLDINGTAX>
+  <ISNOTAXABLE><![CDATA[N]]></ISNOTAXABLE>
+  <ISTAXUNDEDUCTABLE><![CDATA[N]]></ISTAXUNDEDUCTABLE>
+  <ISTAXDEDUCTABLE><![CDATA[N]]></ISTAXDEDUCTABLE>
+  <ISNOVAT><![CDATA[N]]></ISNOVAT>
+  <BASEAMOUNT><![CDATA[LNA]]></BASEAMOUNT>
+  <DOCTAXAMOUNT><![CDATA[D]]></DOCTAXAMOUNT>
+  <ISCASHVAT><![CDATA[N]]></ISCASHVAT>
+</C_TAX>
+
+<C_TAX>
   <C_TAX_ID><![CDATA[F9D9AF81F4FA459C9CE7A2D9697DF1E4]]></C_TAX_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[357947E87C284935AD1D783CF6F099A1]]></AD_ORG_ID>
--- a/referencedata/sampledata/QA_Testing/C_TAXCATEGORY.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_TAXCATEGORY.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -1,6 +1,20 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
 <C_TAXCATEGORY>
+  <C_TAXCATEGORY_ID><![CDATA[1955F4CC846840D4832A49BAAC67A45C]]></C_TAXCATEGORY_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:17:49.207]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:17:49.207]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <NAME><![CDATA[As Per BOM]]></NAME>
+  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <ASBOM><![CDATA[Y]]></ASBOM>
+</C_TAXCATEGORY>
+
+<C_TAXCATEGORY>
   <C_TAXCATEGORY_ID><![CDATA[4028E6C72959682B01295ADC0FB80217]]></C_TAXCATEGORY_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
@@ -12,6 +26,7 @@
   <NAME><![CDATA[VAT 10%]]></NAME>
   <DESCRIPTION><![CDATA[Created using default values]]></DESCRIPTION>
   <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <ASBOM><![CDATA[N]]></ASBOM>
 </C_TAXCATEGORY>
 
 <C_TAXCATEGORY>
@@ -26,6 +41,7 @@
   <NAME><![CDATA[VAT 3%]]></NAME>
   <DESCRIPTION><![CDATA[Created using default values]]></DESCRIPTION>
   <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <ASBOM><![CDATA[N]]></ASBOM>
 </C_TAXCATEGORY>
 
 <C_TAXCATEGORY>
@@ -39,6 +55,7 @@
   <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
   <NAME><![CDATA[Exempt]]></NAME>
   <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <ASBOM><![CDATA[N]]></ASBOM>
 </C_TAXCATEGORY>
 
 </data>
--- a/referencedata/sampledata/QA_Testing/C_TAXCATEGORY_TRL.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_TAXCATEGORY_TRL.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -63,6 +63,21 @@
 </C_TAXCATEGORY_TRL>
 
 <C_TAXCATEGORY_TRL>
+  <C_TAXCATEGORY_TRL_ID><![CDATA[D9F4DC116E8C45B78AED82D3C6D76A0B]]></C_TAXCATEGORY_TRL_ID>
+  <C_TAXCATEGORY_ID><![CDATA[1955F4CC846840D4832A49BAAC67A45C]]></C_TAXCATEGORY_ID>
+  <AD_LANGUAGE><![CDATA[en_US]]></AD_LANGUAGE>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:17:49.207]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:17:49.207]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <NAME><![CDATA[As Per BOM]]></NAME>
+  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+</C_TAXCATEGORY_TRL>
+
+<C_TAXCATEGORY_TRL>
   <C_TAXCATEGORY_TRL_ID><![CDATA[E639E4D8E247424B9A3A4A375E4046FD]]></C_TAXCATEGORY_TRL_ID>
   <C_TAXCATEGORY_ID><![CDATA[4028E6C72959682B01295ADC0FB80217]]></C_TAXCATEGORY_ID>
   <AD_LANGUAGE><![CDATA[es_ES]]></AD_LANGUAGE>
--- a/referencedata/sampledata/QA_Testing/C_TAX_ACCT.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_TAX_ACCT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -46,6 +46,21 @@
 </C_TAX_ACCT>
 
 <C_TAX_ACCT>
+  <C_TAX_ACCT_ID><![CDATA[3A15B58510E343C8B68C8DA1156EA18E]]></C_TAX_ACCT_ID>
+  <C_TAX_ID><![CDATA[D85D2465A01C464BA75E053D36FC28EC]]></C_TAX_ID>
+  <C_ACCTSCHEMA_ID><![CDATA[432EAC71E1B8451E97C7F54718C4A06B]]></C_ACCTSCHEMA_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-20 16:35:13.0]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-20 16:35:13.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <T_DUE_ACCT><![CDATA[4203F97B5DB6456F8CB2DFE2A74B611A]]></T_DUE_ACCT>
+  <T_CREDIT_ACCT><![CDATA[FA66D8B235134769BD64835BBEA60C97]]></T_CREDIT_ACCT>
+</C_TAX_ACCT>
+
+<C_TAX_ACCT>
   <C_TAX_ACCT_ID><![CDATA[574B7B9BD7474412B01BCFF4C67E0BAA]]></C_TAX_ACCT_ID>
   <C_TAX_ID><![CDATA[9EDA6E6317CF4E5E97E3C412467923FA]]></C_TAX_ID>
   <C_ACCTSCHEMA_ID><![CDATA[9A68A0F8D72D4580B3EC3CAA00A5E1F0]]></C_ACCTSCHEMA_ID>
@@ -151,6 +166,21 @@
 </C_TAX_ACCT>
 
 <C_TAX_ACCT>
+  <C_TAX_ACCT_ID><![CDATA[AD4982231AA44C519CB8243A30143603]]></C_TAX_ACCT_ID>
+  <C_TAX_ID><![CDATA[D85D2465A01C464BA75E053D36FC28EC]]></C_TAX_ID>
+  <C_ACCTSCHEMA_ID><![CDATA[9A68A0F8D72D4580B3EC3CAA00A5E1F0]]></C_ACCTSCHEMA_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-20 16:35:13.0]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-20 16:35:13.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <T_DUE_ACCT><![CDATA[BC820B24C87A448B9B64CB10A9F2EE5F]]></T_DUE_ACCT>
+  <T_CREDIT_ACCT><![CDATA[36D9402834944B238108749A27CE6A70]]></T_CREDIT_ACCT>
+</C_TAX_ACCT>
+
+<C_TAX_ACCT>
   <C_TAX_ACCT_ID><![CDATA[C5E9543386354A8C8D8AA923E076859D]]></C_TAX_ACCT_ID>
   <C_TAX_ID><![CDATA[5690F12F2C934F5384FA94F063F63C5F]]></C_TAX_ID>
   <C_ACCTSCHEMA_ID><![CDATA[9A68A0F8D72D4580B3EC3CAA00A5E1F0]]></C_ACCTSCHEMA_ID>
--- a/referencedata/sampledata/QA_Testing/C_TAX_TRL.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/C_TAX_TRL.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -241,6 +241,21 @@
 </C_TAX_TRL>
 
 <C_TAX_TRL>
+  <C_TAX_TRL_ID><![CDATA[BC8FB894EC444DF098324519B4E9C270]]></C_TAX_TRL_ID>
+  <C_TAX_ID><![CDATA[D85D2465A01C464BA75E053D36FC28EC]]></C_TAX_ID>
+  <AD_LANGUAGE><![CDATA[en_US]]></AD_LANGUAGE>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-20 16:35:13.925]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-20 16:35:13.925]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+  <NAME><![CDATA[As Per BOM]]></NAME>
+</C_TAX_TRL>
+
+<C_TAX_TRL>
   <C_TAX_TRL_ID><![CDATA[CAF102C75C114D5C878213BFE1768C57]]></C_TAX_TRL_ID>
   <C_TAX_ID><![CDATA[58A7B9D1DDDD442CAD08052C1B735AFC]]></C_TAX_ID>
   <AD_LANGUAGE><![CDATA[en_US]]></AD_LANGUAGE>
--- a/referencedata/sampledata/QA_Testing/M_PRICELIST.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/M_PRICELIST.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -181,6 +181,42 @@
 </M_PRICELIST>
 
 <M_PRICELIST>
+  <M_PRICELIST_ID><![CDATA[62C67BFD306C4BEF9F2738C27353380B]]></M_PRICELIST_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:15:20.716]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:15:20.716]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <NAME><![CDATA[Price Including Taxes Sales]]></NAME>
+  <ISTAXINCLUDED><![CDATA[Y]]></ISTAXINCLUDED>
+  <ISSOPRICELIST><![CDATA[Y]]></ISSOPRICELIST>
+  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <C_CURRENCY_ID><![CDATA[102]]></C_CURRENCY_ID>
+  <ENFORCEPRICELIMIT><![CDATA[N]]></ENFORCEPRICELIMIT>
+  <COSTBASED><![CDATA[N]]></COSTBASED>
+</M_PRICELIST>
+
+<M_PRICELIST>
+  <M_PRICELIST_ID><![CDATA[83BD2A678D30447983755C4E46C6F69A]]></M_PRICELIST_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:16:23.364]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:16:23.364]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <NAME><![CDATA[Price Including Taxes Purchase]]></NAME>
+  <ISTAXINCLUDED><![CDATA[Y]]></ISTAXINCLUDED>
+  <ISSOPRICELIST><![CDATA[N]]></ISSOPRICELIST>
+  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
+  <C_CURRENCY_ID><![CDATA[102]]></C_CURRENCY_ID>
+  <ENFORCEPRICELIMIT><![CDATA[N]]></ENFORCEPRICELIMIT>
+  <COSTBASED><![CDATA[N]]></COSTBASED>
+</M_PRICELIST>
+
+<M_PRICELIST>
   <M_PRICELIST_ID><![CDATA[9DA3304545C44A139A36DD75B994A3DB]]></M_PRICELIST_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[357947E87C284935AD1D783CF6F099A1]]></AD_ORG_ID>
--- a/referencedata/sampledata/QA_Testing/M_PRICELIST_VERSION.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/M_PRICELIST_VERSION.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -188,6 +188,23 @@
 </M_PRICELIST_VERSION>
 
 <M_PRICELIST_VERSION>
+  <M_PRICELIST_VERSION_ID><![CDATA[5C45E8C8A0EF4BD386EACA822DC0A85E]]></M_PRICELIST_VERSION_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:15:32.41]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:15:32.41]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <NAME><![CDATA[21-04-2015]]></NAME>
+  <M_PRICELIST_ID><![CDATA[62C67BFD306C4BEF9F2738C27353380B]]></M_PRICELIST_ID>
+  <M_DISCOUNTSCHEMA_ID><![CDATA[4028E6C72959682B01295ADC16FC0219]]></M_DISCOUNTSCHEMA_ID>
+  <VALIDFROM><![CDATA[2000-01-01 00:00:00.0]]></VALIDFROM>
+  <PROCCREATE><![CDATA[N]]></PROCCREATE>
+  <M_PRICELIST_VERSION_GENERATE><![CDATA[N]]></M_PRICELIST_VERSION_GENERATE>
+</M_PRICELIST_VERSION>
+
+<M_PRICELIST_VERSION>
   <M_PRICELIST_VERSION_ID><![CDATA[8AE242126D924D02902704AC2A5717E9]]></M_PRICELIST_VERSION_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
@@ -222,6 +239,23 @@
 </M_PRICELIST_VERSION>
 
 <M_PRICELIST_VERSION>
+  <M_PRICELIST_VERSION_ID><![CDATA[C6648957037F46E79DBE22E9B0117F1B]]></M_PRICELIST_VERSION_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:16:33.141]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:16:33.141]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <NAME><![CDATA[21-04-2015]]></NAME>
+  <M_PRICELIST_ID><![CDATA[83BD2A678D30447983755C4E46C6F69A]]></M_PRICELIST_ID>
+  <M_DISCOUNTSCHEMA_ID><![CDATA[4028E6C72959682B01295ADC16FC0219]]></M_DISCOUNTSCHEMA_ID>
+  <VALIDFROM><![CDATA[2000-01-01 00:00:00.0]]></VALIDFROM>
+  <PROCCREATE><![CDATA[N]]></PROCCREATE>
+  <M_PRICELIST_VERSION_GENERATE><![CDATA[N]]></M_PRICELIST_VERSION_GENERATE>
+</M_PRICELIST_VERSION>
+
+<M_PRICELIST_VERSION>
   <M_PRICELIST_VERSION_ID><![CDATA[F3BE529C058447438A75BC8C558EF8EB]]></M_PRICELIST_VERSION_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
--- a/referencedata/sampledata/QA_Testing/M_PRODUCT.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/M_PRODUCT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -82,6 +82,50 @@
 </M_PRODUCT>
 
 <M_PRODUCT>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:27:56.102]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:27:56.102]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <VALUE><![CDATA[DGE]]></VALUE>
+  <NAME><![CDATA[Distribution Good E (BOM Taxes with Exempt)]]></NAME>
+  <C_UOM_ID><![CDATA[100]]></C_UOM_ID>
+  <SALESREP_ID><![CDATA[100]]></SALESREP_ID>
+  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+  <ISSTOCKED><![CDATA[Y]]></ISSTOCKED>
+  <ISPURCHASED><![CDATA[Y]]></ISPURCHASED>
+  <ISSOLD><![CDATA[Y]]></ISSOLD>
+  <ISBOM><![CDATA[Y]]></ISBOM>
+  <ISINVOICEPRINTDETAILS><![CDATA[N]]></ISINVOICEPRINTDETAILS>
+  <ISPICKLISTPRINTDETAILS><![CDATA[N]]></ISPICKLISTPRINTDETAILS>
+  <ISVERIFIED><![CDATA[N]]></ISVERIFIED>
+  <M_PRODUCT_CATEGORY_ID><![CDATA[4028E6C72959682B01295ADC1F0A0232]]></M_PRODUCT_CATEGORY_ID>
+  <VOLUME><![CDATA[0]]></VOLUME>
+  <WEIGHT><![CDATA[0]]></WEIGHT>
+  <C_TAXCATEGORY_ID><![CDATA[1955F4CC846840D4832A49BAAC67A45C]]></C_TAXCATEGORY_ID>
+  <DISCONTINUED><![CDATA[N]]></DISCONTINUED>
+  <PROCESSING><![CDATA[N]]></PROCESSING>
+  <PRODUCTTYPE><![CDATA[I]]></PRODUCTTYPE>
+  <M_LOCATOR_ID><![CDATA[96DEDCC179504711A81497DE68900F49]]></M_LOCATOR_ID>
+  <ISPRICEPRINTED><![CDATA[Y]]></ISPRICEPRINTED>
+  <ENFORCE_ATTRIBUTE><![CDATA[N]]></ENFORCE_ATTRIBUTE>
+  <CALCULATED><![CDATA[N]]></CALCULATED>
+  <PRODUCTION><![CDATA[N]]></PRODUCTION>
+  <QTYTYPE><![CDATA[N]]></QTYTYPE>
+  <ISQUANTITYVARIABLE><![CDATA[N]]></ISQUANTITYVARIABLE>
+  <ISDEFERREDREVENUE><![CDATA[N]]></ISDEFERREDREVENUE>
+  <ISDEFERREDEXPENSE><![CDATA[N]]></ISDEFERREDEXPENSE>
+  <BOOKUSINGPOPRICE><![CDATA[N]]></BOOKUSINGPOPRICE>
+  <ISGENERIC><![CDATA[N]]></ISGENERIC>
+  <CREATEVARIANTS><![CDATA[N]]></CREATEVARIANTS>
+  <UPDATEINVARIANTS><![CDATA[N]]></UPDATEINVARIANTS>
+  <MANAGEVARIANTS><![CDATA[N]]></MANAGEVARIANTS>
+</M_PRODUCT>
+
+<M_PRODUCT>
   <M_PRODUCT_ID><![CDATA[3FDFF9456AA74466A9CBBC0FB99F2369]]></M_PRODUCT_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
@@ -1036,6 +1080,50 @@
 </M_PRODUCT>
 
 <M_PRODUCT>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:19:22.834]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:27:00.257]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <VALUE><![CDATA[DGD]]></VALUE>
+  <NAME><![CDATA[Distribution Good D (BOM Taxes)]]></NAME>
+  <C_UOM_ID><![CDATA[100]]></C_UOM_ID>
+  <SALESREP_ID><![CDATA[100]]></SALESREP_ID>
+  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+  <ISSTOCKED><![CDATA[Y]]></ISSTOCKED>
+  <ISPURCHASED><![CDATA[Y]]></ISPURCHASED>
+  <ISSOLD><![CDATA[Y]]></ISSOLD>
+  <ISBOM><![CDATA[Y]]></ISBOM>
+  <ISINVOICEPRINTDETAILS><![CDATA[N]]></ISINVOICEPRINTDETAILS>
+  <ISPICKLISTPRINTDETAILS><![CDATA[N]]></ISPICKLISTPRINTDETAILS>
+  <ISVERIFIED><![CDATA[N]]></ISVERIFIED>
+  <M_PRODUCT_CATEGORY_ID><![CDATA[4028E6C72959682B01295ADC1F0A0232]]></M_PRODUCT_CATEGORY_ID>
+  <VOLUME><![CDATA[0]]></VOLUME>
+  <WEIGHT><![CDATA[0]]></WEIGHT>
+  <C_TAXCATEGORY_ID><![CDATA[1955F4CC846840D4832A49BAAC67A45C]]></C_TAXCATEGORY_ID>
+  <DISCONTINUED><![CDATA[N]]></DISCONTINUED>
+  <PROCESSING><![CDATA[N]]></PROCESSING>
+  <PRODUCTTYPE><![CDATA[I]]></PRODUCTTYPE>
+  <M_LOCATOR_ID><![CDATA[96DEDCC179504711A81497DE68900F49]]></M_LOCATOR_ID>
+  <ISPRICEPRINTED><![CDATA[Y]]></ISPRICEPRINTED>
+  <ENFORCE_ATTRIBUTE><![CDATA[N]]></ENFORCE_ATTRIBUTE>
+  <CALCULATED><![CDATA[N]]></CALCULATED>
+  <PRODUCTION><![CDATA[N]]></PRODUCTION>
+  <QTYTYPE><![CDATA[N]]></QTYTYPE>
+  <ISQUANTITYVARIABLE><![CDATA[N]]></ISQUANTITYVARIABLE>
+  <ISDEFERREDREVENUE><![CDATA[N]]></ISDEFERREDREVENUE>
+  <ISDEFERREDEXPENSE><![CDATA[N]]></ISDEFERREDEXPENSE>
+  <BOOKUSINGPOPRICE><![CDATA[N]]></BOOKUSINGPOPRICE>
+  <ISGENERIC><![CDATA[N]]></ISGENERIC>
+  <CREATEVARIANTS><![CDATA[N]]></CREATEVARIANTS>
+  <UPDATEINVARIANTS><![CDATA[N]]></UPDATEINVARIANTS>
+  <MANAGEVARIANTS><![CDATA[N]]></MANAGEVARIANTS>
+</M_PRODUCT>
+
+<M_PRODUCT>
   <M_PRODUCT_ID><![CDATA[901CAFF074954746970719E6A2910638]]></M_PRODUCT_ID>
   <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
   <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
--- a/referencedata/sampledata/QA_Testing/M_PRODUCTPRICE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/M_PRODUCTPRICE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -1,6 +1,24 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
 <M_PRODUCTPRICE>
+  <M_PRODUCTPRICE_ID><![CDATA[060133493E9942FC908486E7E96E756F]]></M_PRODUCTPRICE_ID>
+  <M_PRICELIST_VERSION_ID><![CDATA[C6648957037F46E79DBE22E9B0117F1B]]></M_PRICELIST_VERSION_ID>
+  <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC1AD40222]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:16:49.605]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:16:49.605]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <PRICELIST><![CDATA[3]]></PRICELIST>
+  <PRICESTD><![CDATA[3]]></PRICESTD>
+  <PRICELIMIT><![CDATA[0]]></PRICELIMIT>
+  <COST><![CDATA[0]]></COST>
+  <ALGORITHM><![CDATA[S]]></ALGORITHM>
+</M_PRODUCTPRICE>
+
+<M_PRODUCTPRICE>
   <M_PRODUCTPRICE_ID><![CDATA[13FACF4645AE4EB89D08D3121AC363DD]]></M_PRODUCTPRICE_ID>
   <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295ADC1D64022C]]></M_PRICELIST_VERSION_ID>
   <M_PRODUCT_ID><![CDATA[A8B10A097DBD4BF5865BA3C844A2299C]]></M_PRODUCT_ID>
@@ -667,6 +685,24 @@
 </M_PRODUCTPRICE>
 
 <M_PRODUCTPRICE>
+  <M_PRODUCTPRICE_ID><![CDATA[59BE500605B34944807BE8AA23203245]]></M_PRODUCTPRICE_ID>
+  <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295ADC17A8021C]]></M_PRICELIST_VERSION_ID>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:29:14.616]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:29:14.616]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <PRICELIST><![CDATA[10]]></PRICELIST>
+  <PRICESTD><![CDATA[10]]></PRICESTD>
+  <PRICELIMIT><![CDATA[0]]></PRICELIMIT>
+  <COST><![CDATA[0]]></COST>
+  <ALGORITHM><![CDATA[S]]></ALGORITHM>
+</M_PRODUCTPRICE>
+
+<M_PRODUCTPRICE>
   <M_PRODUCTPRICE_ID><![CDATA[5A9180EEDDCC41A9BF3348D76D7DDC0B]]></M_PRODUCTPRICE_ID>
   <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295B03CE960244]]></M_PRICELIST_VERSION_ID>
   <M_PRODUCT_ID><![CDATA[EBCD272DC37B4ABBB12B96139E5837BF]]></M_PRODUCT_ID>
@@ -775,6 +811,42 @@
 </M_PRODUCTPRICE>
 
 <M_PRODUCTPRICE>
+  <M_PRODUCTPRICE_ID><![CDATA[B0CA27565EA647FD970AE8036DAD7BD9]]></M_PRODUCTPRICE_ID>
+  <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295ADC1D64022C]]></M_PRICELIST_VERSION_ID>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:28:59.288]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:29:41.885]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <PRICELIST><![CDATA[25]]></PRICELIST>
+  <PRICESTD><![CDATA[25]]></PRICESTD>
+  <PRICELIMIT><![CDATA[0]]></PRICELIMIT>
+  <COST><![CDATA[0]]></COST>
+  <ALGORITHM><![CDATA[S]]></ALGORITHM>
+</M_PRODUCTPRICE>
+
+<M_PRODUCTPRICE>
+  <M_PRODUCTPRICE_ID><![CDATA[BCB0DF0B9FD44A9EA056DB122D62528E]]></M_PRODUCTPRICE_ID>
+  <M_PRICELIST_VERSION_ID><![CDATA[5C45E8C8A0EF4BD386EACA822DC0A85E]]></M_PRICELIST_VERSION_ID>
+  <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC1D07022A]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-04-21 12:16:09.421]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-04-21 12:16:09.421]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <PRICELIST><![CDATA[3]]></PRICELIST>
+  <PRICESTD><![CDATA[3]]></PRICESTD>
+  <PRICELIMIT><![CDATA[0]]></PRICELIMIT>
+  <COST><![CDATA[0]]></COST>
+  <ALGORITHM><![CDATA[S]]></ALGORITHM>
+</M_PRODUCTPRICE>
+
+<M_PRODUCTPRICE>
   <M_PRODUCTPRICE_ID><![CDATA[C4F55819AF964C60924B82D63B992276]]></M_PRODUCTPRICE_ID>
   <M_PRICELIST_VERSION_ID><![CDATA[F3BE529C058447438A75BC8C558EF8EB]]></M_PRICELIST_VERSION_ID>
   <M_PRODUCT_ID><![CDATA[901CAFF074954746970719E6A2910638]]></M_PRODUCT_ID>
@@ -847,6 +919,24 @@
 </M_PRODUCTPRICE>
 
 <M_PRODUCTPRICE>
+  <M_PRODUCTPRICE_ID><![CDATA[E81E1A5E5A53497081E7BE33F15FA2AB]]></M_PRODUCTPRICE_ID>
+  <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295ADC17A8021C]]></M_PRICELIST_VERSION_ID>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:27:12.546]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:27:12.546]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <PRICELIST><![CDATA[3]]></PRICELIST>
+  <PRICESTD><![CDATA[3]]></PRICESTD>
+  <PRICELIMIT><![CDATA[0]]></PRICELIMIT>
+  <COST><![CDATA[0]]></COST>
+  <ALGORITHM><![CDATA[S]]></ALGORITHM>
+</M_PRODUCTPRICE>
+
+<M_PRODUCTPRICE>
   <M_PRODUCTPRICE_ID><![CDATA[E9DB1A8A1C4443E2B83E35EA746509FD]]></M_PRODUCTPRICE_ID>
   <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295B03CFDE0249]]></M_PRICELIST_VERSION_ID>
   <M_PRODUCT_ID><![CDATA[901CAFF074954746970719E6A2910638]]></M_PRODUCT_ID>
@@ -865,6 +955,24 @@
 </M_PRODUCTPRICE>
 
 <M_PRODUCTPRICE>
+  <M_PRODUCTPRICE_ID><![CDATA[EDA1BE6AEB324306AFCFF20FE7328AA2]]></M_PRODUCTPRICE_ID>
+  <M_PRICELIST_VERSION_ID><![CDATA[4028E6C72959682B01295ADC1D64022C]]></M_PRICELIST_VERSION_ID>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:19:45.26]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:19:45.26]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <PRICELIST><![CDATA[15]]></PRICELIST>
+  <PRICESTD><![CDATA[15]]></PRICESTD>
+  <PRICELIMIT><![CDATA[0]]></PRICELIMIT>
+  <COST><![CDATA[0]]></COST>
+  <ALGORITHM><![CDATA[S]]></ALGORITHM>
+</M_PRODUCTPRICE>
+
+<M_PRODUCTPRICE>
   <M_PRODUCTPRICE_ID><![CDATA[EE0DA05301C04E0D9DD08C9C96F0FBA6]]></M_PRODUCTPRICE_ID>
   <M_PRICELIST_VERSION_ID><![CDATA[4E87E6C9E5CB4988A2D953583232E9C8]]></M_PRICELIST_VERSION_ID>
   <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC211E0237]]></M_PRODUCT_ID>
--- a/referencedata/sampledata/QA_Testing/M_PRODUCT_ACCT.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/referencedata/sampledata/QA_Testing/M_PRODUCT_ACCT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -1,6 +1,23 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
 <M_PRODUCT_ACCT>
+  <M_PRODUCT_ACCT_ID><![CDATA[0C4C560D6FE34C7E850C992834AC5D81]]></M_PRODUCT_ACCT_ID>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <C_ACCTSCHEMA_ID><![CDATA[9A68A0F8D72D4580B3EC3CAA00A5E1F0]]></C_ACCTSCHEMA_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:27:56.0]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:27:56.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <P_REVENUE_ACCT><![CDATA[988029814B4D4B19BD7BA9EAB4F1FC29]]></P_REVENUE_ACCT>
+  <P_EXPENSE_ACCT><![CDATA[17263FD54AE64546A89C79D797AEFF4F]]></P_EXPENSE_ACCT>
+  <P_ASSET_ACCT><![CDATA[07840D840D0940CBA1254D1A0CDD64A0]]></P_ASSET_ACCT>
+  <P_COGS_ACCT><![CDATA[F9B6701E65A94F6E804287B808E919BE]]></P_COGS_ACCT>
+</M_PRODUCT_ACCT>
+
+<M_PRODUCT_ACCT>
   <M_PRODUCT_ACCT_ID><![CDATA[0DE318546471430980BFDF2EC3A42D33]]></M_PRODUCT_ACCT_ID>
   <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC2285023B]]></M_PRODUCT_ID>
   <C_ACCTSCHEMA_ID><![CDATA[432EAC71E1B8451E97C7F54718C4A06B]]></C_ACCTSCHEMA_ID>
@@ -120,6 +137,23 @@
 </M_PRODUCT_ACCT>
 
 <M_PRODUCT_ACCT>
+  <M_PRODUCT_ACCT_ID><![CDATA[25D092B3E9BD497190BBAC2DD3E75B18]]></M_PRODUCT_ACCT_ID>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <C_ACCTSCHEMA_ID><![CDATA[9A68A0F8D72D4580B3EC3CAA00A5E1F0]]></C_ACCTSCHEMA_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:19:22.0]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:19:22.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <P_REVENUE_ACCT><![CDATA[988029814B4D4B19BD7BA9EAB4F1FC29]]></P_REVENUE_ACCT>
+  <P_EXPENSE_ACCT><![CDATA[17263FD54AE64546A89C79D797AEFF4F]]></P_EXPENSE_ACCT>
+  <P_ASSET_ACCT><![CDATA[07840D840D0940CBA1254D1A0CDD64A0]]></P_ASSET_ACCT>
+  <P_COGS_ACCT><![CDATA[F9B6701E65A94F6E804287B808E919BE]]></P_COGS_ACCT>
+</M_PRODUCT_ACCT>
+
+<M_PRODUCT_ACCT>
   <M_PRODUCT_ACCT_ID><![CDATA[2D6E637F41A14616AEBEEB4C6A1F1CED]]></M_PRODUCT_ACCT_ID>
   <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC2340023D]]></M_PRODUCT_ID>
   <C_ACCTSCHEMA_ID><![CDATA[9A68A0F8D72D4580B3EC3CAA00A5E1F0]]></C_ACCTSCHEMA_ID>
@@ -308,6 +342,23 @@
 </M_PRODUCT_ACCT>
 
 <M_PRODUCT_ACCT>
+  <M_PRODUCT_ACCT_ID><![CDATA[599AEE9C0B76489EBC4BE8EFA9CAA9FC]]></M_PRODUCT_ACCT_ID>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <C_ACCTSCHEMA_ID><![CDATA[432EAC71E1B8451E97C7F54718C4A06B]]></C_ACCTSCHEMA_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:19:22.0]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:19:22.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <P_REVENUE_ACCT><![CDATA[56821CE085F846D7AC31278C253B4534]]></P_REVENUE_ACCT>
+  <P_EXPENSE_ACCT><![CDATA[DEFD960D4AA8470596B125D1C051D68E]]></P_EXPENSE_ACCT>
+  <P_ASSET_ACCT><![CDATA[95E4C0C233994DE283922DA5221EBB9B]]></P_ASSET_ACCT>
+  <P_COGS_ACCT><![CDATA[7EBB52E1D49F4A7AB660E8AEBE53E88C]]></P_COGS_ACCT>
+</M_PRODUCT_ACCT>
+
+<M_PRODUCT_ACCT>
   <M_PRODUCT_ACCT_ID><![CDATA[5D50E01290634D42B17031310412BD58]]></M_PRODUCT_ACCT_ID>
   <M_PRODUCT_ID><![CDATA[A8B10A097DBD4BF5865BA3C844A2299C]]></M_PRODUCT_ID>
   <C_ACCTSCHEMA_ID><![CDATA[432EAC71E1B8451E97C7F54718C4A06B]]></C_ACCTSCHEMA_ID>
@@ -580,6 +631,23 @@
 </M_PRODUCT_ACCT>
 
 <M_PRODUCT_ACCT>
+  <M_PRODUCT_ACCT_ID><![CDATA[A51E20E1979E403F8F0854DC245F8407]]></M_PRODUCT_ACCT_ID>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <C_ACCTSCHEMA_ID><![CDATA[432EAC71E1B8451E97C7F54718C4A06B]]></C_ACCTSCHEMA_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:27:56.0]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:27:56.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <P_REVENUE_ACCT><![CDATA[56821CE085F846D7AC31278C253B4534]]></P_REVENUE_ACCT>
+  <P_EXPENSE_ACCT><![CDATA[DEFD960D4AA8470596B125D1C051D68E]]></P_EXPENSE_ACCT>
+  <P_ASSET_ACCT><![CDATA[95E4C0C233994DE283922DA5221EBB9B]]></P_ASSET_ACCT>
+  <P_COGS_ACCT><![CDATA[7EBB52E1D49F4A7AB660E8AEBE53E88C]]></P_COGS_ACCT>
+</M_PRODUCT_ACCT>
+
+<M_PRODUCT_ACCT>
   <M_PRODUCT_ACCT_ID><![CDATA[B1B2B86D8D2847BBAEE47EFB82F72B15]]></M_PRODUCT_ACCT_ID>
   <M_PRODUCT_ID><![CDATA[4028E6C72959682B01295ADC1E6E0230]]></M_PRODUCT_ID>
   <C_ACCTSCHEMA_ID><![CDATA[432EAC71E1B8451E97C7F54718C4A06B]]></C_ACCTSCHEMA_ID>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/referencedata/sampledata/QA_Testing/M_PRODUCT_BOM.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,71 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<data>
+<M_PRODUCT_BOM>
+  <M_PRODUCT_BOM_ID><![CDATA[2E763107B5844760B4895E62CD8612F0]]></M_PRODUCT_BOM_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:28:42.586]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:28:42.586]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <LINE><![CDATA[20]]></LINE>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <M_PRODUCTBOM_ID><![CDATA[4028E6C72959682B01295ADC211E0237]]></M_PRODUCTBOM_ID>
+  <BOMQTY><![CDATA[3]]></BOMQTY>
+  <BOMTYPE><![CDATA[P]]></BOMTYPE>
+  <BOMPRICE><![CDATA[5]]></BOMPRICE>
+</M_PRODUCT_BOM>
+
+<M_PRODUCT_BOM>
+  <M_PRODUCT_BOM_ID><![CDATA[4B47F862F9474E7EA55FB43E9E2E49B8]]></M_PRODUCT_BOM_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-22 16:28:24.526]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-22 16:28:24.526]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <LINE><![CDATA[10]]></LINE>
+  <M_PRODUCT_ID><![CDATA[144339F3C9CA4B32986754D3BB0B6D7F]]></M_PRODUCT_ID>
+  <M_PRODUCTBOM_ID><![CDATA[A8B10A097DBD4BF5865BA3C844A2299C]]></M_PRODUCTBOM_ID>
+  <BOMQTY><![CDATA[1]]></BOMQTY>
+  <BOMTYPE><![CDATA[P]]></BOMTYPE>
+  <BOMPRICE><![CDATA[15]]></BOMPRICE>
+</M_PRODUCT_BOM>
+
+<M_PRODUCT_BOM>
+  <M_PRODUCT_BOM_ID><![CDATA[50330A419F0F4E198BF79B9968D55745]]></M_PRODUCT_BOM_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:20:22.27]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:20:22.27]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <LINE><![CDATA[20]]></LINE>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <M_PRODUCTBOM_ID><![CDATA[4028E6C72959682B01295ADC1D07022A]]></M_PRODUCTBOM_ID>
+  <BOMQTY><![CDATA[1]]></BOMQTY>
+  <BOMTYPE><![CDATA[P]]></BOMTYPE>
+  <BOMPRICE><![CDATA[5]]></BOMPRICE>
+</M_PRODUCT_BOM>
+
+<M_PRODUCT_BOM>
+  <M_PRODUCT_BOM_ID><![CDATA[A0B0B69525A747FCA43510628F0C3271]]></M_PRODUCT_BOM_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2015-05-19 13:20:08.911]]></CREATED>
+  <CREATEDBY><![CDATA[100]]></CREATEDBY>
+  <UPDATED><![CDATA[2015-05-19 13:20:08.911]]></UPDATED>
+  <UPDATEDBY><![CDATA[100]]></UPDATEDBY>
+  <LINE><![CDATA[10]]></LINE>
+  <M_PRODUCT_ID><![CDATA[8581A3A503C44FC18727516E12A85575]]></M_PRODUCT_ID>
+  <M_PRODUCTBOM_ID><![CDATA[4028E6C72959682B01295ADC211E0237]]></M_PRODUCTBOM_ID>
+  <BOMQTY><![CDATA[1]]></BOMQTY>
+  <BOMTYPE><![CDATA[P]]></BOMTYPE>
+  <BOMPRICE><![CDATA[3]]></BOMPRICE>
+</M_PRODUCT_BOM>
+
+</data>
--- a/src-core/src/org/openbravo/modulescript/ModuleScript.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-core/src/org/openbravo/modulescript/ModuleScript.java	Mon Jul 27 19:05:39 2015 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2010 Openbravo S.L.U.
+ * Copyright (C) 2010-2015 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -12,6 +12,7 @@
 package org.openbravo.modulescript;
 
 import java.io.File;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.apache.tools.ant.BuildException;
@@ -19,7 +20,7 @@
 import org.openbravo.database.ConnectionProvider;
 
 /**
- * Clases extending ModuleScript can be included in Openbravo Core or a module and will be
+ * Classes extending ModuleScript can be included in Openbravo Core or a module and will be
  * automatically executed when the system is rebuilt (technically in: update.database and
  * update.database.mod)
  * 
@@ -38,6 +39,84 @@
   public abstract void execute();
 
   /**
+   * This method prints some log information before calling the execute() method
+   */
+  private void doExecute() {
+    log4j.info("Executing moduleScript: " + this.getClass().getName());
+    execute();
+  }
+
+  /**
+   * This method checks whether the ModuleScript can be executed before invoke the doExecute()
+   * method
+   * 
+   * @param modulesVersionMap
+   *          A data structure that contains module versions mapped by module id
+   */
+  public final void preExecute(Map<String, OpenbravoVersion> modulesVersionMap) {
+    ModuleScriptExecutionLimits executionLimits = getModuleScriptExecutionLimits();
+    if (executionLimits == null || executionLimits.getModuleId() == null
+        || modulesVersionMap == null || modulesVersionMap.size() == 0) {
+      doExecute();
+      return;
+    }
+    if (!executionLimits.areCorrect()) {
+      log4j.error("ModuleScript " + this.getClass().getName()
+          + " not executed because its execution limits are incorrect. "
+          + "Last version should be greater or equal than first version.");
+      return;
+    }
+    OpenbravoVersion currentVersion = modulesVersionMap.get(executionLimits.getModuleId());
+    OpenbravoVersion firstVersion = executionLimits.getFirstVersion();
+    OpenbravoVersion lastVersion = executionLimits.getLastVersion();
+    String additionalInfo = "";
+    if (currentVersion == null) {
+      // Dependent module is being installed
+      if (executeOnInstall()) {
+        doExecute();
+        return;
+      }
+      additionalInfo = this.getClass().getName()
+          + " is configured to not execute it during dependent module installation.";
+    } else {
+      // Dependent module is already installed
+      if ((firstVersion == null || firstVersion.compareTo(currentVersion) < 0)
+          && (lastVersion == null || lastVersion.compareTo(currentVersion) > 0)) {
+        doExecute();
+        return;
+      }
+      additionalInfo = "Dependent module current version (" + currentVersion
+          + ") is not between moduleScript execution limits: first version = " + firstVersion
+          + ", last version = " + lastVersion;
+
+    }
+    log4j.debug("Not necessary to execute moduleScript: " + this.getClass().getName());
+    log4j.debug(additionalInfo);
+  }
+
+  /**
+   * This method can be overridden by the ModuleScript subclasses, to specify the module and the
+   * limit versions to define whether the ModuleScript should be executed or not.
+   * 
+   * @return a ModuleScriptExecutionLimits object which contains the dependent module id and the
+   *         first and last versions of the module that define the execution logic.
+   */
+  protected ModuleScriptExecutionLimits getModuleScriptExecutionLimits() {
+    return null;
+  }
+
+  /**
+   * This method can be overridden by the ModuleScript subclasses, to specify if the ModuleScript
+   * should be executed when installing the dependent module.
+   * 
+   * @return a boolean that indicates if the ModuleScript should be executed when installing the
+   *         dependent module.
+   */
+  protected boolean executeOnInstall() {
+    return true;
+  }
+
+  /**
    * This method returns a connection provider, which can be used to execute statements in the
    * database
    * 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/modulescript/ModuleScriptExecutionLimits.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,88 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2015 Openbravo S.L.U.
+ * Licensed under the Apache Software License version 2.0
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to  in writing,  software  distributed
+ * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
+ * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
+ * specific language governing permissions and limitations under the License.
+ ************************************************************************************
+ */
+package org.openbravo.modulescript;
+
+/**
+ * This class is used by ModuleScript objects to store the limits that define if they should be
+ * executed or not. This class holds a String with a module version id, together with the first and
+ * last module versions that establish under which versions a ModuleScript must be executed.
+ */
+public class ModuleScriptExecutionLimits {
+  private String moduleId;
+  private OpenbravoVersion firstVersion;
+  private OpenbravoVersion lastVersion;
+  private boolean correct;
+
+  /**
+   * Basic ModuleScriptExecutionLimits constructor. Used to define a dependency between a
+   * ModuleScript and a module. When upgrading the module whose id is moduleId, the ModuleScript
+   * will be executed only if its version before upgrading is higher than firstVersion and lower
+   * than lastVersion. Otherwise it will not be executed.
+   * 
+   * @param moduleId
+   *          A String with the module id
+   * @param firstVersion
+   *          An OpenbravoVersion which defines the first version of the module with id = moduleId
+   *          since the ModuleScript can be executed
+   * @param lastVersion
+   *          An OpenbravoVersion with the last version of the module with id = moduleId which
+   *          allows the ModuleScript execution
+   */
+  public ModuleScriptExecutionLimits(String moduleId, OpenbravoVersion firstVersion,
+      OpenbravoVersion lastVersion) {
+    this.moduleId = moduleId;
+    this.firstVersion = firstVersion;
+    this.lastVersion = lastVersion;
+    if (firstVersion != null && lastVersion != null && firstVersion.compareTo(lastVersion) > 0) {
+      correct = false;
+    } else {
+      correct = true;
+    }
+  }
+
+  /**
+   * Returns the ModuleScript dependent module id
+   * 
+   * @return a String with the module id
+   */
+  public String getModuleId() {
+    return moduleId;
+  }
+
+  /**
+   * Returns the first version of the dependent module for which the ModuleScript should be
+   * executed.
+   * 
+   * @return a OpenbravoVersion with the first execution version of the dependent module
+   */
+  public OpenbravoVersion getFirstVersion() {
+    return firstVersion;
+  }
+
+  /**
+   * Returns the last version of the dependent module for which the ModuleScript should be executed.
+   * 
+   * @return a OpenbravoVersion with the last execution version of the dependent module
+   */
+  public OpenbravoVersion getLastVersion() {
+    return lastVersion;
+  }
+
+  /**
+   * This method returns true when the last version and first version values are correctly defined.
+   * 
+   * @return false in case first version is higher than last version. Otherwise, it returns true.
+   */
+  public boolean areCorrect() {
+    return correct;
+  }
+}
--- a/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java	Mon Jul 27 19:05:39 2015 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2010-2014 Openbravo S.L.U.
+ * Copyright (C) 2010-2015 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -15,7 +15,9 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.apache.tools.ant.BuildException;
@@ -27,6 +29,7 @@
 
   private File basedir;
   private String moduleJavaPackage;
+  private Map<String, OpenbravoVersion> modulesVersionMap;
 
   @Override
   public void execute() {
@@ -60,12 +63,11 @@
         if (myClass.getGenericSuperclass().equals(
             Class.forName("org.openbravo.modulescript.ModuleScript"))) {
           Object instance = myClass.newInstance();
-          log4j.info("Executing moduleScript: " + s);
           callExecute(myClass, instance);
         }
       } catch (Exception e) {
         log4j.error("Error executing moduleScript: " + s, e);
-        throw new BuildException("Execution of moduleScript " + s + "failed.");
+        throw new BuildException("Execution of moduleScript " + s + " failed.");
       }
     }
   }
@@ -73,24 +75,72 @@
   @SuppressWarnings("unchecked")
   private ArrayList<String> callExecute(Class<?> myClass, Object instance)
       throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
-    return (ArrayList<String>) myClass.getMethod("execute", new Class[0]).invoke(instance,
-        new Object[0]);
+    return (ArrayList<String>) myClass.getMethod("preExecute", new Class[] { Map.class }).invoke(
+        instance, new Object[] { getModulesVersionMap() });
   }
 
+  /**
+   * Returns a File with the base directory
+   * 
+   * @return a File with the base directory
+   */
   public File getBasedir() {
     return basedir;
   }
 
+  /**
+   * Sets the base directory
+   * 
+   * @param basedir
+   *          File used to set the base directory
+   */
   public void setBasedir(File basedir) {
     this.basedir = basedir;
   }
 
+  /**
+   * Returns the java package
+   * 
+   * @return a String with the module java package
+   */
   public String getModuleJavaPackage() {
     return moduleJavaPackage;
   }
 
+  /**
+   * Sets the java package
+   * 
+   * @param moduleJavaPackage
+   *          String to set the java package
+   */
   public void setModuleJavaPackage(String moduleJavaPackage) {
     this.moduleJavaPackage = moduleJavaPackage;
   }
 
+  /**
+   * Creates the OpenbravoVersion map from a map of version strings
+   * 
+   * @param currentVersionsMap
+   *          A data structure that contains Strings with module versions mapped by module id
+   */
+  public void setModulesVersionMap(Map<String, String> currentVersionsMap) {
+    modulesVersionMap = new HashMap<String, OpenbravoVersion>();
+    for (Map.Entry<String, String> entry : currentVersionsMap.entrySet()) {
+      try {
+        modulesVersionMap.put(entry.getKey(), new OpenbravoVersion(entry.getValue()));
+      } catch (Exception ex) {
+        log4j.error(
+            "Not possible to recover the current version of module with id: " + entry.getKey(), ex);
+      }
+    }
+  }
+
+  /**
+   * Returns a map with the current module versions
+   * 
+   * @return A data structure that contains module versions mapped by module id
+   */
+  public Map<String, OpenbravoVersion> getModulesVersionMap() {
+    return this.modulesVersionMap;
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/modulescript/OpenbravoVersion.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,112 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.modulescript;
+
+/**
+ * This class represents an Openbravo ERP version number. It is designed to compare Openbravo ERP
+ * version numbers
+ * 
+ * @author adrian
+ */
+public class OpenbravoVersion implements Comparable<OpenbravoVersion> {
+
+  private int major1;
+  private int major2;
+  private int minor;
+
+  /**
+   * Creates a new Openbravo version object based on its three version numbers.
+   * 
+   * @param major1
+   *          the major1 version number
+   * @param major2
+   *          the major2 version number
+   * @param minor
+   *          the minor version number
+   */
+  public OpenbravoVersion(int major1, int major2, int minor) {
+    this.major1 = major1;
+    this.major2 = major2;
+    this.minor = minor;
+  }
+
+  /**
+   * Creates a new Openbravo version object based on its <code>String</code> representation.
+   * 
+   * @param version
+   *          the version representation
+   */
+  public OpenbravoVersion(String version) {
+
+    String[] numbers = version.split("\\.");
+
+    if (numbers.length != 3) {
+      throw new IllegalArgumentException("Version must consist in three numbers separated by .");
+    }
+    this.major1 = Integer.valueOf(numbers[0]);
+    this.major2 = Integer.valueOf(numbers[1]);
+    this.minor = Integer.valueOf(numbers[2]);
+  }
+
+  /**
+   * Gets the Major1 version number
+   * 
+   * @return The Major1 version number
+   */
+  public int getMajor1() {
+    return major1;
+  }
+
+  /**
+   * Returns the Major1 version number
+   * 
+   * @return The Major2 version number
+   */
+  public int getMajor2() {
+    return major2;
+  }
+
+  /**
+   * Returns the Minor version number
+   * 
+   * @return The Minor version number
+   */
+  public int getMinor() {
+    return minor;
+  }
+
+  public int compareTo(OpenbravoVersion o) {
+    if (major1 == o.major1) {
+      if (major2 == o.major2) {
+        return (minor < o.minor ? -1 : (minor == o.minor ? 0 : 1));
+      } else {
+        return major2 < o.major2 ? -1 : 1;
+      }
+    } else {
+      return major1 < o.major1 ? -1 : 1;
+    }
+  }
+
+  @Override
+  public String toString() {
+    return Integer.toString(major1) + "." + Integer.toString(major2) + "."
+        + Integer.toString(minor);
+  }
+}
--- a/src-db/database/build-create.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/build-create.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -196,8 +196,6 @@
         CREATE ROLE ${bbdd.user} LOGIN PASSWORD '${bbdd.password}'
                SUPERUSER CREATEDB CREATEROLE
                VALID UNTIL 'infinity';
-        
-        UPDATE pg_authid SET rolcatupdate=true WHERE rolname='${bbdd.user}';
       </transaction>
     </sql>
     <sql driver="${bbdd.driver}" url="${bbdd.url}/postgres" userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" autocommit="true">
--- a/src-db/database/model/functions/C_GETWITHHOLDING.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_GETWITHHOLDING.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -16,7 +16,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-2006 Openbravo SLU
+* All portions are Copyright (C) 2001-2015 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  _Francesco Finamore_______________________.
 ************************************************************************/
@@ -44,7 +44,7 @@
 
 TotCompensi NUMBER;
 base_amount NUMBER;
-Withholding varchar(32);
+Withholding NUMBER;
 TaxInps NUMBER;
 TaxAmount NUMBER;
 
--- a/src-db/database/model/functions/C_INVOICELINETAX_ROUNDING.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_INVOICELINETAX_ROUNDING.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -10,6 +10,9 @@
       <parameter name="p_netamount" type="NUMERIC" mode="in">
         <default/>
       </parameter>
+      <parameter name="p_linefrom" type="NUMERIC" mode="in">
+        <default><![CDATA[0]]></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
@@ -38,17 +41,18 @@
   v_expected_tax_amt := p_grossamount - p_netamount;
   SELECT SUM(taxamt) INTO v_current_tax_amt
   FROM c_invoicelinetax
-  WHERE c_invoiceline_id = p_invoiceline_id;
+  WHERE c_invoiceline_id = p_invoiceline_id and line > p_linefrom;
   IF (v_expected_tax_amt <> v_current_tax_amt) THEN
     FOR cur_invoicelinetax IN (
-      SELECT c_invoicelinetax_id
+      SELECT c_invoicelinetax_id, c_tax_id
       FROM c_invoicelinetax
-      WHERE c_invoiceline_id = p_invoiceline_id
-      ORDER BY taxamt desc
+      WHERE c_invoiceline_id = p_invoiceline_id and line > p_linefrom
+      ORDER BY ABS(taxamt) desc
     ) LOOP
       UPDATE c_invoicelinetax
       SET taxamt = taxamt - (v_current_tax_amt - v_expected_tax_amt)
       WHERE c_invoicelinetax_id  = cur_invoicelinetax.c_invoicelinetax_id ;
+      C_INVOICELINETAX_ROUNDING_AMT(p_invoiceline_id, cur_invoicelinetax.c_tax_id, v_expected_tax_amt - v_current_tax_amt, p_linefrom);
       EXIT;
     END LOOP;
   END IF;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/functions/C_INVOICELINETAX_ROUNDING_AMT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+  <database name="FUNCTION C_INVOICELINETAX_ROUNDING_AMT">
+    <function name="C_INVOICELINETAX_ROUNDING_AMT" type="NULL">
+      <parameter name="p_invoiceline_id" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_tax_id" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_diff_amount" type="NUMERIC" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_linefrom" type="NUMERIC" mode="in">
+        <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
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2015 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+-- Variables
+  v_ResultStr VARCHAR(2000):='';
+  TYPE RECORD IS REF CURSOR;
+  cur_invoicelinetax RECORD;
+  
+BEGIN --BODY
+  FOR cur_invoicelinetax IN (
+    SELECT c_invoicelinetax_id, c_tax_id
+    FROM c_invoicelinetax
+    WHERE  c_invoiceline_id = p_invoiceline_id and line > p_linefrom
+    AND c_tax_id = (SELECT tb.c_tax_id FROM c_tax tb WHERE tb.c_taxbase_id = p_tax_id)
+  ) LOOP
+      UPDATE c_invoicelinetax
+      SET taxbaseamt = taxbaseamt + p_diff_amount
+      WHERE c_invoicelinetax_id  = cur_invoicelinetax.c_invoicelinetax_id;
+      C_INVOICELINETAX_ROUNDING_AMT(p_invoiceline_id, cur_invoicelinetax.c_tax_id, p_diff_amount, p_linefrom);
+  END LOOP;
+EXCEPTION
+  WHEN OTHERS THEN
+  v_ResultStr:= '@ERROR=' || SQLERRM;
+  DBMS_OUTPUT.PUT_LINE(v_ResultStr) ;
+  RAISE;
+END C_INVOICELINETAX_ROUNDING_AMT
+]]></body>
+    </function>
+  </database>
--- a/src-db/database/model/functions/C_INVOICETAX_ROUNDING.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_INVOICETAX_ROUNDING.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -51,7 +51,7 @@
       FROM c_invoicetax
       WHERE c_invoice_id = p_invoice_id
         AND recalculate = 'Y'
-      ORDER BY taxamt desc
+      ORDER BY ABS(taxamt) desc
     ) LOOP
       UPDATE c_invoicetax
       SET taxamt = taxamt - (v_current_gross_amt - COALESCE(p_grandtotal, 0))
--- a/src-db/database/model/functions/C_INVOICE_CREATE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_INVOICE_CREATE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -139,7 +139,8 @@
           ol.A_Asset_ID,
           ol.C_Costcenter_ID,
           ol.User1_ID, 
-          ol.User2_ID
+          ol.User2_ID,
+          ol.QtyOrdered
         FROM M_INOUT s, M_INOUTLINE sl
         RIGHT JOIN C_ORDERLINE ol
           ON sl.C_OrderLine_ID=ol.C_OrderLine_ID
@@ -731,7 +732,8 @@
                         ChargeAmt, C_UOM_ID,
                         C_Tax_ID,  --MODIFIED BY F.IRIAZABAL
                         QuantityOrder, M_Product_Uom_ID, PriceStd,
-                        m_attributesetinstance_id, taxbaseamt,
+                        m_attributesetinstance_id, 
+                        taxbaseamt,
                         gross_unit_price, line_gross_amount,
                         grosspricestd, grosspricelist,
                         isdeferred, defplantype, periodnumber, c_period_id, 
@@ -749,7 +751,8 @@
                         ptr_sl.ChargeAmt, ptr_sl.C_UOM_ID,
                         ptr_sl.C_Tax_ID,  --MODIFIED BY F.IRIAZABAL
                         ptr_sl.QuantityOrder, ptr_sl.M_Product_Uom_ID, ptr_sl.PriceStd,
-                        ptr_sl.m_attributesetinstance_id, ptr_sl.taxbaseamt,
+                        ptr_sl.m_attributesetinstance_id,
+                        CASE WHEN ptr_sl.QtyOrdered != 0 THEN C_Currency_Round(ptr_sl.taxbaseamt*ptr_sl.MovementQty/ptr_sl.QtyOrdered, Cur_Order.C_Currency_ID, NULL) ELSE ptr_sl.taxbaseamt END,
                         ptr_sl.gross_unit_price, C_Currency_Round(ptr_sl.MovementQty*ptr_sl.gross_unit_price, Cur_Order.C_Currency_ID, NULL),
                         COALESCE(ptr_sl.grosspricestd,0), COALESCE(ptr_sl.grosspricelist,0),
                         v_isdeferred_inv, v_defplantype_inv, v_periodnumber_inv, v_period_inv,
@@ -911,7 +914,7 @@
                 pl.istaxincluded,
                 ol.grosspricestd,
                 ol.grosspricelist, 
-                sl.explode, sl.bom_parent_id
+                sl.explode, sl.bom_parent_id, ol.qtyordered
               FROM M_INOUT sh,
                 M_INOUTLINE sl,
                 C_ORDER o,
@@ -1283,7 +1286,8 @@
                     ChargeAmt, C_UOM_ID,
                     C_Tax_ID,  --MODIFIED BY F.IRIAZABAL
                     QuantityOrder, M_Product_Uom_ID, PriceStd,
-                    m_attributesetinstance_id, taxbaseamt,
+                    m_attributesetinstance_id, 
+                    taxbaseamt,
                     gross_unit_price, line_gross_amount,
                     grosspricestd, grosspricelist,
                     isdeferred, defplantype, periodnumber, c_period_id,
@@ -1301,7 +1305,8 @@
                     Cur_InvoiceSchedule.Line_ChargeAmt, Cur_InvoiceSchedule.C_UOM_ID,
                     Cur_InvoiceSchedule.C_Tax_ID,  --MODIFIED BY F.IRIAZABAL
                     Cur_InvoiceSchedule.QuantityOrder, Cur_InvoiceSchedule.M_Product_Uom_ID, Cur_InvoiceSchedule.PriceStd,
-                    Cur_InvoiceSchedule.m_attributesetinstance_id, Cur_InvoiceSchedule.taxbaseamt,
+                    Cur_InvoiceSchedule.m_attributesetinstance_id, 
+                    CASE WHEN Cur_InvoiceSchedule.QtyOrdered != 0 THEN C_Currency_Round(Cur_InvoiceSchedule.taxbaseamt*Cur_InvoiceSchedule.MovementQty/Cur_InvoiceSchedule.QtyOrdered, Cur_InvoiceSchedule.C_Currency_ID, NULL) ELSE Cur_InvoiceSchedule.taxbaseamt END,
                     Cur_InvoiceSchedule.gross_unit_price, C_Currency_Round(Cur_InvoiceSchedule.MovementQty*Cur_InvoiceSchedule.gross_unit_price, Cur_InvoiceSchedule.C_Currency_ID, NULL),
                     COALESCE(Cur_InvoiceSchedule.grosspricestd,0), COALESCE(Cur_InvoiceSchedule.grosspricelist,0),
                     v_isdeferred_inv, v_defplantype_inv, v_periodnumber_inv, v_period_inv,
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -641,7 +641,8 @@
             now(), C_PaymentTerm_ID, C_BPartner_ID, C_BPartner_Location_ID,
             AD_User_ID, POReference, DateOrdered, IsDiscountPrinted,
             C_Currency_ID, PaymentRule, C_Charge_ID, ChargeAmt * -1,
-            TotalLines * -1, GrandTotal * -1, M_PriceList_ID, C_Campaign_ID,
+            0, 0, --Totals are recalculed adding invoice lines
+            M_PriceList_ID, C_Campaign_ID,
             C_Project_ID, C_Activity_ID, AD_OrgTrx_ID, User1_ID,
             User2_ID, fin_paymentmethod_id, C_CostCenter_ID,
             A_Asset_ID
@@ -1313,109 +1314,17 @@
   END IF;--FINISH_PROCESS
   IF (NOT FINISH_PROCESS AND NOT END_PROCESSING) THEN
     /**************************************************************************
-     * Calculate Invoice Taxes and Totals
+     * Calculate Invoice Withholding Tax
      *************************************************************************/
-    DECLARE
-      Cur_Tax RECORD;
-      Cur_MultiTax RECORD;
-      xTaxBaseAmt NUMBER:=0;
-      xTaxAmt NUMBER:=0;
-      v_taxnorecalculable NUMBER:=0;
-      v_PreviousTaxAmt NUMBER:=0;
-      HeaderNotAdded BOOLEAN:=TRUE;
-      v_LineNo NUMBER:=0;
-      v_ActualBaseAmt NUMBER;
-      v_FirstLine BOOLEAN;
-      v_C_InvoiceTax_ID VARCHAR2(32);
-      
-    BEGIN
-      v_ResultStr:='DeleteOldTaxes';
-      DELETE FROM C_INVOICELINETAX
-      WHERE C_InvoiceLine_ID IN (SELECT C_InvoiceLine_ID from C_InvoiceLine WHERE C_Invoice_ID = v_Record_ID);
-      DELETE FROM C_INVOICETAX
-      WHERE C_Invoice_ID=v_Record_ID
-        AND Recalculate = 'Y';
-      -- Update line if recalculate='N'
-      FOR Cur_TaxMAct IN
-        ( SELECT C_INVOICETAX_ID FROM C_INVOICETAX
-          WHERE C_Invoice_ID=v_Record_ID
-          AND Recalculate = 'N'
-        )
-      LOOP
-        v_LineNo:=v_LineNo+10;
-        UPDATE C_INVOICETAX SET line=v_LineNo WHERE C_INVOICETAX_ID=Cur_TaxMAct.C_INVOICETAX_ID;   
-      END LOOP;
-      -- For all Tax Rates
-      v_ResultStr:='InsertNewTaxes';
-      FOR Cur_Tax IN
-        (SELECT l.C_InvoiceLine_ID, l.C_Tax_ID, i.IsTaxIncluded,
-              COALESCE(SUM(l.LineNetAmt),0) + COALESCE(SUM(l.ChargeAmt), 0) AS LineNetAmt,
-              COALESCE(SUM(l.TaxBaseAmt), 0) + COALESCE(SUM(l.ChargeAmt), 0) AS TaxBaseAmt,
-              COALESCE(SUM(i.ChargeAmt), 0) AS HeaderNet,
-              t.Rate, t.IsSummary, c.StdPrecision, t.Cascade, t.BaseAmount,
-              l.line_gross_amount
-         FROM C_INVOICE i, C_INVOICELINE l, C_TAX t, C_CURRENCY c
-         WHERE i.C_Invoice_ID=l.C_Invoice_ID
-           AND i.C_Invoice_ID=v_Record_ID -- Parameter
-           AND l.C_Tax_ID=t.C_Tax_ID
-           AND i.C_Currency_ID=c.C_Currency_ID
-         GROUP BY l.C_InvoiceLine_ID, l.C_Tax_ID,i.IsTaxIncluded, t.Rate, t.IsSummary,
-              c.StdPrecision, t.Cascade, t.BaseAmount, l.line_gross_amount
-         ORDER BY 4 DESC
-        )
-      LOOP
-        xTaxBaseAmt:=Cur_Tax.LineNetAmt;
-        v_TotalLines:=v_TotalLines + xTaxBaseAmt; -- w/o Header Freight/Charge
-        IF (HeaderNotAdded) THEN -- add header to first
-          HeaderNotAdded:=FALSE;
-          xTaxBaseAmt:=xTaxBaseAmt + Cur_Tax.HeaderNet;
-        END IF;
-        C_INVOICELINETAX_INSERT(v_Org_ID, v_Record_ID, Cur_Tax.C_InvoiceLine_ID, v_UpdatedBy, Cur_Tax.C_Tax_ID, Cur_Tax.C_Tax_ID, Cur_Tax.LineNetAmt, Cur_Tax.TaxBaseAmt, Cur_Tax.StdPrecision);
-        IF (v_istaxincluded = 'Y') THEN
-          C_INVOICELINETAX_ROUNDING(cur_tax.c_invoiceline_id, cur_tax.line_gross_amount, cur_tax.linenetamt);
-        END IF;
-
-      END LOOP; -- Insert New Taxes
       -- Update Header
       IF (v_IsSOTrx = 'N') THEN
         SELECT c_getwithholding(v_record_id) INTO withholdamount FROM dual;
       ELSE
         withholdamount:=0;
       END IF;
-
-      IF (v_istaxincluded = 'Y') THEN
-        SELECT COALESCE(SUM(TaxAmt),0) INTO v_TaxNoRecalculable
-        FROM C_INVOICETAX
-        WHERE C_Invoice_ID = v_Record_ID
-          AND Recalculate = 'N';
-        SELECT COALESCE(SUM(line_gross_amount), 0) INTO v_grandtotal
-        FROM c_invoiceline
-        WHERE c_invoice_id = v_record_id;
-        v_grandtotal := v_grandtotal + v_taxnorecalculable;
-      ELSE
-        SELECT COALESCE(SUM(TAXAMT), 0) INTO v_GrandTotal
-        FROM C_INVOICETAX
-        WHERE C_INVOICE_ID = v_Record_ID;
-        v_GrandTotal:=v_GrandTotal+ v_TotalLines;
-      END IF;
       UPDATE C_INVOICE
-      SET TotalLines=v_TotalLines,
-          GrandTotal=v_GrandTotal,
-          withholdingamount = withholdamount
+      SET withholdingamount = withholdamount
       WHERE C_Invoice_ID=v_Record_ID;
-      IF (v_istaxincluded = 'Y') THEN
-        C_INVOICETAX_ROUNDING(v_Record_ID, v_GrandTotal - v_taxnorecalculable, v_TotalLines);
-      END IF;
-      DBMS_OUTPUT.PUT_LINE('withholdingamount=' || withholdamount);
-      DBMS_OUTPUT.PUT_LINE('GrandTotal=' || v_GrandTotal) ;
-    END; -- Calculate Tax and Totals
-    -- Synchronize Client/Org Ownership
-    v_ResultStr:='SyncOwnershipClient';
-    UPDATE C_INVOICELINE
-    SET AD_Client_ID=v_Client_ID
-    WHERE C_Invoice_ID=v_Record_ID
-      AND AD_Client_ID<>v_Client_ID;
-
   END IF;--FINISH_PROCESS
   IF (NOT FINISH_PROCESS AND NOT END_PROCESSING) THEN
     /**************************************************************************
--- a/src-db/database/model/functions/C_ORDERLINETAX_ROUNDING.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_ORDERLINETAX_ROUNDING.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -10,6 +10,9 @@
       <parameter name="p_netamount" type="NUMERIC" mode="in">
         <default/>
       </parameter>
+      <parameter name="p_linefrom" type="NUMERIC" mode="in">
+        <default><![CDATA[0]]></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
@@ -38,17 +41,18 @@
   v_expected_tax_amt := p_grossamount - p_netamount;
   SELECT SUM(taxamt) INTO v_current_tax_amt
   FROM c_orderlinetax
-  WHERE c_orderline_id = p_orderline_id;
+  WHERE c_orderline_id = p_orderline_id and line > p_linefrom;
   IF (v_expected_tax_amt <> v_current_tax_amt) THEN
     FOR cur_orderlinetax IN (
-      SELECT c_orderlinetax_id
+      SELECT c_orderlinetax_id, c_tax_id
       FROM c_orderlinetax
-      WHERE c_orderline_id = p_orderline_id
-      ORDER BY taxamt desc
+      WHERE c_orderline_id = p_orderline_id and line > p_linefrom
+      ORDER BY ABS(taxamt) desc
     ) LOOP
       UPDATE c_orderlinetax
       SET taxamt = taxamt - (v_current_tax_amt - v_expected_tax_amt)
       WHERE c_orderlinetax_id  = cur_orderlinetax.c_orderlinetax_id ;
+      C_ORDERLINETAX_ROUNDING_AMT(p_orderline_id, cur_orderlinetax.c_tax_id, v_expected_tax_amt - v_current_tax_amt, p_linefrom);
       EXIT;
     END LOOP;
   END IF;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/functions/C_ORDERLINETAX_ROUNDING_AMT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+  <database name="FUNCTION C_ORDERLINETAX_ROUNDING_AMT">
+    <function name="C_ORDERLINETAX_ROUNDING_AMT" type="NULL">
+      <parameter name="p_orderline_id" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_tax_id" type="VARCHAR" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_diff_amount" type="NUMERIC" mode="in">
+        <default/>
+      </parameter>
+      <parameter name="p_linefrom" type="NUMERIC" mode="in">
+        <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
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2015 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+-- Variables
+  v_ResultStr VARCHAR(2000):='';
+  TYPE RECORD IS REF CURSOR;
+  cur_orderlinetax RECORD;
+  
+BEGIN --BODY
+  FOR cur_orderlinetax IN (
+    SELECT c_orderlinetax_id, c_tax_id
+    FROM c_orderlinetax
+    WHERE  c_orderline_id = p_orderline_id and line > p_linefrom
+    AND c_tax_id = (SELECT tb.c_tax_id FROM c_tax tb WHERE tb.c_taxbase_id = p_tax_id)
+  ) LOOP
+      UPDATE c_orderlinetax
+      SET taxbaseamt = taxbaseamt + p_diff_amount
+      WHERE c_orderlinetax_id  = cur_orderlinetax.c_orderlinetax_id;
+      C_ORDERLINETAX_ROUNDING_AMT(p_orderline_id, cur_orderlinetax.c_tax_id, p_diff_amount, p_linefrom);
+  END LOOP;
+EXCEPTION
+  WHEN OTHERS THEN
+  v_ResultStr:= '@ERROR=' || SQLERRM;
+  DBMS_OUTPUT.PUT_LINE(v_ResultStr) ;
+  RAISE;
+END C_ORDERLINETAX_ROUNDING_AMT
+]]></body>
+    </function>
+  </database>
--- a/src-db/database/model/functions/C_ORDERTAX_ROUNDING.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_ORDERTAX_ROUNDING.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -54,7 +54,7 @@
       SELECT c_ordertax_id
       FROM c_ordertax
       WHERE c_order_id = p_order_id
-      ORDER BY taxamt desc
+      ORDER BY ABS(taxamt) desc
     ) LOOP
       UPDATE c_ordertax
       SET taxamt = taxamt - (v_current_gross_amt - COALESCE(p_grandtotal, 0))
--- a/src-db/database/model/functions/C_ORDER_POST1.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -1320,73 +1320,7 @@
           END IF;
         END;
       END IF;
-
-     /**************************************************************************
-      * Calculate Taxes and Totals
-      *************************************************************************/
-      DECLARE
-        Cur_Tax RECORD;
-        Cur_MultiTax RECORD;
-        xTotalLines NUMBER:=0;
-        v_LineNetAmt NUMBER:=0;
-        xTaxAmt NUMBER:=0;
-        xGrandTotal NUMBER:=0;
-        HeaderNotAdded BOOLEAN:=TRUE;
-        v_FirstLine BOOLEAN;
-        v_ActualBaseAmt NUMBER;
-        v_lineNo NUMBER:= 0;
-      BEGIN
-        v_ResultStr:='DeleteOldTaxes';
-        DELETE FROM C_ORDERLINETAX  WHERE C_OrderLine_ID IN (SELECT C_OrderLine_ID FROM C_OrderLine
-                                                             WHERE C_Order_ID = v_Record_ID);
-        DELETE FROM C_ORDERTAX  WHERE C_Order_ID=v_Record_ID;
-        -- For all Tax Rates
-        v_ResultStr:='InsertNewTaxes';
-        FOR Cur_Tax IN
-            (SELECT l.C_OrderLine_ID, l.C_Tax_ID, o.IsTaxIncluded, l.line_gross_amount,
-                SUM(l.LineNetAmt) + SUM(l.FreightAmt) + SUM(coalesce(l.ChargeAmt,0)) AS LineNetAmt,
-                SUM(l.TaxBaseAmt) + SUM(l.FreightAmt) + SUM(coalesce(l.ChargeAmt,0)) AS TaxBaseAmt,
-                SUM(o.FreightAmt) + SUM(coalesce(o.ChargeAmt,0)) AS HeaderNet,
-                t.Rate, t.IsSummary, c.StdPrecision, t.BaseAmount, o.C_Order_ID
-            FROM C_ORDER o,  C_ORDERLINE l, C_TAX t, C_CURRENCY c
-            WHERE o.C_Order_ID=l.C_Order_ID
-              AND o.C_Order_ID=v_Record_ID -- Parameter
-              AND l.C_Tax_ID=t.C_Tax_ID
-              AND o.C_Currency_ID=c.C_Currency_ID
-            GROUP BY l.C_OrderLine_ID, l.C_Tax_ID, l.line_gross_amount, o.IsTaxIncluded, t.Rate,
-                     t.IsSummary, c.StdPrecision, t.BaseAmount, o.C_Order_ID
-            ORDER BY 4 DESC
-            )
-        LOOP
-          v_LineNetAmt:=Cur_Tax.LineNetAmt;
-          xTotalLines:=xTotalLines + v_LineNetAmt; -- w/o Header Freight/Charge
-          IF (HeaderNotAdded) THEN --  add header net to first tax
-            HeaderNotAdded:=FALSE;
-            v_LineNetAmt:=v_LineNetAmt + Cur_Tax.HeaderNet;
-          END IF;
-          C_ORDERLINETAX_INSERT(v_Org_ID, Cur_Tax.C_Order_ID, Cur_Tax.C_OrderLine_ID, v_UpdatedBy, Cur_Tax.C_Tax_ID, Cur_Tax.C_Tax_ID, Cur_Tax.LineNetAmt, Cur_Tax.TaxBaseAmt, Cur_Tax.StdPrecision);
-          IF (v_istaxincluded = 'Y') THEN
-            C_ORDERLINETAX_ROUNDING(Cur_Tax.C_OrderLine_ID, Cur_Tax.line_gross_amount, Cur_Tax.LineNetAmt);
-          END IF;
-        END LOOP; -- Insert New Taxes
-        IF (v_istaxincluded = 'Y') THEN
-          SELECT COALESCE(SUM(line_gross_amount), 0) INTO xGrandTotal
-          FROM c_orderline
-          WHERE c_order_id = v_record_id;
-        ELSE
-          SELECT COALESCE(SUM(TAXAMT), 0) INTO xGrandTotal
-          FROM C_ORDERTAX
-          WHERE C_ORDER_ID = v_Record_ID;
-          xGrandTotal:=xGrandTotal+ xTotalLines;
-        END IF;
-        -- Update Header
-        UPDATE C_ORDER
-        SET TotalLines=xTotalLines,
-            GrandTotal=xGrandTotal
-        WHERE C_Order_ID=v_Record_ID;
-        C_ORDERTAX_ROUNDING(v_Record_ID, xGrandTotal, xTotalLines);
-        DBMS_OUTPUT.PUT_LINE('GrandTotal=' || xGrandTotal) ;
-      END; -- Calculate Tax and Totals
+      
       -- Synchronize Client/Org Ownership
       UPDATE C_ORDERLINE
       SET AD_Client_ID=v_Client_ID
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -69,6 +69,7 @@
     Cur_Order RECORD;
     Cur_OrderLine RECORD;
     Cur_Lines RECORD;
+    Cur_Reservation RECORD;
     --
     v_Result NUMBER:=1;
     v_AD_Org_ID VARCHAR2(32);
@@ -117,6 +118,9 @@
     v_IsQtyVariable M_Product.IsQuantityVariable%TYPE;
     v_IsReversedDoc CHAR(1);
 
+    v_uuid VARCHAR2(32) := get_uuid();
+    v_qtyordered NUMBER;
+
   BEGIN
   
     IF(p_PInstance_ID IS NOT NULL) THEN
@@ -1145,6 +1149,59 @@
               Updated=now(),
               UpdatedBy=v_User
             WHERE M_INOUTLINE.M_INOUTLINE_ID=Cur_InOutLine.M_INOUTLINE_ID;
+
+	    -- Create new reservation to replace the closed related one
+	    FOR Cur_Reservation IN
+              (SELECT *
+              FROM M_RESERVATION
+              WHERE M_RESERVATION.C_OrderLine_ID=Cur_InOutLine.C_OrderLine_ID
+              AND IsActive='Y')
+	    LOOP
+	      IF (Cur_Reservation.Res_Status = 'CL') THEN
+
+		-- Get the ordered quantity from the order line
+	        SELECT qtyordered
+	        INTO v_qtyordered
+	        FROM C_ORDERLINE
+	        WHERE C_OrderLine_ID=Cur_Reservation.C_OrderLine_ID;
+
+	        -- Create a new reservation with the ordered quantity
+	        INSERT INTO M_RESERVATION (
+		  m_reservation_id, ad_client_id, ad_org_id, isactive,
+		  created, createdby, updated, updatedby,
+		  m_product_id, quantity, c_uom_id, c_orderline_id,
+		  ad_user_id, c_bpartner_id, m_warehouse_id, m_attributesetinstance_id, m_locator_id,
+		  res_status, res_process, managereservation_pe, reservedgoodmnt_pe
+	        ) VALUES (
+		  v_uuid, Cur_Reservation.ad_client_id, Cur_Reservation.ad_org_id, 'Y',
+		  now(), v_user, now(), v_user,
+		  Cur_Reservation.m_product_id, v_qtyordered, Cur_Reservation.c_uom_id, Cur_Reservation.c_orderline_id,
+		  Cur_Reservation.ad_user_id, Cur_Reservation.c_bpartner_id, Cur_Reservation.m_warehouse_id,
+		  Cur_Reservation.m_attributesetinstance_id, Cur_Reservation.m_locator_id, 'DR', 'PR',
+		  Cur_Reservation.managereservation_pe, Cur_Reservation.reservedgoodmnt_pe
+	        );
+
+           -- Add a reservation stock with the ordered quantity
+      	   INSERT INTO M_RESERVATION_STOCK (
+     	      m_reservation_stock_id, ad_client_id, ad_org_id, isactive,
+   	        created, createdby, updated, updatedby,
+		        m_reservation_id, c_orderline_id, quantity, isallocated,
+		        m_locator_id, m_attributesetinstance_id
+	        )
+          SELECT get_uuid(), ad_client_id, ad_org_id, 'Y',
+            now(), v_user, now(), v_user,
+            v_uuid, c_orderline_id, v_qtyordered, isallocated,
+            m_locator_id, m_attributesetinstance_id
+          FROM M_RESERVATION_STOCK
+          WHERE M_RESERVATION_STOCK.M_Reservation_ID=Cur_Reservation.M_Reservation_ID
+          AND IsActive='Y';
+
+	        -- Process the reservation
+	        M_RESERVATION_POST(null, v_uuid, 'PR', v_user);
+
+	      END IF;
+	    END LOOP;
+
           END LOOP;
           
           -- Post Reversal
--- a/src-db/database/model/functions/M_PRICELIST_CREATE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/M_PRICELIST_CREATE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -148,73 +148,6 @@
       OR PricePO=0)
       AND PriceLastPO<>0;
     UPDATE M_Product_PO  SET PricePO=0  WHERE PricePO IS NULL;
-    -- Set default current vendor
-    UPDATE M_Product_PO
-      SET IsCurrentVendor='Y'
-    WHERE IsCurrentVendor='N'
-      AND NOT EXISTS
-      (SELECT pp.M_Product_ID
-      FROM M_Product_PO pp
-      WHERE pp.M_Product_ID=M_Product_PO.M_Product_ID
-      GROUP BY pp.M_Product_ID
-      HAVING COUNT(*)>1
-      )
-      ;
-    -- Commented by cromero 19102006 COMMIT;
-    /**
-    * Make sure that we have only one active product
-    */
-    v_ResultStr:='CorrectingDuplicates';
-    DBMS_OUTPUT.PUT_LINE(v_ResultStr) ;
-    DECLARE
-      -- All duplicate products
-      Cur_Duplicates RECORD;
-      -- All vendors of Product - expensive first
-      CURSOR Cur_Vendors (Product_ID VARCHAR) IS
-        SELECT M_Product_ID,
-          C_BPartner_ID
-        FROM M_Product_PO
-        WHERE IsCurrentVendor='Y'
-          AND IsActive='Y'
-          AND M_Product_ID=Product_ID
-        ORDER BY PriceList DESC;
-        --
-        Product_ID VARCHAR2(32);
-        BPartner_ID VARCHAR2(32);
-      BEGIN
-        FOR Cur_Duplicates IN
-          (SELECT DISTINCT M_Product_ID
-          FROM M_Product_PO po
-          WHERE IsCurrentVendor='Y'
-            AND IsActive='Y'
-            AND EXISTS
-            (SELECT M_Product_ID
-            FROM M_Product_PO x
-            WHERE x.M_Product_ID=po.M_Product_ID
-            GROUP BY M_Product_ID
-            HAVING COUNT(*)>1
-            )
-          ORDER BY 1
-          )
-        LOOP
-          OPEN Cur_Vendors(Cur_Duplicates.M_Product_ID) ;
-          FETCH Cur_Vendors INTO Product_ID,
-          BPartner_ID; -- Leave First
-          LOOP
-            FETCH Cur_Vendors INTO Product_ID,
-            BPartner_ID; -- Get Record ID
-            EXIT WHEN Cur_Vendors%NOTFOUND;
-            --
-            DBMS_OUTPUT.PUT_LINE('  Record: ' || Product_ID || ' / ' || BPartner_ID) ;
-            UPDATE M_Product_PO
-              SET IsCurrentVendor='N'
-            WHERE M_Product_ID=Product_ID
-              AND C_BPartner_ID=BPartner_ID;
-          END LOOP;
-          CLOSE Cur_Vendors;
-        END LOOP;
-        -- Commented by cromero 19102006 COMMIT;
-      END;
       /** Delete Old Data */
       v_ResultStr:='DeletingOld';
       IF(v_DeleteOld='Y') THEN
@@ -349,35 +282,8 @@
         IF(v_PriceList_Version_Base_ID=v_PriceList_Version_ID) THEN
           -- We have Prices already
           NULL;
-        ELSIF(v_costbased='N'AND v_PriceList_Version_Base_ID IS NULL) THEN
-          -- Copy and Convert from Product_PO
-          v_ResultStr:=v_ResultStr || ',Copy_PO';
-          INSERT
-          INTO M_ProductPrice
-            (
-              M_ProductPrice_ID, M_PriceList_Version_ID, M_Product_ID, AD_Client_ID, AD_Org_ID,
-              IsActive, Created, CreatedBy, Updated,
-              UpdatedBy,
-              PriceList,
-              PriceStd,
-              PriceLimit
-            )
-          SELECT  get_uuid(), v_PriceList_Version_ID,
-            po.M_Product_ID, v_Client_ID, v_Org_ID, 'Y',
-            now(), v_UpdatedBy, now(), v_UpdatedBy,
-            -- Price List
-            COALESCE(C_Currency_Convert(po.PriceList, po.C_Currency_ID, v_Currency_ID, Cur_DiscountLine.ConversionDate, Cur_DiscountLine.ConversionRateType, v_Client_ID, v_Org_ID), 0),
-            -- Price Std
-            COALESCE(C_Currency_Convert(po.PriceList, po.C_Currency_ID, v_Currency_ID, Cur_DiscountLine.ConversionDate, Cur_DiscountLine.ConversionRateType, v_Client_ID, v_Org_ID), 0),
-            -- Price Limit
-            COALESCE(C_Currency_Convert(po.PricePO, po.C_Currency_ID, v_Currency_ID, Cur_DiscountLine.ConversionDate, Cur_DiscountLine.ConversionRateType, v_Client_ID, v_Org_ID), 0)
-          FROM M_Product_PO po
-          WHERE EXISTS
-            (SELECT 1 FROM C_TEMP_Selection s WHERE po.M_Product_ID=s.C_TEMP_Selection_ID)
-            AND po.IsCurrentVendor='Y'
-            AND po.IsActive='Y';      
-         ELSIF(v_costbased='Y')THEN   
-           v_ResultStr:=v_ResultStr || ',costbased';
+        ELSIF(v_costbased='Y')THEN   
+          v_ResultStr:=v_ResultStr || ',costbased';
           INSERT
           INTO M_ProductPrice
             (
@@ -400,7 +306,7 @@
             where EXISTS (SELECT 1 FROM C_TEMP_Selection s WHERE mp.M_Product_ID=s.C_TEMP_Selection_ID)
             AND mp.IsActive='Y'; 
             
-         ELSE
+        ELSE
           -- Copy and Convert from other PriceList_Version
           v_ResultStr:=v_ResultStr || ',Copy_PL';
           INSERT
--- a/src-db/database/model/functions/M_PROMOTION_CALCULATE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/M_PROMOTION_CALCULATE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -110,12 +110,10 @@
 
       if (v_count > 0) then
 				if (v_taxIncluded = 'Y') then
-					update c_orderline
-						 set gross_unit_price = grosspricestd,
-								 line_gross_amount = round(grosspricestd * qtyordered, v_stdPrecision),
-								 priceactual = c_get_net_price_from_gross(Cur_Order.c_tax_id, round(grosspricestd * qtyordered, v_stdPrecision), round(grosspricestd * qtyordered, v_stdPrecision), v_precision, qtyordered),
-								 linenetamt = round(c_get_net_price_from_gross(Cur_Order.c_tax_id, round(grosspricestd * qtyordered, v_stdPrecision), round(grosspricestd * qtyordered, v_stdPrecision), v_precision, qtyordered) * qtyordered, v_stdPrecision)
-					 where c_orderline_id = Cur_Order.id;
+					update c_orderline set
+						gross_unit_price = grosspricestd,
+						line_gross_amount = round(grosspricestd * qtyordered, v_stdPrecision)
+					where c_orderline_id = Cur_Order.id;
 				else
 					update c_orderline
 						 set priceactual = pricestd,
@@ -148,12 +146,10 @@
         if (Cur_Order.from_order is null) then
           -- Invoice: reset to original prices in case invoice is not coming fom an order
 					if (v_taxIncluded = 'Y') then
-						update c_invoiceline
-							 set gross_unit_price = grosspricestd,
-									 line_gross_amount = round(grosspricestd * qtyinvoiced, v_stdPrecision),
-									 priceactual = c_get_net_price_from_gross(Cur_Order.c_tax_id, round(grosspricestd * qtyinvoiced, v_stdPrecision), round(grosspricestd * qtyinvoiced, v_stdPrecision), v_precision, qtyinvoiced),
-									 linenetamt = round(c_get_net_price_from_gross(Cur_Order.c_tax_id, round(grosspricestd * qtyinvoiced, v_stdPrecision), round(grosspricestd * qtyinvoiced, v_stdPrecision), v_precision, qtyinvoiced) * qtyinvoiced, v_stdPrecision)
-						 where c_invoiceline_id = Cur_Order.id;
+						update c_invoiceline set
+							gross_unit_price = grosspricestd,
+							line_gross_amount = round(grosspricestd * qtyinvoiced, v_stdPrecision)
+						where c_invoiceline_id = Cur_Order.id;
 					else
 						update c_invoiceline
 							 set priceactual = pricestd,
--- a/src-db/database/model/functions/M_RESERVATION_POST.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/functions/M_RESERVATION_POST.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -238,7 +238,8 @@
         SELECT count(*) INTO v_count
         FROM m_reservation
         WHERE c_orderline_id = v_orderline_id
-          AND m_reservation_id != v_reservation_id;
+        AND m_reservation_id != v_reservation_id
+        AND res_status <> 'CL';
         IF (v_count > 0) THEN
           RAISE_APPLICATION_ERROR(-20000, '@SOLineWithMoreThanOneOpenReservation@');
         END IF;
@@ -381,17 +382,35 @@
     END IF;
     v_newstatus := 'CL';
     v_newaction := 'RE';
+    
+    -- Force to set reservation = CL here to avoid mutating table issues
+    -- when updating m_reservation_stock.quantity
+    UPDATE m_reservation
+    SET res_status = v_newstatus,
+      res_process = v_newaction,
+      updated = now(),
+      updatedby = v_user_id
+    WHERE m_reservation_id = v_reservation_id;
+    
+    UPDATE m_reservation_stock
+    SET quantity = releasedQty,
+    updated = now(),
+    updatedby = v_user_id
+    WHERE m_reservation_id = v_reservation_id;
 
   ELSE
     RAISE_APPLICATION_ERROR(-20000, '@UnsupportedResAction@');
   END IF;
 
-  UPDATE m_reservation
-  SET res_status = v_newstatus,
-      res_process = v_newaction,
-      updated = now(),
-      updatedby = v_user_id
-  WHERE m_reservation_id = v_reservation_id;
+  -- Close status already set
+  IF (v_newstatus <> 'CL') THEN
+    UPDATE m_reservation
+    SET res_status = v_newstatus,
+        res_process = v_newaction,
+        updated = now(),
+        updatedby = v_user_id
+    WHERE m_reservation_id = v_reservation_id;
+  END IF;
 
   IF (v_resaction = 'PR') THEN
     -- ADD RESERVED STOCK
--- a/src-db/database/model/tables/C_TAXCATEGORY.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/tables/C_TAXCATEGORY.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -45,6 +45,10 @@
         <default><![CDATA[N]]></default>
         <onCreateDefault/>
       </column>
+      <column name="ASBOM" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="C_TAXCATEGORY_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
@@ -56,6 +60,7 @@
         <unique-column name="AD_ORG_ID"/>
         <unique-column name="NAME"/>
       </unique>
+      <check name="C_TAXCATEGORY_ASBOM_CHK"><![CDATA[ASBOM IN ('Y', 'N')]]></check>
       <check name="C_TAXCATEGORY_ISACTIVE_CHECK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
     </table>
   </database>
--- a/src-db/database/model/tables/M_PRODUCT_BOM.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/tables/M_PRODUCT_BOM.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -57,6 +57,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="BOMPRICE" primaryKey="false" required="false" type="DECIMAL" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="M_PRODUCT_BOM_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/src-db/database/model/triggers/A_AMORTIZATIONLINE_TRG2.xml	Wed Jul 22 17:54:36 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-<?xml version="1.0"?>
-  <database name="TRIGGER A_AMORTIZATIONLINE_TRG2">
-    <trigger name="A_AMORTIZATIONLINE_TRG2" table="A_AMORTIZATIONLINE" fires="after" insert="false" update="true" delete="false" foreach="row">
-      <body><![CDATA[
-
-
-
-
-      
-BEGIN
-    
-    IF AD_isTriggerEnabled()='N' THEN RETURN;
-    END IF;
-
- null;
-/* mutating table
-  update a_asset
-  set DepreciatedPlan=(select sum(AmortizationAmt)
-  from A_AmortizationLine
-  where  A_AmortizationLine_ID=:new.A_AmortizationLine_ID)
-  where a_Asset_ID=:new.A_Asset_ID:
-   exception when others then null; */
-END A_AMORTIZATIONLINE_TRG2
-]]></body>
-    </trigger>
-  </database>
--- a/src-db/database/model/triggers/C_INVOICELINETAX_TRG.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/triggers/C_INVOICELINETAX_TRG.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -112,14 +112,7 @@
     AND C_TAX_ID = :OLD.C_TAX_ID
     AND TAXAMT=0 AND TAXBASEAMT=0;
     
- 		IF (v_istaxincluded = 'Y') THEN
-      SELECT totallines, grandtotal INTO v_totallines, v_grandtotal
-      FROM C_invoice
-      WHERE c_invoice_id = v_C_Invoice_ID;
-      C_INVOICETAX_ROUNDING(v_C_Invoice_ID, v_grandtotal, v_totallines);
-    END IF;
-    
-	END IF;
+  END IF;
 END IF;
 END C_INVOICELINETAX_TRG
 ]]></body>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-db/database/model/triggers/C_INVOICELINE_BEFORE_TRG.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,142 @@
+<?xml version="1.0"?>
+  <database name="TRIGGER C_INVOICELINE_BEFORE_TRG">
+    <trigger name="C_INVOICELINE_BEFORE_TRG" table="C_INVOICELINE" fires="before" insert="true" update="true" delete="false" foreach="row">
+      <body><![CDATA[
+/*************************************************************************
+* The contents of this file are subject to the Openbravo  Public  License
+* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+* Version 1.1  with a permitted attribution clause; you may not  use this
+* file except in compliance with the License. You  may  obtain  a copy of
+* the License at http://www.openbravo.com/legal/license.html
+* Software distributed under the License  is  distributed  on  an "AS IS"
+* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+* License for the specific  language  governing  rights  and  limitations
+* under the License.
+* The Original Code is Openbravo ERP.
+* The Initial Developer of the Original Code is Openbravo SLU
+* All portions are Copyright (C) 2014-2015 Openbravo SLU
+* All Rights Reserved.
+* Contributor(s):  ______________________________________.
+************************************************************************/
+
+  v_std_prec NUMBER:=2;
+  v_price_prec NUMBER:=2;
+  v_invoiceline_id VARCHAR2(32);
+  v_invoice_id VARCHAR2(32);
+  v_istaxincluded CHAR(1);
+  v_PriceActual NUMBER;
+  
+  v_IsSOTrx CHAR(1);
+  v_Warehouse_ID VARCHAR2(32);
+  v_BPartner_Location_ID VARCHAR2(32);
+  v_Project_ID VARCHAR2(32);  
+  v_AsBOM CHAR(1);  
+  v_TotalRatio NUMBER;
+  v_TotalProducts NUMBER;
+  
+  v_BaseLine NUMBER;
+  v_Line NUMBER;
+  v_LineAcum NUMBER;   
+  v_NetActual NUMBER;
+  v_PriceLine NUMBER;
+  v_CalcLine NUMBER;
+  v_execute CHAR(1):='N';
+          
+  TYPE RECORD IS REF CURSOR;
+  Cur_BOM RECORD;  
+BEGIN
+  IF AD_isTriggerEnabled()='N' THEN RETURN;
+  END IF;
+
+  IF (:new.c_orderline_id IS NULL) THEN
+    v_Warehouse_ID := NULL;
+  ELSE
+    SELECT o.m_warehouse_id into v_Warehouse_ID 
+    FROM c_orderline ol, c_order o 
+    WHERE o.c_order_id = ol.c_order_id and ol.c_orderline_id = :new.c_orderline_id;
+  END IF;
+  
+  v_invoice_id := :new.c_invoice_id;
+  SELECT stdPrecision, m_pricelist.istaxincluded, priceprecision, i.C_BPARTNER_LOCATION_ID, i.C_PROJECT_ID, i.ISSOTRX
+    INTO v_std_prec, v_istaxincluded, v_price_prec, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX
+  FROM c_invoice i
+    JOIN c_currency ON i.c_currency_id = c_currency.c_currency_id
+    JOIN m_pricelist ON i.m_pricelist_id = m_pricelist.m_pricelist_id
+  WHERE i.c_invoice_id = v_invoice_id;
+
+  IF (v_istaxincluded = 'Y') THEN
+    IF (INSERTING) THEN
+          v_execute:='Y';
+    ELSIF(UPDATING) THEN
+        IF(:old.LineNetAmt <> :new.LineNetAmt
+          OR :old.gross_unit_price <> :new.gross_unit_price
+          OR :old.c_tax_id <> :new.c_tax_id
+          OR :old.qtyinvoiced <> :new.qtyinvoiced) THEN
+          v_execute:='Y';
+        END IF;
+    END IF;
+    IF (v_execute='Y') THEN
+  
+      -- If tax included taxes recalculate net price / amounts
+      :new.line_gross_amount := ROUND(:new.gross_unit_price * :new.Qtyinvoiced, v_std_prec);
+      
+      SELECT tc.ASBOM INTO v_AsBOM FROM C_TAXCATEGORY tc, C_tax t WHERE tc.C_TAXCATEGORY_ID = t.C_TAXCATEGORY_ID AND t.C_TAX_ID = :new.C_Tax_ID;
+      IF (v_AsBOM = 'Y') THEN
+        -- BOM taxes
+        -- Calculate the base for ratios.
+        v_BaseLine := :new.line_gross_amount;
+        -- Calculate total ratio and number of products
+        v_TotalRatio := 0;
+        v_TotalProducts := 0;      
+        FOR Cur_BOM IN (
+          SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+          SUM(ROUND(BOMQTY * BOMPRICE, v_std_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+          GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+          ORDER BY RATIO ASC )
+        LOOP
+          v_TotalRatio := v_TotalRatio + Cur_BOM.RATIO;
+          v_TotalProducts := v_TotalProducts + 1;
+        END LOOP;
+        
+        -- Calculate taxes based on BOM of products  
+        v_LineAcum := 0;
+        v_NetActual := 0;
+        FOR Cur_BOM IN (
+          SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+          SUM(ROUND(BOMQTY * BOMPRICE, v_std_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+          GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+          ORDER BY RATIO ASC )
+        LOOP
+          v_TotalProducts := v_TotalProducts - 1;
+          IF (v_TotalProducts > 0) THEN
+            v_Line := ROUND(v_BaseLine * Cur_BOM.RATIO / v_TotalRatio , v_std_Prec);
+            v_LineAcum := v_LineAcum + v_Line;
+          ELSE -- The last willaccummulate rounding
+            v_Line := v_BaseLine - v_LineAcum;
+          END IF;
+
+          v_PriceLine := C_GET_NET_PRICE_FROM_GROSS(Cur_BOM.TAX, v_Line, v_Line, v_price_prec, :new.qtyinvoiced);
+          v_CalcLine := ROUND(:new.qtyinvoiced * v_PriceLine, v_std_Prec); -- In price including taxes the net and net alternate are equals.
+
+          v_NetActual := v_NetActual + v_CalcLine; -- Acum the net
+        END LOOP;    
+        v_PriceActual := v_NetActual / :new.qtyinvoiced;     
+      ELSE
+        -- Regular taxes
+        v_PriceActual := C_GET_NET_PRICE_FROM_GROSS(:new.c_tax_id, :new.line_gross_amount, :new.line_gross_amount, v_price_prec, :NEW.qtyinvoiced);    
+        v_NetActual := ROUND(:new.Qtyinvoiced * v_PriceActual, v_std_Prec);
+      END IF;      
+      
+      :NEW.pricestd := v_priceactual;
+      :NEW.pricelist := v_priceactual;
+      :NEW.pricelimit := v_priceactual;
+      :NEW.priceactual := v_priceactual;
+      :new.taxbaseamt := v_NetActual;
+      :new.LineNetAmt := v_NetActual;
+    END IF;
+  END IF;
+
+END C_INVOICELINE_BEFORE_TRG
+]]></body>
+    </trigger>
+  </database>
--- a/src-db/database/model/triggers/C_INVOICELINE_TRG2.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/triggers/C_INVOICELINE_TRG2.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -29,14 +29,36 @@
   v_newLineAlternate NUMBER;
   v_taxAmt NUMBER;
   v_Prec C_CURRENCY.STDPRECISION%TYPE;
+  v_PricePrec C_CURRENCY.PRICEPRECISION%TYPE;
   v_istaxincluded CHAR(1) ;
   v_oldGrossAmt NUMBER:=0;
   v_newGrossAmt NUMBER:=0;
   v_totallines NUMBER:=0;
   v_grandtotal NUMBER:=0;
   v_oldLineAlternate NUMBER;
-  v_create CHAR(1):='Y';
-        
+  v_create CHAR(1):='Y';  
+  
+  v_Warehouse_ID VARCHAR2(32);
+  v_BPartner_Location_ID VARCHAR2(32);
+  v_Project_ID VARCHAR2(32);
+  v_IsSOTRX CHAR(1);
+  v_AsBOM CHAR(1);  
+  v_TotalRatio NUMBER;
+  v_TotalProducts NUMBER;
+  
+  v_BaseLine NUMBER;
+  v_Line NUMBER;
+  v_LineAcum NUMBER;  
+  v_BaseLineAlternate NUMBER;
+  v_LineAlternate NUMBER;
+  v_LineAlternateAcum NUMBER;
+  
+  v_PriceLine NUMBER;
+  v_CalcLine NUMBER;
+  v_maxline NUMBER;    
+          
+  TYPE RECORD IS REF CURSOR;
+  Cur_BOM RECORD;          
 BEGIN
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
@@ -50,12 +72,21 @@
 ELSE
   v_ID:=:NEW.C_INVOICE_ID;
 END IF;
+ IF INSERTING OR UPDATING THEN
+   IF (:new.c_orderline_id IS NULL) THEN
+     v_Warehouse_ID := NULL;
+   ELSE
+     SELECT o.m_warehouse_id into v_Warehouse_ID 
+     FROM c_orderline ol, c_order o 
+     WHERE o.c_order_id = ol.c_order_id and ol.c_orderline_id = :new.c_orderline_id;
+   END IF;
+ END IF; 
 
   /**************************************************************************
    * Calculate Tax, etc.
    */
- SELECT processed, stdPrecision, pl.istaxincluded
-   INTO v_Processed, v_Prec, v_istaxincluded
+ SELECT processed, stdPrecision, priceprecision, pl.istaxincluded, C_BPARTNER_LOCATION_ID, C_PROJECT_ID, ISSOTRX
+   INTO v_Processed, v_Prec, v_PricePrec, v_istaxincluded, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX
  FROM C_Invoice, C_Currency, m_pricelist pl
  WHERE C_Invoice.C_Currency_ID = C_Currency.C_Currency_ID
  AND C_Invoice.m_pricelist_id = pl.m_pricelist_id
@@ -71,14 +102,13 @@
      ELSIF (INSERTING) THEN
         v_newgrossamt := :new.line_gross_amount;
      END IF;
-   END IF;
+   END IF;  
   IF(UPDATING OR DELETING) THEN
   v_oldLine:= COALESCE(:old.LineNetAmt,0);
   END IF;  
   IF (INSERTING OR UPDATING) THEN
    v_newLineNetAmt := COALESCE(:new.LineNetAmt,0);
    v_newLineAlternate := COALESCE(:new.TaxBaseAmt,0);
-   
    IF (UPDATING) THEN
      v_oldLineAlternate := COALESCE(:old.TaxBaseAmt,0);
      IF (:new.AD_Org_ID <> :old.AD_Org_ID OR :new.C_Tax_ID <> :old.C_Tax_ID OR
@@ -89,31 +119,89 @@
      ELSE
        v_create := 'N';
      END IF;
-   END IF;   
+   END IF;      
+   
+   IF (v_create = 'Y') THEN   
+   IF(:new.C_Tax_ID IS NOT NULL) THEN
+     
+    SELECT tc.ASBOM INTO v_AsBOM FROM C_TAXCATEGORY tc, C_tax t WHERE tc.C_TAXCATEGORY_ID = t.C_TAXCATEGORY_ID AND t.C_TAX_ID = :new.C_Tax_ID;
+    IF (v_AsBOM = 'Y') THEN
+      -- BOM taxes
+      -- Calculate the base for ratios.
+      IF (v_istaxincluded = 'Y') THEN
+        v_BaseLine := :new.line_gross_amount;
+        v_BaseLineAlternate := :new.line_gross_amount;
+      ELSE
+        v_BaseLine := v_newLineNetAmt;
+        v_BaseLineAlternate := v_newLineAlternate;
+      END IF;
+          -- Calculate total ratio and number of products
+      v_TotalRatio := 0;
+      v_TotalProducts := 0;      
+      FOR Cur_BOM IN (
+        SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+        SUM(ROUND(BOMQTY * BOMPRICE, v_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+        GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+        ORDER BY RATIO ASC )
+      LOOP
+        v_TotalRatio := v_TotalRatio + Cur_BOM.RATIO;
+        v_TotalProducts := v_TotalProducts + 1;
+      END LOOP;
+      
+      -- Calculate taxes based on BOM of products  
+      v_LineAlternateAcum := 0;
+      v_LineAcum := 0;
+      FOR Cur_BOM IN (
+        SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+        SUM(ROUND(BOMQTY * BOMPRICE, v_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+        GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+        ORDER BY RATIO ASC )
+      LOOP
+        v_TotalProducts := v_TotalProducts - 1;
+        IF (v_TotalProducts > 0) THEN
+          v_Line := ROUND(v_BaseLine * Cur_BOM.RATIO / v_TotalRatio , v_Prec);
+          v_LineAcum := v_LineAcum + v_Line;
+          v_LineAlternate := ROUND(v_BaseLineAlternate * Cur_BOM.RATIO / v_TotalRatio , v_Prec);
+          v_LineAlternateAcum := v_LineAlternateAcum + v_LineAlternate;
+        ELSE -- The last willaccummulate rounding
+          v_Line := v_BaseLine - v_LineAcum;
+          v_LineAlternate := v_BaseLineAlternate - v_LineAlternateAcum;
+        END IF;
+        IF (v_istaxincluded = 'Y') THEN
+          v_PriceLine := C_GET_NET_PRICE_FROM_GROSS(Cur_BOM.TAX, v_Line, v_LineAlternate, v_PricePrec, :new.qtyinvoiced);
+          v_CalcLine := ROUND(:new.qtyinvoiced * v_PriceLine, v_Prec); -- In price including taxes the net and net alternate are equals.
+          select coalesce(max(line), 0) into v_maxline from c_invoicelinetax where c_invoiceline_id = :new.C_InvoiceLine_ID;
+          C_INVOICELINETAX_INSERT(:new.AD_Org_ID, :new.C_Invoice_ID, :new.C_InvoiceLine_ID, :new.UpdatedBy, Cur_BOM.TAX, Cur_BOM.TAX, v_CalcLine, v_CalcLine, v_Prec);
+        ELSE
+          C_INVOICELINETAX_INSERT(:new.AD_Org_ID, :new.C_Invoice_ID, :new.C_InvoiceLine_ID, :new.UpdatedBy, Cur_BOM.TAX, Cur_BOM.TAX, v_Line, v_LineAlternate, v_Prec);
+        END IF;
+      END LOOP;       
+    ELSE
+      -- Regular taxes
+      C_INVOICELINETAX_INSERT(:new.AD_Org_ID, :new.C_Invoice_ID, :new.C_InvoiceLine_ID, :new.UpdatedBy, :new.C_Tax_ID, :new.C_Tax_ID, v_newLineNetAmt, v_newLineAlternate, v_Prec);    
+    END IF;  
 
-   IF (v_create = 'Y') THEN  
-     IF(:new.C_Tax_ID IS NOT NULL) THEN
-       C_INVOICELINETAX_INSERT(:new.AD_Org_ID, :new.C_Invoice_ID, :new.C_InvoiceLine_ID, :new.UpdatedBy, :new.C_Tax_ID, :new.C_Tax_ID, v_newLineNetAmt, v_newLineAlternate, v_Prec);
-       IF (v_istaxincluded = 'Y') THEN
-         C_INVOICELINETAX_ROUNDING(:new.C_InvoiceLine_ID, :new.line_gross_amount, v_newLineNetAmt);
-       END IF;
-     END IF;
-    -- Get Total Tax Amt
-     SELECT SUM(TaxAmt)
-       INTO v_taxAmt
-     FROM C_InvoiceTax
-     WHERE C_Invoice_ID=:new.C_Invoice_ID;
-    -- DBMS_OUTPUT.PUT_LINE('TaxAmt = ' || v_taxAmt);
-     -- Update Header
-         -- Get Total Tax Amt
-     UPDATE C_Invoice
-       SET TotalLines = TotalLines - v_oldLine + v_newLineNetAmt,
-       GrandTotal = CASE v_istaxincluded
-                       WHEN 'Y' THEN grandtotal - v_oldgrossamt + v_newgrossamt
-                       ELSE TotalLines - v_oldLine + v_newLineNetAmt + COALESCE(v_taxAmt, 0)
-                    END
-     --  Updated = SysDate -- Don't update as otherwise it does not save changes
-     WHERE C_Invoice_ID = :new.C_Invoice_ID;
+    IF (v_istaxincluded = 'Y') THEN
+      C_INVOICELINETAX_ROUNDING(:new.C_InvoiceLine_ID, :new.line_gross_amount, v_newLineNetAmt);
+    END IF;  
+              
+   END IF;
+  -- Get Total Tax Amt
+   SELECT SUM(TaxAmt)
+     INTO v_taxAmt
+   FROM C_InvoiceTax
+   WHERE C_Invoice_ID=:new.C_Invoice_ID;
+  -- DBMS_OUTPUT.PUT_LINE('TaxAmt = ' || v_taxAmt);
+   -- Update Header
+       -- Get Total Tax Amt
+   UPDATE C_Invoice
+     SET TotalLines = TotalLines - v_oldLine + v_newLineNetAmt,
+     GrandTotal = CASE v_istaxincluded
+                     WHEN 'Y' THEN grandtotal - v_oldgrossamt + v_newgrossamt
+                     ELSE TotalLines - v_oldLine + v_newLineNetAmt + COALESCE(v_taxAmt, 0)
+                  END
+   --  Updated = SysDate -- Don't update as otherwise it does not save changes
+   WHERE C_Invoice_ID = :new.C_Invoice_ID;
    END IF;
   ELSE -- DELETING
    IF (v_istaxincluded = 'Y') THEN
@@ -140,7 +228,7 @@
     WHERE c_invoice_id = v_id;
     C_INVOICETAX_ROUNDING(v_id, v_grandtotal, v_totallines);
   END IF;
-  
+   
  END IF;
 
 
--- a/src-db/database/model/triggers/C_ORDERLINE2_TRG.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/triggers/C_ORDERLINE2_TRG.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -18,7 +18,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-2014 Openbravo SLU
+* All portions are Copyright (C) 2001-2015 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -67,6 +67,25 @@
           END IF;
         END IF;
       END IF;
+      
+      -- Close reservations if QtyDelivered >= qtyordered
+      IF (:new.QtyDelivered IS NOT NULL AND :new.QtyDelivered <> COALESCE(:old.QtyDelivered, 0) 
+        AND :new.QtyDelivered > 0 AND :new.QtyDelivered >= COALESCE(:new.qtyordered, 0)) THEN
+         DECLARE
+           TYPE RECORD IS REF CURSOR;
+           cur_reservations RECORD;
+
+         BEGIN
+           FOR cur_reservations IN (
+             SELECT res.m_reservation_id as m_reservation_id
+             FROM m_reservation res
+             WHERE res.C_ORDERLINE_ID = :new.C_ORDERLINE_ID
+             AND res.RES_STATUS <> 'CL'
+           ) LOOP
+               M_RESERVATION_POST(null, cur_reservations.m_reservation_id, 'CL', :new.updatedBy);
+             END LOOP;
+         END;
+      END IF;
     END IF;
   END IF;
 
--- a/src-db/database/model/triggers/C_ORDERLINE_TRG.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/triggers/C_ORDERLINE_TRG.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -23,30 +23,38 @@
   * file and version.
   *************************************************************************/
 
-  v_newTaxBaseAmt NUMBER;
-  v_oldTaxBaseAmt NUMBER;
-  v_oldLine NUMBER:= 0;
-  v_newLineNetAmt NUMBER:= 0;
-  v_newLineAlternate NUMBER:= 0;
-  v_taxAmt NUMBER:= 0;
-  v_BaseAmount C_TAX.BASEAMOUNT%TYPE;
-  v_HasTaxLine  BOOLEAN := FALSE;
   v_Prec   NUMBER;
+  v_price_prec NUMBER;
   v_ID   VARCHAR2(32);
-  v_Processed  VARCHAR(60);
   v_UOM_ID    VARCHAR2(32);
   v_IsSOTrx CHAR(1);
   v_Count NUMBER;
-  v_taxBaseAmt NUMBER;
-  v_rate NUMBER;
-  v_isSummary CHAR(1);
-  xTaxAmt NUMBER:=0;
   v_reservation_id    VARCHAR2(32);
   v_prereservedqty    NUMBER;
   v_IsWithholding_Tax C_Tax.IsWithholdingTax%TYPE;
   v_IsCashVAT_Tax C_Tax.IsCashVAT%TYPE;
   v_IsCashVAT_Order C_Order.IsCashVAT%TYPE;
   v_Rate_Tax C_Tax.Rate%TYPE;
+
+  v_istaxincluded CHAR(1);
+  v_PriceActual NUMBER;
+  
+  v_Warehouse_ID VARCHAR2(32);
+  v_BPartner_Location_ID VARCHAR2(32);
+  v_Project_ID VARCHAR2(32);  
+  v_AsBOM CHAR(1);  
+  v_TotalRatio NUMBER;
+  v_TotalProducts NUMBER;
+  
+  v_BaseLine NUMBER;
+  v_Line NUMBER;
+  v_LineAcum NUMBER;   
+  v_NetActual NUMBER;
+  v_PriceLine NUMBER;
+  v_CalcLine NUMBER;
+          
+  TYPE RECORD IS REF CURSOR;
+  Cur_BOM RECORD;         
 BEGIN
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
@@ -61,7 +69,9 @@
   OR COALESCE(:old.C_Tax_ID,'0') <> COALESCE(:NEW.C_Tax_ID,'0')
   OR COALESCE(:old.C_Uom_ID,'0') <> COALESCE(:NEW.C_Uom_ID,'0')
   OR COALESCE(:old.qtyOrdered,0) <> COALESCE(:NEW.qtyOrdered,0)
-  OR COALESCE(:old.PriceActual,0) <> COALESCE(:NEW.PriceActual,0))
+  OR COALESCE(:old.PriceActual,0) <> COALESCE(:NEW.PriceActual,0)
+  OR COALESCE(:old.gross_unit_price,0) <> COALESCE(:NEW.gross_unit_price,0)
+  OR COALESCE(:old.line_gross_amount,0) <> COALESCE(:NEW.line_gross_amount,0))
  THEN
   RETURN;
   END IF;
@@ -141,6 +151,10 @@
        END IF;
      END IF;
    END IF;
+ ELSIF (INSERTING) THEN
+   SELECT issotrx INTO v_IsSOTrx
+   FROM c_order
+   WHERE c_order_id = :NEW.c_order_id;
  END IF;
 
  -- Get ID
@@ -156,23 +170,83 @@
   v_ID := :old.C_Order_ID;
  END IF;
 
- SELECT StdPrecision
- INTO v_Prec
- FROM C_Currency, C_Order
- WHERE C_Currency.C_Currency_ID = C_Order.C_Currency_ID
- AND C_Order_ID = v_ID;
+ SELECT stdPrecision, m_pricelist.istaxincluded, priceprecision, M_WAREHOUSE_ID, C_BPARTNER_LOCATION_ID, C_PROJECT_ID
+   INTO v_prec, v_istaxincluded, v_price_prec, v_Warehouse_ID, v_Bpartner_Location_ID, v_Project_ID
+ FROM c_order
+        JOIN c_currency ON c_order.c_currency_id = c_currency.c_currency_id
+        JOIN m_pricelist ON c_order.m_pricelist_id = m_pricelist.m_pricelist_id
+ WHERE C_Order_ID = v_ID;
  /**
   * Round Base
   */
- --v_Prec := 2;
  IF (INSERTING OR UPDATING) THEN
-     -- Modified by I.Ciordia. Sometimes js fails calculting lineNet
-  :new.LineNetAmt := ROUND(:new.QtyOrdered*:new.PriceActual, v_Prec);-- Modified by I.Ciordia
+  IF (v_istaxincluded = 'Y') THEN
+    -- If tax included taxes recalculate net price
+    :new.line_gross_amount := ROUND(:new.gross_unit_price * :new.qtyordered, v_prec);
+    
+    
+    
+    SELECT tc.ASBOM INTO v_AsBOM FROM C_TAXCATEGORY tc, C_tax t WHERE tc.C_TAXCATEGORY_ID = t.C_TAXCATEGORY_ID AND t.C_TAX_ID = :new.C_Tax_ID;
+    IF (v_AsBOM = 'Y') THEN
+      -- BOM taxes
+      -- Calculate the base for ratios.
+      v_BaseLine := :new.line_gross_amount;
+      -- Calculate total ratio and number of products
+      v_TotalRatio := 0;
+      v_TotalProducts := 0;      
+      FOR Cur_BOM IN (
+        SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+        SUM(ROUND(BOMQTY * BOMPRICE, v_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+        GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+        ORDER BY RATIO ASC )
+      LOOP
+        v_TotalRatio := v_TotalRatio + Cur_BOM.RATIO;
+        v_TotalProducts := v_TotalProducts + 1;
+      END LOOP;
+      
+      -- Calculate taxes based on BOM of products  
+      v_LineAcum := 0;
+      v_NetActual := 0;
+      
+      FOR Cur_BOM IN (
+        SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+        SUM(ROUND(BOMQTY * BOMPRICE, v_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+        GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+        ORDER BY RATIO ASC)
+      LOOP
+       v_TotalProducts := v_TotalProducts - 1;
+        IF (v_TotalProducts > 0) THEN
+          v_Line := ROUND(v_BaseLine * Cur_BOM.RATIO / v_TotalRatio , v_Prec);
+          v_LineAcum := v_LineAcum + v_Line;
+        ELSE -- The last willaccummulate rounding
+          v_Line := v_BaseLine - v_LineAcum;
+        END IF;
+
+        v_PriceLine := C_GET_NET_PRICE_FROM_GROSS(Cur_BOM.TAX, v_Line, v_Line, v_price_prec, :new.qtyordered);     
+        v_CalcLine := ROUND(:new.qtyordered * v_PriceLine, v_Prec); -- In price including taxes the net and net alternate are equals.
+        v_NetActual := v_NetActual + v_CalcLine; -- Acum the net
+      END LOOP;    
+      v_PriceActual := ROUND(v_NetActual / :new.qtyordered, v_price_prec);     
+    ELSE
+      -- Regular taxes
+      v_PriceActual := C_GET_NET_PRICE_FROM_GROSS(:new.c_tax_id, :new.line_gross_amount, :new.taxbaseamt, v_price_prec, :NEW.qtyordered);    
+      v_NetActual := ROUND(:new.QtyOrdered * v_PriceActual, v_Prec);
+    END IF;      
+    
+    :NEW.pricestd := v_priceactual;
+    :NEW.pricelist := v_priceactual;
+    :NEW.pricelimit := v_priceactual;
+    :NEW.priceactual := v_priceactual;
+    :new.taxbaseamt := v_NetActual;
+    :new.LineNetAmt := v_NetActual;
+  ELSE
+    -- Price including taxes = 'N'
+    -- Modified by I.Ciordia. Sometimes js fails calculting lineNet
+    :new.LineNetAmt := ROUND(:new.QtyOrdered*:new.PriceActual, v_Prec);-- Modified by I.Ciordia  
+  END IF;
+  
   :new.FreightAmt := ROUND(:new.FreightAmt, v_Prec);
-  :new.ChargeAmt := ROUND(:new.ChargeAmt, v_Prec);
-  IF (round(to_number(:NEW.QTYORDERED) * to_number(:NEW.PRICEACTUAL),v_Prec) != to_number(:NEW.LINENETAMT)) THEN
-      RAISE_APPLICATION_ERROR(-20000, '@LineAmountNotCorrect@') ;
-    END IF;
+  :new.ChargeAmt := ROUND(:new.ChargeAmt, v_Prec);  
  END IF;
 
  -- Update C_Order.IsCashVAT flag from the line tax rate.
--- a/src-db/database/model/triggers/C_ORDERLINE_TRG2.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/model/triggers/C_ORDERLINE_TRG2.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -36,10 +36,33 @@
   v_grandtotal NUMBER:=0;
   v_taxAmt NUMBER;
   v_Prec C_CURRENCY.STDPRECISION%TYPE;
+  v_PricePrec C_CURRENCY.PRICEPRECISION%TYPE;
   v_AttrSetValueType M_Product.AttrSetValueType%TYPE;
+
   v_oldLineAlternate NUMBER;
   v_create CHAR(1):='Y';
-    
+ 
+  v_Warehouse_ID VARCHAR2(32);
+  v_BPartner_Location_ID VARCHAR2(32);
+  v_Project_ID VARCHAR2(32);
+  v_IsSOTRX CHAR(1);
+  v_AsBOM CHAR(1);  
+  v_TotalRatio NUMBER;
+  v_TotalProducts NUMBER;
+  
+  v_BaseLine NUMBER;
+  v_Line NUMBER;
+  v_LineAcum NUMBER;  
+  v_BaseLineAlternate NUMBER;
+  v_LineAlternate NUMBER;
+  v_LineAlternateAcum NUMBER;
+  
+  v_PriceLine NUMBER;
+  v_CalcLine NUMBER;
+  v_maxline NUMBER;
+          
+  TYPE RECORD IS REF CURSOR;
+  Cur_BOM RECORD;        
 BEGIN
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
@@ -51,19 +74,32 @@
   v_ID:=:NEW.C_ORDER_ID;
 END IF;
 
+IF (UPDATING) THEN
+  IF NOT(COALESCE(:old.M_Product_ID,'0') <> COALESCE(:NEW.M_Product_ID,'0')
+  OR COALESCE(:old.LineNetAmt,0) <> COALESCE(:NEW.LineNetAmt,0)
+  OR COALESCE(:old.FreightAmt,0) <> COALESCE(:NEW.FreightAmt,0)
+  OR COALESCE(:old.ChargeAmt,0) <> COALESCE(:NEW.ChargeAmt,0)
+  OR COALESCE(:old.C_Tax_ID,'0') <> COALESCE(:NEW.C_Tax_ID,'0')
+  OR COALESCE(:old.AD_Org_ID,'0') <> COALESCE(:NEW.AD_Org_ID,'0')
+  OR COALESCE(:old.TaxBaseAmt,0) <> COALESCE(:NEW.TaxBaseAmt,0)
+  OR COALESCE(:old.M_AttributeSetInstance_ID,'0') <> COALESCE(:NEW.M_AttributeSetInstance_ID,'0')
+  OR COALESCE(:old.line_gross_amount,0) <> COALESCE(:NEW.line_gross_amount,0))
+  THEN
+  RETURN;
+  END IF;
+ END IF;
 
   /**************************************************************************
    * Calculate Tax, etc.
    */
- SELECT processed, stdPrecision, m_pricelist.istaxincluded
-   INTO v_processed, v_prec, v_istaxincluded
+ SELECT processed, stdPrecision, priceprecision, m_pricelist.istaxincluded, M_WAREHOUSE_ID, C_BPARTNER_LOCATION_ID, C_PROJECT_ID, ISSOTRX
+   INTO v_processed, v_prec, v_PricePrec, v_istaxincluded, v_Warehouse_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX
  FROM c_order
         JOIN c_currency ON c_order.c_currency_id = c_currency.c_currency_id
         JOIN m_pricelist ON c_order.m_pricelist_id = m_pricelist.m_pricelist_id
  WHERE C_Order_ID=v_ID;
 
 
- IF(v_Processed='N') THEN
    v_oldLine:=0;
    v_newLineNetAmt:=0;
    IF (v_istaxincluded = 'Y') THEN
@@ -82,9 +118,9 @@
     v_oldLine:= COALESCE(:old.LineNetAmt,0) + COALESCE(:old.FreightAmt,0) + COALESCE(:old.ChargeAmt,0);
   END IF;  
   IF (INSERTING OR UPDATING) THEN
+    
     v_newLineNetAmt := COALESCE(:new.LineNetAmt,0) + COALESCE(:new.FreightAmt,0) + COALESCE(:new.ChargeAmt,0);
     v_newLineAlternate := COALESCE(:new.TaxBaseAmt,0) + COALESCE(:new.FreightAmt,0) + COALESCE(:new.ChargeAmt,0);
-
     IF (UPDATING) THEN
       v_oldLineAlternate := COALESCE(:old.TaxBaseAmt,0) + COALESCE(:old.FreightAmt,0) + COALESCE(:old.ChargeAmt,0);
       IF (:new.AD_Org_ID <> :old.AD_Org_ID OR :new.C_Tax_ID <> :old.C_Tax_ID OR
@@ -92,25 +128,83 @@
           :new.line_gross_amount <> :old.line_gross_amount) THEN
         DELETE FROM C_ORDERLINETAX WHERE C_ORDERLINE_ID = :new.C_OrderLine_ID;
         v_create := 'Y';
+      ELSE        
+        v_create := 'N';        
+      END IF;
+    END IF;      
+  
+    IF (v_create = 'Y') THEN        
+    SELECT tc.ASBOM INTO v_AsBOM FROM C_TAXCATEGORY tc, C_tax t WHERE tc.C_TAXCATEGORY_ID = t.C_TAXCATEGORY_ID AND t.C_TAX_ID = :new.C_Tax_ID;
+    IF (v_AsBOM = 'Y') THEN
+      -- BOM taxes
+      -- Calculate the base for ratios.
+      IF (v_istaxincluded = 'Y') THEN
+        v_BaseLine := :new.line_gross_amount;
+        v_BaseLineAlternate := :new.line_gross_amount;
       ELSE
-        v_create := 'N';
+        v_BaseLine := v_newLineNetAmt;
+        v_BaseLineAlternate := v_newLineAlternate;
       END IF;
+
+          -- Calculate total ratio and number of products
+      v_TotalRatio := 0;
+      v_TotalProducts := 0;      
+      FOR Cur_BOM IN (
+        SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+        SUM(ROUND(BOMQTY * BOMPRICE, v_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+        GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+        ORDER BY RATIO ASC )
+      LOOP
+        v_TotalRatio := v_TotalRatio + Cur_BOM.RATIO;
+        v_TotalProducts := v_TotalProducts + 1;
+      END LOOP;
+      
+      -- Calculate taxes based on BOM of products  
+      v_LineAlternateAcum := 0;
+      v_LineAcum := 0;
+      FOR Cur_BOM IN (
+        SELECT C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX) AS TAX,
+        SUM(ROUND(BOMQTY * BOMPRICE, v_Prec)) AS RATIO FROM m_product_bom WHERE m_product_id = :NEW.M_PRODUCT_ID
+        GROUP BY C_GETTAX(m_productbom_id, :new.UPDATED, :new.AD_Org_ID, v_Warehouse_ID, v_Bpartner_Location_ID, v_Bpartner_Location_ID, v_Project_ID, v_IsSOTRX)
+        ORDER BY RATIO ASC )
+      LOOP
+        v_TotalProducts := v_TotalProducts - 1;
+        IF (v_TotalProducts > 0) THEN
+          v_Line := ROUND(v_BaseLine * Cur_BOM.RATIO / v_TotalRatio , v_Prec);
+          v_LineAcum := v_LineAcum + v_Line;
+          v_LineAlternate := ROUND(v_BaseLineAlternate * Cur_BOM.RATIO / v_TotalRatio , v_Prec);
+          v_LineAlternateAcum := v_LineAlternateAcum + v_LineAlternate;
+        ELSE -- The last willaccummulate rounding
+          v_Line := v_BaseLine - v_LineAcum;
+          v_LineAlternate := v_BaseLineAlternate - v_LineAlternateAcum;
+        END IF;
+        IF (v_istaxincluded = 'Y') THEN
+          v_PriceLine := C_GET_NET_PRICE_FROM_GROSS(Cur_BOM.TAX, v_Line, v_LineAlternate, v_PricePrec, :new.qtyordered);
+          v_CalcLine := ROUND(:new.qtyordered * v_PriceLine, v_Prec); -- In price including taxes the net and net alternate are equals.
+          select coalesce(max(line), 0) into v_maxline from c_orderlinetax where c_orderline_id = :new.C_OrderLine_ID;
+          C_ORDERLINETAX_INSERT(:new.AD_Org_ID, :new.C_Order_ID, :new.C_OrderLine_ID, :new.UpdatedBy, Cur_BOM.TAX, Cur_BOM.TAX, v_CalcLine, v_CalcLine, v_Prec);
+        ELSE
+          C_ORDERLINETAX_INSERT(:new.AD_Org_ID, :new.C_Order_ID, :new.C_OrderLine_ID, :new.UpdatedBy, Cur_BOM.TAX, Cur_BOM.TAX, v_Line, v_LineAlternate, v_Prec);
+        END IF;
+      END LOOP;         
+    ELSE
+      -- Regular taxes
+      C_ORDERLINETAX_INSERT(:new.AD_Org_ID, :new.C_Order_ID, :new.C_OrderLine_ID, :new.UpdatedBy, :new.C_Tax_ID, :new.C_Tax_ID, v_newLineNetAmt, v_newLineAlternate, v_Prec);    
+    END IF;
+    
+    IF (v_istaxincluded = 'Y') THEN
+      C_ORDERLINETAX_ROUNDING(:new.C_OrderLine_ID, :new.line_gross_amount, v_newLineNetAmt);
     END IF;
 
-    IF (v_create = 'Y') THEN
-      C_ORDERLINETAX_INSERT(:new.AD_Org_ID, :new.C_Order_ID, :new.C_OrderLine_ID, :new.UpdatedBy, :new.C_Tax_ID, :new.C_Tax_ID, v_newLineNetAmt, v_newLineAlternate, v_Prec);
-      IF (v_istaxincluded = 'Y') THEN
-        C_ORDERLINETAX_ROUNDING(:new.C_OrderLine_ID, :new.line_gross_amount, v_newLineNetAmt);
-      END IF;
-      -- Get Total Tax Amt
-      SELECT SUM(TaxAmt) INTO v_taxAmt
-      FROM C_OrderTax
-      WHERE C_Order_ID=:new.C_Order_ID;
-      -- DBMS_OUTPUT.PUT_LINE('TaxAmt = ' || v_taxAmt);
-      -- Update Header
-      UPDATE C_Order
-      SET TotalLines = TotalLines - v_oldLine + v_newLineNetAmt,
-          GrandTotal = CASE v_istaxincluded
+    -- Get Total Tax Amt
+    SELECT SUM(TaxAmt) INTO v_taxAmt
+    FROM C_OrderTax
+    WHERE C_Order_ID=:new.C_Order_ID;
+    -- DBMS_OUTPUT.PUT_LINE('TaxAmt = ' || v_taxAmt);
+    -- Update Header
+    UPDATE C_Order
+    SET TotalLines = TotalLines - v_oldLine + v_newLineNetAmt,
+        GrandTotal = CASE v_istaxincluded
                        WHEN 'Y' THEN grandtotal - v_oldgrossamt + v_newgrossamt
                        ELSE TotalLines - v_oldLine + v_newLineNetAmt + COALESCE(v_taxAmt, 0)
                        END
@@ -137,8 +231,6 @@
     C_ORDERTAX_ROUNDING(v_id, v_grandtotal, v_totallines);
   END IF;
 
- END IF;
-
  IF (INSERTING OR UPDATING) THEN
   --Does not allow to change the attribute set value
   -- for products which attribute set value type is Fixed
--- a/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_AUXILIARINPUT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -1957,6 +1957,17 @@
 <!--51568B79156646C8966F49F82EE51CB7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--51568B79156646C8966F49F82EE51CB7--></AD_AUXILIARINPUT>
 
+<!--51A01FEBD73F45189B342865ACE44FAC--><AD_AUXILIARINPUT>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <AD_AUXILIARINPUT_ID><![CDATA[51A01FEBD73F45189B342865ACE44FAC]]></AD_AUXILIARINPUT_ID>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <AD_TAB_ID><![CDATA[D53F675ADB2745059623175D8870A721]]></AD_TAB_ID>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <NAME><![CDATA[isQuantityVariable]]></NAME>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <CODE><![CDATA[@SQL=SELECT ISQUANTITYVARIABLE FROM M_PRODUCT where M_PRODUCT_ID = @M_Product_ID@]]></CODE>
+<!--51A01FEBD73F45189B342865ACE44FAC-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--51A01FEBD73F45189B342865ACE44FAC--></AD_AUXILIARINPUT>
+
 <!--523446BDF86D49E1942315BF330CD5B8--><AD_AUXILIARINPUT>
 <!--523446BDF86D49E1942315BF330CD5B8-->  <AD_AUXILIARINPUT_ID><![CDATA[523446BDF86D49E1942315BF330CD5B8]]></AD_AUXILIARINPUT_ID>
 <!--523446BDF86D49E1942315BF330CD5B8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -3904,6 +3915,17 @@
 <!--E40878AA754F4735B145BB8564191534-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--E40878AA754F4735B145BB8564191534--></AD_AUXILIARINPUT>
 
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53--><AD_AUXILIARINPUT>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <AD_AUXILIARINPUT_ID><![CDATA[E4536B2BCBDB4469A130B3BD4D7DEB53]]></AD_AUXILIARINPUT_ID>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <AD_TAB_ID><![CDATA[187]]></AD_TAB_ID>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <NAME><![CDATA[isQuantityVariable]]></NAME>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <CODE><![CDATA[@SQL=SELECT ISQUANTITYVARIABLE FROM M_PRODUCT where M_PRODUCT_ID = @M_Product_ID@]]></CODE>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E4536B2BCBDB4469A130B3BD4D7DEB53--></AD_AUXILIARINPUT>
+
 <!--E4A3C225FA09479DBCB33D4E15A410B8--><AD_AUXILIARINPUT>
 <!--E4A3C225FA09479DBCB33D4E15A410B8-->  <AD_AUXILIARINPUT_ID><![CDATA[E4A3C225FA09479DBCB33D4E15A410B8]]></AD_AUXILIARINPUT_ID>
 <!--E4A3C225FA09479DBCB33D4E15A410B8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4043,6 +4065,17 @@
 <!--ED9749CC067E495FA3D369E65B972450-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--ED9749CC067E495FA3D369E65B972450--></AD_AUXILIARINPUT>
 
+<!--F12E4458B64640EC9200B936D58337ED--><AD_AUXILIARINPUT>
+<!--F12E4458B64640EC9200B936D58337ED-->  <AD_AUXILIARINPUT_ID><![CDATA[F12E4458B64640EC9200B936D58337ED]]></AD_AUXILIARINPUT_ID>
+<!--F12E4458B64640EC9200B936D58337ED-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F12E4458B64640EC9200B936D58337ED-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F12E4458B64640EC9200B936D58337ED-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F12E4458B64640EC9200B936D58337ED-->  <AD_TAB_ID><![CDATA[293]]></AD_TAB_ID>
+<!--F12E4458B64640EC9200B936D58337ED-->  <NAME><![CDATA[isQuantityVariable]]></NAME>
+<!--F12E4458B64640EC9200B936D58337ED-->  <CODE><![CDATA[@SQL=SELECT ISQUANTITYVARIABLE FROM M_PRODUCT where M_PRODUCT_ID = @M_Product_ID@]]></CODE>
+<!--F12E4458B64640EC9200B936D58337ED-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--F12E4458B64640EC9200B936D58337ED--></AD_AUXILIARINPUT>
+
 <!--F1B30F5F741C4709B745AB64E249F6F9--><AD_AUXILIARINPUT>
 <!--F1B30F5F741C4709B745AB64E249F6F9-->  <AD_AUXILIARINPUT_ID><![CDATA[F1B30F5F741C4709B745AB64E249F6F9]]></AD_AUXILIARINPUT_ID>
 <!--F1B30F5F741C4709B745AB64E249F6F9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -227786,6 +227786,41 @@
 <!--123ECC9DA80E47D6BBE8D3C8E9ACC59C-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--123ECC9DA80E47D6BBE8D3C8E9ACC59C--></AD_COLUMN>
 
+<!--126D0666E46B4B41B3D596102127A6D6--><AD_COLUMN>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_COLUMN_ID><![CDATA[126D0666E46B4B41B3D596102127A6D6]]></AD_COLUMN_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <NAME><![CDATA[Bomprice]]></NAME>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <DESCRIPTION><![CDATA[Bill of Materials weighted price]]></DESCRIPTION>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <HELP><![CDATA[Bill of Materials weighted price]]></HELP>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <COLUMNNAME><![CDATA[Bomprice]]></COLUMNNAME>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_TABLE_ID><![CDATA[383]]></AD_TABLE_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_REFERENCE_ID><![CDATA[800008]]></AD_REFERENCE_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <FIELDLENGTH><![CDATA[22]]></FIELDLENGTH>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <SEQNO><![CDATA[12]]></SEQNO>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_ELEMENT_ID><![CDATA[70737B1CCE0146F49577E885A639B059]]></AD_ELEMENT_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <POSITION><![CDATA[16]]></POSITION>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--126D0666E46B4B41B3D596102127A6D6-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--126D0666E46B4B41B3D596102127A6D6--></AD_COLUMN>
+
 <!--129A714A729241E2ABB54C374A4031BD--><AD_COLUMN>
 <!--129A714A729241E2ABB54C374A4031BD-->  <AD_COLUMN_ID><![CDATA[129A714A729241E2ABB54C374A4031BD]]></AD_COLUMN_ID>
 <!--129A714A729241E2ABB54C374A4031BD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -241050,6 +241085,42 @@
 <!--49D072B712FE4B25A3F3A1C608A26898-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--49D072B712FE4B25A3F3A1C608A26898--></AD_COLUMN>
 
+<!--49F5920858E84905861E7BBEF67EC3D8--><AD_COLUMN>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_COLUMN_ID><![CDATA[49F5920858E84905861E7BBEF67EC3D8]]></AD_COLUMN_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <NAME><![CDATA[Asbom]]></NAME>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <DESCRIPTION><![CDATA[Virtual Tax Category that indicates that taxes are defined by the Bill of Materials products]]></DESCRIPTION>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <HELP><![CDATA[Virtual Tax Category that indicates that taxes are defined by the Bill of Materials products]]></HELP>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <COLUMNNAME><![CDATA[Asbom]]></COLUMNNAME>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_TABLE_ID><![CDATA[252]]></AD_TABLE_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <DEFAULTVALUE><![CDATA[N]]></DEFAULTVALUE>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <SEQNO><![CDATA[11]]></SEQNO>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_ELEMENT_ID><![CDATA[8E59B175B6BE4A1285EC9C244F8CC51C]]></AD_ELEMENT_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <POSITION><![CDATA[12]]></POSITION>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--49F5920858E84905861E7BBEF67EC3D8-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--49F5920858E84905861E7BBEF67EC3D8--></AD_COLUMN>
+
 <!--4A0964E5760F4746B324BDBA16B8D1CB--><AD_COLUMN>
 <!--4A0964E5760F4746B324BDBA16B8D1CB-->  <AD_COLUMN_ID><![CDATA[4A0964E5760F4746B324BDBA16B8D1CB]]></AD_COLUMN_ID>
 <!--4A0964E5760F4746B324BDBA16B8D1CB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -26319,6 +26319,20 @@
 <!--703C6A9880D14919B8C2CCE7F2823DC0-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--703C6A9880D14919B8C2CCE7F2823DC0--></AD_ELEMENT>
 
+<!--70737B1CCE0146F49577E885A639B059--><AD_ELEMENT>
+<!--70737B1CCE0146F49577E885A639B059-->  <AD_ELEMENT_ID><![CDATA[70737B1CCE0146F49577E885A639B059]]></AD_ELEMENT_ID>
+<!--70737B1CCE0146F49577E885A639B059-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--70737B1CCE0146F49577E885A639B059-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--70737B1CCE0146F49577E885A639B059-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--70737B1CCE0146F49577E885A639B059-->  <COLUMNNAME><![CDATA[Bomprice]]></COLUMNNAME>
+<!--70737B1CCE0146F49577E885A639B059-->  <NAME><![CDATA[BOM Price]]></NAME>
+<!--70737B1CCE0146F49577E885A639B059-->  <PRINTNAME><![CDATA[BOM Price]]></PRINTNAME>
+<!--70737B1CCE0146F49577E885A639B059-->  <DESCRIPTION><![CDATA[Bill of Materials weighted price]]></DESCRIPTION>
+<!--70737B1CCE0146F49577E885A639B059-->  <HELP><![CDATA[Bill of Materials weighted price]]></HELP>
+<!--70737B1CCE0146F49577E885A639B059-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--70737B1CCE0146F49577E885A639B059-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--70737B1CCE0146F49577E885A639B059--></AD_ELEMENT>
+
 <!--7079E2FD4AA8799EE040007F010104AD--><AD_ELEMENT>
 <!--7079E2FD4AA8799EE040007F010104AD-->  <AD_ELEMENT_ID><![CDATA[7079E2FD4AA8799EE040007F010104AD]]></AD_ELEMENT_ID>
 <!--7079E2FD4AA8799EE040007F010104AD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -28913,6 +28927,20 @@
 <!--8DDFD4A4FC364A109F63347131249176-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--8DDFD4A4FC364A109F63347131249176--></AD_ELEMENT>
 
+<!--8E59B175B6BE4A1285EC9C244F8CC51C--><AD_ELEMENT>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <AD_ELEMENT_ID><![CDATA[8E59B175B6BE4A1285EC9C244F8CC51C]]></AD_ELEMENT_ID>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <COLUMNNAME><![CDATA[Asbom]]></COLUMNNAME>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <NAME><![CDATA[As per BOM]]></NAME>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <PRINTNAME><![CDATA[As per BOM]]></PRINTNAME>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <DESCRIPTION><![CDATA[Virtual Tax Category that indicates that taxes are defined by the Bill of Materials products]]></DESCRIPTION>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <HELP><![CDATA[Virtual Tax Category that indicates that taxes are defined by the Bill of Materials products]]></HELP>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--8E59B175B6BE4A1285EC9C244F8CC51C--></AD_ELEMENT>
+
 <!--8E7CC7A39184B541E040007F01004601--><AD_ELEMENT>
 <!--8E7CC7A39184B541E040007F01004601-->  <AD_ELEMENT_ID><![CDATA[8E7CC7A39184B541E040007F01004601]]></AD_ELEMENT_ID>
 <!--8E7CC7A39184B541E040007F01004601-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -283733,6 +283733,7 @@
 <!--CC2F9E8FD677D7CDE040007F01002E21-->  <AD_COLUMN_ID><![CDATA[CC2F971F21813089E040007F01002D7C]]></AD_COLUMN_ID>
 <!--CC2F9E8FD677D7CDE040007F01002E21-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--CC2F9E8FD677D7CDE040007F01002E21-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--CC2F9E8FD677D7CDE040007F01002E21-->  <DISPLAYLOGIC><![CDATA[@RES_Status@!'CL']]></DISPLAYLOGIC>
 <!--CC2F9E8FD677D7CDE040007F01002E21-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
 <!--CC2F9E8FD677D7CDE040007F01002E21-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--CC2F9E8FD677D7CDE040007F01002E21-->  <SEQNO><![CDATA[0]]></SEQNO>
@@ -291004,6 +291005,35 @@
 <!--D7BCB70AB20F4E9F9B53FA10F43CFB66-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--D7BCB70AB20F4E9F9B53FA10F43CFB66--></AD_FIELD>
 
+<!--D7C30265C22D43E484CB6B225B5E6424--><AD_FIELD>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <AD_FIELD_ID><![CDATA[D7C30265C22D43E484CB6B225B5E6424]]></AD_FIELD_ID>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <NAME><![CDATA[As per BOM]]></NAME>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <DESCRIPTION><![CDATA[Virtual Tax Category that indicates that taxes are defined by the Bill of Materials products]]></DESCRIPTION>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <HELP><![CDATA[Virtual Tax Category that indicates that taxes are defined by the Bill of Materials products]]></HELP>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <AD_TAB_ID><![CDATA[176]]></AD_TAB_ID>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <AD_COLUMN_ID><![CDATA[49F5920858E84905861E7BBEF67EC3D8]]></AD_COLUMN_ID>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <SEQNO><![CDATA[45]]></SEQNO>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <GRID_SEQNO><![CDATA[45]]></GRID_SEQNO>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--D7C30265C22D43E484CB6B225B5E6424-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--D7C30265C22D43E484CB6B225B5E6424--></AD_FIELD>
+
 <!--D7C82000170D43D18F1920A8E96D1949--><AD_FIELD>
 <!--D7C82000170D43D18F1920A8E96D1949-->  <AD_FIELD_ID><![CDATA[D7C82000170D43D18F1920A8E96D1949]]></AD_FIELD_ID>
 <!--D7C82000170D43D18F1920A8E96D1949-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -302007,6 +302037,36 @@
 <!--F4F7389688484D2AA604CE6FF30FC87E-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--F4F7389688484D2AA604CE6FF30FC87E--></AD_FIELD>
 
+<!--F4FD374ECBC54954871142F0F4E8A658--><AD_FIELD>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <AD_FIELD_ID><![CDATA[F4FD374ECBC54954871142F0F4E8A658]]></AD_FIELD_ID>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <NAME><![CDATA[BOM Price]]></NAME>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <DESCRIPTION><![CDATA[Bill of Materials weighted price]]></DESCRIPTION>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <HELP><![CDATA[Bill of Materials weighted price]]></HELP>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <AD_TAB_ID><![CDATA[317]]></AD_TAB_ID>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <AD_COLUMN_ID><![CDATA[126D0666E46B4B41B3D596102127A6D6]]></AD_COLUMN_ID>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <DISPLAYLOGIC><![CDATA[@IsBOM@='Y']]></DISPLAYLOGIC>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <DISPLAYLENGTH><![CDATA[22]]></DISPLAYLENGTH>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <SEQNO><![CDATA[55]]></SEQNO>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <GRID_SEQNO><![CDATA[65]]></GRID_SEQNO>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--F4FD374ECBC54954871142F0F4E8A658-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--F4FD374ECBC54954871142F0F4E8A658--></AD_FIELD>
+
 <!--F4FE34AB8E284CC0A26B91B4F1A791F2--><AD_FIELD>
 <!--F4FE34AB8E284CC0A26B91B4F1A791F2-->  <AD_FIELD_ID><![CDATA[F4FE34AB8E284CC0A26B91B4F1A791F2]]></AD_FIELD_ID>
 <!--F4FE34AB8E284CC0A26B91B4F1A791F2-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -304093,7 +304153,7 @@
 <!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <AD_COLUMN_ID><![CDATA[AEA1C7FCCA5C4142A66621E09FC2C1FA]]></AD_COLUMN_ID>
 <!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <DISPLAYLOGIC><![CDATA[@TransactionCost@!'' & @IsCostPermanent@='N']]></DISPLAYLOGIC>
+<!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <DISPLAYLOGIC><![CDATA[@TransactionCost@!'' & @IsCostPermanent@='N' & @M_Costing_Algorithm_ID@!'6A39D8B46CD94FE682D48758D3B7726B']]></DISPLAYLOGIC>
 <!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--FB1F9DDBE72A45A3AED2953DC3FAFA82-->  <SEQNO><![CDATA[260]]></SEQNO>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -17137,6 +17137,18 @@
 <!--1E4DFEDC675F4BD8AFA6A8D707D77FFF-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--1E4DFEDC675F4BD8AFA6A8D707D77FFF--></AD_MESSAGE>
 
+<!--1E7DAA08317D40A982A3484D3803A8B3--><AD_MESSAGE>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <AD_MESSAGE_ID><![CDATA[1E7DAA08317D40A982A3484D3803A8B3]]></AD_MESSAGE_ID>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <VALUE><![CDATA[BPCurrencyChangeRate]]></VALUE>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <MSGTEXT><![CDATA[It is not possible to convert credit automatically if current balance is 0 and foreign amount is different than 0. In this case, you should use a conversion rate instead.]]></MSGTEXT>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--1E7DAA08317D40A982A3484D3803A8B3-->  <ISINCLUDEINI18N><![CDATA[Y]]></ISINCLUDEINI18N>
+<!--1E7DAA08317D40A982A3484D3803A8B3--></AD_MESSAGE>
+
 <!--1EC11EDD0953422B9B4E8B54690CE345--><AD_MESSAGE>
 <!--1EC11EDD0953422B9B4E8B54690CE345-->  <AD_MESSAGE_ID><![CDATA[1EC11EDD0953422B9B4E8B54690CE345]]></AD_MESSAGE_ID>
 <!--1EC11EDD0953422B9B4E8B54690CE345-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -23218,6 +23230,23 @@
 <!--B077B434599241F6B04A8D01E8302C9C-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--B077B434599241F6B04A8D01E8302C9C--></AD_MESSAGE>
 
+<!--B080C88FF56E4F8594967A6164977D5F--><AD_MESSAGE>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <AD_MESSAGE_ID><![CDATA[B080C88FF56E4F8594967A6164977D5F]]></AD_MESSAGE_ID>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <VALUE><![CDATA[BPCurrencyChange]]></VALUE>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <MSGTEXT><![CDATA[Detected available credit for this business partner. <br/>
+Changing the Business Partner's currency will not allow you to use available credit in the old currency.
+
+If you want to convert the available credit in the old currency into credit in the new currency automatically, select a G/L Item. 
+<br/>
+Otherwise you will have to do it manually following this document: <a href='http://wiki.openbravo.com/wiki/How_to_convert_credit_to_a_different_currency' target='_blank'>How to convert credit to a different currency</a>]]></MSGTEXT>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <MSGTYPE><![CDATA[W]]></MSGTYPE>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--B080C88FF56E4F8594967A6164977D5F-->  <ISINCLUDEINI18N><![CDATA[Y]]></ISINCLUDEINI18N>
+<!--B080C88FF56E4F8594967A6164977D5F--></AD_MESSAGE>
+
 <!--B0976829EBD64E38B342821AABA3ADAB--><AD_MESSAGE>
 <!--B0976829EBD64E38B342821AABA3ADAB-->  <AD_MESSAGE_ID><![CDATA[B0976829EBD64E38B342821AABA3ADAB]]></AD_MESSAGE_ID>
 <!--B0976829EBD64E38B342821AABA3ADAB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -24060,6 +24089,18 @@
 <!--C32F6A68AB474978879C6E39F1FE03E5-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--C32F6A68AB474978879C6E39F1FE03E5--></AD_MESSAGE>
 
+<!--C380295D080546129B16D28D0CE67A6F--><AD_MESSAGE>
+<!--C380295D080546129B16D28D0CE67A6F-->  <AD_MESSAGE_ID><![CDATA[C380295D080546129B16D28D0CE67A6F]]></AD_MESSAGE_ID>
+<!--C380295D080546129B16D28D0CE67A6F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C380295D080546129B16D28D0CE67A6F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C380295D080546129B16D28D0CE67A6F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C380295D080546129B16D28D0CE67A6F-->  <VALUE><![CDATA[ModifyGLJournalLine]]></VALUE>
+<!--C380295D080546129B16D28D0CE67A6F-->  <MSGTEXT><![CDATA[If you want to modify the Credit/Debit/Financial Account/Payment Method/GL Item/Payment Date of any of these lines, you must first reactivate and delete its related payments.]]></MSGTEXT>
+<!--C380295D080546129B16D28D0CE67A6F-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--C380295D080546129B16D28D0CE67A6F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C380295D080546129B16D28D0CE67A6F-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--C380295D080546129B16D28D0CE67A6F--></AD_MESSAGE>
+
 <!--C3A43E71574945BC8986D5B934A69A96--><AD_MESSAGE>
 <!--C3A43E71574945BC8986D5B934A69A96-->  <AD_MESSAGE_ID><![CDATA[C3A43E71574945BC8986D5B934A69A96]]></AD_MESSAGE_ID>
 <!--C3A43E71574945BC8986D5B934A69A96-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -9400,7 +9400,7 @@
 <!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <AD_REF_LIST_ID><![CDATA[51E9ABC6ED344AD1A9DC0DAB968A1F65]]></AD_REF_LIST_ID>
 <!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <VALUE><![CDATA[CL]]></VALUE>
 <!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <NAME><![CDATA[Closed]]></NAME>
 <!--51E9ABC6ED344AD1A9DC0DAB968A1F65-->  <AD_REFERENCE_ID><![CDATA[EE8B072E19034D0FB34CA1CEB3583620]]></AD_REFERENCE_ID>
@@ -10287,7 +10287,7 @@
 <!--85666C41D834448F83D5B3613D7B59D4-->  <AD_REF_LIST_ID><![CDATA[85666C41D834448F83D5B3613D7B59D4]]></AD_REF_LIST_ID>
 <!--85666C41D834448F83D5B3613D7B59D4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--85666C41D834448F83D5B3613D7B59D4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--85666C41D834448F83D5B3613D7B59D4-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--85666C41D834448F83D5B3613D7B59D4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--85666C41D834448F83D5B3613D7B59D4-->  <VALUE><![CDATA[CL]]></VALUE>
 <!--85666C41D834448F83D5B3613D7B59D4-->  <NAME><![CDATA[Close]]></NAME>
 <!--85666C41D834448F83D5B3613D7B59D4-->  <AD_REFERENCE_ID><![CDATA[440DDA64A43F4799AAFF48BC86DC8F78]]></AD_REFERENCE_ID>
--- a/src-db/database/sourcedata/AD_TAB.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_TAB.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -18807,6 +18807,7 @@
 <!--D53F675ADB2745059623175D8870A721-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--D53F675ADB2745059623175D8870A721-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--D53F675ADB2745059623175D8870A721-->  <UIPATTERN><![CDATA[STD]]></UIPATTERN>
+<!--D53F675ADB2745059623175D8870A721-->  <HQLFILTERCLAUSE><![CDATA[e.rESStatus!='CL']]></HQLFILTERCLAUSE>
 <!--D53F675ADB2745059623175D8870A721-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--D53F675ADB2745059623175D8870A721-->  <DISABLE_PARENT_KEY_PROPERTY><![CDATA[N]]></DISABLE_PARENT_KEY_PROPERTY>
 <!--D53F675ADB2745059623175D8870A721-->  <ISREADONLYTREE><![CDATA[N]]></ISREADONLYTREE>
--- a/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -577,17 +577,6 @@
 <!--800486-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--800486--></AD_TEXTINTERFACES>
 
-<!--800487--><AD_TEXTINTERFACES>
-<!--800487-->  <AD_TEXTINTERFACES_ID><![CDATA[800487]]></AD_TEXTINTERFACES_ID>
-<!--800487-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--800487-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--800487-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--800487-->  <TEXT><![CDATA[AVERAGE COST]]></TEXT>
-<!--800487-->  <FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/ReportValuationStock.html]]></FILENAME>
-<!--800487-->  <ISUSED><![CDATA[Y]]></ISUSED>
-<!--800487-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--800487--></AD_TEXTINTERFACES>
-
 <!--800488--><AD_TEXTINTERFACES>
 <!--800488-->  <AD_TEXTINTERFACES_ID><![CDATA[800488]]></AD_TEXTINTERFACES_ID>
 <!--800488-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -20139,6 +20128,17 @@
 <!--A405E19DA38E715BE040007F010047CB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--A405E19DA38E715BE040007F010047CB--></AD_TEXTINTERFACES>
 
+<!--A4D9140571DB4C97BB67734E8216F217--><AD_TEXTINTERFACES>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <AD_TEXTINTERFACES_ID><![CDATA[A4D9140571DB4C97BB67734E8216F217]]></AD_TEXTINTERFACES_ID>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <TEXT><![CDATA[COST]]></TEXT>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/ReportValuationStock.html]]></FILENAME>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--A4D9140571DB4C97BB67734E8216F217-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--A4D9140571DB4C97BB67734E8216F217--></AD_TEXTINTERFACES>
+
 <!--A4EDB3AA68A14937994C020502FAC8D1--><AD_TEXTINTERFACES>
 <!--A4EDB3AA68A14937994C020502FAC8D1-->  <AD_TEXTINTERFACES_ID><![CDATA[A4EDB3AA68A14937994C020502FAC8D1]]></AD_TEXTINTERFACES_ID>
 <!--A4EDB3AA68A14937994C020502FAC8D1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -397,7 +397,7 @@
 <!--6B8309393CF44CCD977219C72458D625-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--6B8309393CF44CCD977219C72458D625-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
 <!--6B8309393CF44CCD977219C72458D625-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
-<!--6B8309393CF44CCD977219C72458D625-->  <DEFAULTVALUE><![CDATA[1]]></DEFAULTVALUE>
+<!--6B8309393CF44CCD977219C72458D625-->  <DEFAULTVALUE><![CDATA["1"]]></DEFAULTVALUE>
 <!--6B8309393CF44CCD977219C72458D625-->  <AD_ELEMENT_ID><![CDATA[534]]></AD_ELEMENT_ID>
 <!--6B8309393CF44CCD977219C72458D625-->  <ISFIXED><![CDATA[N]]></ISFIXED>
 <!--6B8309393CF44CCD977219C72458D625-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
@@ -696,6 +696,31 @@
 <!--D18581DE288A4E3891A8F047355D1CE5-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
 <!--D18581DE288A4E3891A8F047355D1CE5--></OBUIAPP_PARAMETER>
 
+<!--D6043E3651464549808E039AACA8CE70--><OBUIAPP_PARAMETER>
+<!--D6043E3651464549808E039AACA8CE70-->  <OBUIAPP_PARAMETER_ID><![CDATA[D6043E3651464549808E039AACA8CE70]]></OBUIAPP_PARAMETER_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D6043E3651464549808E039AACA8CE70-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <NAME><![CDATA[G/L Item]]></NAME>
+<!--D6043E3651464549808E039AACA8CE70-->  <DESCRIPTION><![CDATA[An alias for the Account Combination which can be commonly used in daily operations.]]></DESCRIPTION>
+<!--D6043E3651464549808E039AACA8CE70-->  <HELP><![CDATA[General ledger item.]]></HELP>
+<!--D6043E3651464549808E039AACA8CE70-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--D6043E3651464549808E039AACA8CE70-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <AD_REFERENCE_VALUE_ID><![CDATA[1A6C5E0A5868417786ECCF3C02B17D65]]></AD_REFERENCE_VALUE_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <COLUMNNAME><![CDATA[c_glitem_id]]></COLUMNNAME>
+<!--D6043E3651464549808E039AACA8CE70-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--D6043E3651464549808E039AACA8CE70-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--D6043E3651464549808E039AACA8CE70-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--D6043E3651464549808E039AACA8CE70-->  <AD_ELEMENT_ID><![CDATA[800080]]></AD_ELEMENT_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--D6043E3651464549808E039AACA8CE70-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--D6043E3651464549808E039AACA8CE70-->  <OBUIAPP_PROCESS_ID><![CDATA[B5C942145F354ABEBC9F16235D80D776]]></OBUIAPP_PROCESS_ID>
+<!--D6043E3651464549808E039AACA8CE70-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--D6043E3651464549808E039AACA8CE70-->  <DISPLAYEDROWS><![CDATA[5]]></DISPLAYEDROWS>
+<!--D6043E3651464549808E039AACA8CE70-->  <DISPLAYTITLE><![CDATA[Y]]></DISPLAYTITLE>
+<!--D6043E3651464549808E039AACA8CE70--></OBUIAPP_PARAMETER>
+
 <!--DBD34BCBFA5D4FFDBA7DDD0565581728--><OBUIAPP_PARAMETER>
 <!--DBD34BCBFA5D4FFDBA7DDD0565581728-->  <OBUIAPP_PARAMETER_ID><![CDATA[DBD34BCBFA5D4FFDBA7DDD0565581728]]></OBUIAPP_PARAMETER_ID>
 <!--DBD34BCBFA5D4FFDBA7DDD0565581728-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -467,7 +467,9 @@
 <!--B5C942145F354ABEBC9F16235D80D776-->  <UIPATTERN><![CDATA[OBUIAPP_PickAndExecute]]></UIPATTERN>
 <!--B5C942145F354ABEBC9F16235D80D776-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
 <!--B5C942145F354ABEBC9F16235D80D776-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
+<!--B5C942145F354ABEBC9F16235D80D776-->  <CLIENTSIDEVALIDATION><![CDATA[OB.CheckAvailableCredit.onProcess]]></CLIENTSIDEVALIDATION>
 <!--B5C942145F354ABEBC9F16235D80D776-->  <ISGRIDLEGACY><![CDATA[Y]]></ISGRIDLEGACY>
+<!--B5C942145F354ABEBC9F16235D80D776-->  <ON_LOAD_FUNCTION><![CDATA[OB.CheckAvailableCredit.onLoad]]></ON_LOAD_FUNCTION>
 <!--B5C942145F354ABEBC9F16235D80D776-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--B5C942145F354ABEBC9F16235D80D776--></OBUIAPP_PROCESS>
 
--- a/src-test/.classpath.template	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/.classpath.template	Mon Jul 27 19:05:39 2015 +0200
@@ -2,11 +2,39 @@
 <classpath>
 	<classpathentry combineaccessrules="false" kind="src" path="/openbravo"/>
 	<classpathentry excluding="build/**" kind="src" path="src"/>
+	<classpathentry kind="src" path="client.kernel-test"/>
+	<classpathentry kind="src" path="test-lib"/>
+	<classpathentry kind="src" path="client.application-src-test"/>
+	<classpathentry kind="src" path="weld-src-test"/>
 	<classpathentry kind="lib" path="/openbravo/lib/test/junit.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/test/hamcrest-all-1.3.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container/openbravo"/>
 	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/OpenbravoWAD"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-container-impl-base-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-container-spi-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-container-test-api-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-container-test-impl-base-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-container-test-spi-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-core-api-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-core-impl-base-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-core-spi-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-junit-container-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-junit-core-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-test-api-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-test-impl-base-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-test-spi-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-testenricher-cdi-1.0.2.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-weld-ee-embedded-1.1-1.0.0.CR8.jar"/>
+	<classpathentry kind="lib" path="test-lib/jboss-ejb3-api-3.1.0.jar"/>
+	<classpathentry kind="lib" path="test-lib/shrinkwrap-api-1.2.2.jar"/>
+	<classpathentry kind="lib" path="test-lib/shrinkwrap-descriptors-api-base-2.0.0-alpha-7.jar"/>
+	<classpathentry kind="lib" path="test-lib/shrinkwrap-descriptors-spi-2.0.0-alpha-7.jar"/>
+	<classpathentry kind="lib" path="test-lib/shrinkwrap-impl-base-1.2.2.jar"/>
+	<classpathentry kind="lib" path="test-lib/shrinkwrap-spi-1.2.2.jar"/>
+	<classpathentry kind="lib" path="test-lib/validation-api-1.0.0.GA.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-config-api-1.1.8.Final.jar"/>
+	<classpathentry kind="lib" path="test-lib/arquillian-config-impl-base-1.1.8.Final.jar"/>
 	<classpathentry kind="output" path="build/classes"/>
 </classpath>
--- a/src-test/.project	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/.project	Mon Jul 27 19:05:39 2015 +0200
@@ -14,4 +14,32 @@
 	<natures>
 		<nature>org.eclipse.jdt.core.javanature</nature>
 	</natures>
+	<linkedResources>
+		<link>
+			<name>client.application-src-test</name>
+			<type>2</type>
+			<locationURI>MODULES/org.openbravo.client.application/src-test</locationURI>
+		</link>
+		<link>
+			<name>client.kernel-test</name>
+			<type>2</type>
+			<locationURI>MODULES/org.openbravo.client.kernel/src-test</locationURI>
+		</link>
+		<link>
+			<name>test-lib</name>
+			<type>2</type>
+			<locationURI>MODULES/org.openbravo.base.weld/lib/test</locationURI>
+		</link>
+		<link>
+			<name>weld-src-test</name>
+			<type>2</type>
+			<locationURI>MODULES/org.openbravo.base.weld/src-test</locationURI>
+		</link>
+	</linkedResources>
+	<variableList>
+		<variable>
+			<name>MODULES</name>
+			<value>$%7BPARENT-1-PROJECT_LOC%7D/modules</value>
+		</variable>
+	</variableList>
 </projectDescription>
--- a/src-test/build.xml	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/build.xml	Mon Jul 27 19:05:39 2015 +0200
@@ -32,16 +32,33 @@
   </path>
 
   <path id="test.class.path">
-    <path refid="project.class.path"/>
+    <path refid="test-src-dirs"/>
+    <pathelement path="${build.test}" />
+  	<pathelement path="${build}" />
     <fileset dir="${base.lib}">
-      <include name="**/test/*.jar" />
+      <include name="**/*.jar" />
+    </fileset>
+    <fileset dir="${build.core.lib}">
+      <include name="openbravo-core.jar" />
+    </fileset>
+    <fileset dir="${build.trl.lib}">
+      <include name="openbravo-trl.jar" />
+    </fileset>
+    <fileset dir="${build.wad.lib}">
+      <include name="openbravo-wad.jar" />
+    </fileset>
+    <fileset dir="${base.lib}">
+      <include name="**/*.jar" />
+    </fileset>
+    <fileset dir="${base.db}/lib/">
+      <include name="**/*.jar" />
     </fileset>
     <fileset dir="${base.modules}">
-      <include name="**/test/*.jar" />
-    </fileset> 
+      <include name="*/lib/**" />
+    </fileset>
   </path>
 
-  <target name="compile.test" depends="compileSqlc,generate.entities.quick">
+  <target name="compile.test" depends="sqlc,generate.entities.quick">
   	 <mkdir dir="${build.test}"/>
      <javac destdir="${build.test}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" nowarn="${friendlyWarnings}" includeantruntime="false">
       <src refid="test-src-dirs"/>
@@ -57,7 +74,7 @@
 
   <target name="run.tests" depends="compile.test, copy.xml">
     <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
+      <classpath refid="test.class.path" />
       <formatter type="plain" usefile="no"/>
       <test name="org.openbravo.test.AntTaskTests" haltonfailure="no"/>
     </junit>
@@ -65,7 +82,7 @@
 
   <target name="run.all.tests" depends="compile.test, copy.xml">
     <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
+      <classpath refid="test.class.path" />
       <formatter type="plain" usefile="no"/>
       <test name="org.openbravo.test.AllAntTaskTests" haltonfailure="no" outfile="../src/result">
       <formatter type="xml" />
@@ -75,15 +92,23 @@
 
   <target name="run.quick.tests" depends="compile.test, copy.xml">
     <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
+      <classpath refid="test.class.path" />
       <formatter type="plain" usefile="no"/>
       <test name="org.openbravo.test.AllQuickAntTaskTests" haltonfailure="no"/>
     </junit>
   </target>
 
+  <target name="run.test" depends="compile.test, copy.xml">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="test.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="${test}" haltonfailure="no"/>
+    </junit>
+  </target>
+
   <target name="run.webservice.tests" depends="compile.test, copy.xml">
     <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
+      <classpath refid="test.class.path" />
       <formatter type="plain" usefile="no"/>
       <test name="org.openbravo.test.AllWebserviceTests" haltonfailure="no" outfile="../src/resultws">
         <formatter type="xml" />
@@ -92,7 +117,7 @@
   </target>
 
   <target name="run.api.test.javascript" depends="compile.test">
-    <taskdef name="jstest" classname="org.openbravo.test.javascript.JavaScriptAntTest" classpathref="project.class.path" />
+    <taskdef name="jstest" classname="org.openbravo.test.javascript.JavaScriptAntTest" classpathref="test.class.path" />
     <property name="export" value="no" />
     <jstest apiDetailsPath="${api.test.javascript.details}" jsPath="${base.web}/js" export="${export}" />
   </target>
--- a/src-test/src/org/openbravo/test/AllAntTaskTests.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/src/org/openbravo/test/AllAntTaskTests.java	Mon Jul 27 19:05:39 2015 +0200
@@ -21,6 +21,17 @@
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
+import org.openbravo.base.weld.test.testinfrastructure.CdiInfrastructure;
+import org.openbravo.base.weld.test.testinfrastructure.DalPersistanceEventTest;
+import org.openbravo.base.weld.test.testinfrastructure.ParameterizedCdi;
+import org.openbravo.client.application.test.ApplicationTest;
+import org.openbravo.client.application.test.DynamicExpressionParserTest;
+import org.openbravo.client.application.test.GenerateTypesJSTest;
+import org.openbravo.client.application.test.MenuTemplateTest;
+import org.openbravo.client.application.test.MenuTest;
+import org.openbravo.client.kernel.freemarker.test.FreemarkerTemplateProcessorTest;
+import org.openbravo.client.kernel.freemarker.test.GenerateComponentTest;
+import org.openbravo.client.kernel.freemarker.test.LabelTest;
 import org.openbravo.erpCommon.info.ClassicSelectorTest;
 import org.openbravo.test.accounting.PostDocumentTest;
 import org.openbravo.test.accounting.RecordID2Test;
@@ -55,6 +66,7 @@
 import org.openbravo.test.modularity.DBPrefixTest;
 import org.openbravo.test.modularity.DatasetServiceTest;
 import org.openbravo.test.modularity.MergePropertiesTest;
+import org.openbravo.test.modularity.ModuleScriptsVersions;
 import org.openbravo.test.modularity.TableNameTest;
 import org.openbravo.test.preference.PreferenceTest;
 import org.openbravo.test.scheduling.ProcessSchedulingTest;
@@ -68,6 +80,7 @@
 import org.openbravo.test.system.SystemServiceTest;
 import org.openbravo.test.system.SystemValidatorTest;
 import org.openbravo.test.system.TestInfrastructure;
+import org.openbravo.test.taxes.TaxesTest;
 import org.openbravo.test.xml.ClientExportImportTest;
 import org.openbravo.test.xml.DatasetExportTest;
 import org.openbravo.test.xml.DefaultsDataset;
@@ -88,16 +101,16 @@
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
 
-// dal
-    DalComplexQueryRequisitionTest.class,//
-    DalComplexQueryTestOrderLine.class,//
-    DalPerformanceInventoryLineTest.class,//
+    // dal
+    DalComplexQueryRequisitionTest.class, //
+    DalComplexQueryTestOrderLine.class, //
+    DalPerformanceInventoryLineTest.class, //
     DalPerformanceProductTest.class, //
     DalPerformanceProxyTest.class, //
-    DalQueryTest.class,//
-    DalFilterTest.class,//
-    DalTest.class,//
-    DalUtilTest.class,//
+    DalQueryTest.class, //
+    DalFilterTest.class, //
+    DalTest.class, //
+    DalUtilTest.class, //
     IssuesTest.class, //
     DalConnectionProviderTest.class, //
     DynamicEntityTest.class, //
@@ -160,9 +173,32 @@
     // Accounting
     RecordID2Test.class, //
     PostDocumentTest.class, //
+    // Taxes
+    TaxesTest.class, //
 
     // scheduling
-    ProcessSchedulingTest.class //
+    ProcessSchedulingTest.class, //
+
+    // cdi
+    CdiInfrastructure.class, //
+    ParameterizedCdi.class, //
+    DalPersistanceEventTest.class, //
+
+    // client application
+    ApplicationTest.class, //
+    DynamicExpressionParserTest.class, //
+    GenerateTypesJSTest.class, //
+    MenuTest.class, //
+    MenuTemplateTest.class, //
+
+    // client kernel
+    FreemarkerTemplateProcessorTest.class, //
+    GenerateComponentTest.class, //
+    LabelTest.class, //
+
+    // moduleScripts
+    ModuleScriptsVersions.class
+
 })
 public class AllAntTaskTests {
 }
--- a/src-test/src/org/openbravo/test/AllTests.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/src/org/openbravo/test/AllTests.java	Mon Jul 27 19:05:39 2015 +0200
@@ -21,6 +21,7 @@
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
+import org.openbravo.base.weld.test.testinfrastructure.CdiInfrastructure;
 import org.openbravo.erpCommon.info.ClassicSelectorTest;
 import org.openbravo.test.dal.ComputedColumnsTest;
 import org.openbravo.test.dal.DalConnectionProviderTest;
@@ -99,6 +100,9 @@
     EntityXMLIssues.class, //
     UniqueConstraintImportTest.class, //
     DefaultsDataset.class, //
-    ClassicSelectorTest.class })
+    ClassicSelectorTest.class,
+
+    // cdi
+    CdiInfrastructure.class })
 public class AllTests {
 }
--- a/src-test/src/org/openbravo/test/AntTaskTests.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/src/org/openbravo/test/AntTaskTests.java	Mon Jul 27 19:05:39 2015 +0200
@@ -21,6 +21,7 @@
 
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
+import org.openbravo.base.weld.test.testinfrastructure.CdiInfrastructure;
 import org.openbravo.erpCommon.info.ClassicSelectorTest;
 import org.openbravo.test.dal.ComputedColumnsTest;
 import org.openbravo.test.dal.DalComplexQueryRequisitionTest;
@@ -138,6 +139,11 @@
     UniqueConstraintImportTest.class, //
     DatasetExportTest.class, //
     DefaultsDataset.class, //
-    ClassicSelectorTest.class, })
+    ClassicSelectorTest.class,
+
+    // cdi
+    CdiInfrastructure.class,
+
+})
 public class AntTaskTests {
 }
\ No newline at end of file
--- a/src-test/src/org/openbravo/test/costing/TestCosting.java	Wed Jul 22 17:54:36 2015 +0200
+++ b/src-test/src/org/openbravo/test/costing/TestCosting.java	Mon Jul 27 19:05:39 2015 +0200
@@ -9903,8 +9903,8 @@
           .setDocumentNo(getDocumentNo(order.getDocumentType().getDocumentSequence().getId()));
       orderClone.setOrderDate(DateUtils.addDays(today, day));
       orderClone.setScheduledDeliveryDate(DateUtils.addDays(today, day));
-      orderClone.setSummedLineAmount(quantity.multiply(price));
-      orderClone.setGrandTotalAmount(quantity.multiply(price));
+      orderClone.setSummedLineAmount(BigDecimal.ZERO);
+      orderClone.setGrandTotalAmount(BigDecimal.ZERO);
 
       // Get the first line associated with the order and clone it to the new order
       OrderLine orderLine = order.getOrderLineList().get(0);
@@ -10002,8 +10002,6 @@
       orderLine.setStandardPrice(price);
       orderLine.setLineNetAmount(orderLine.getOrderedQuantity().multiply(price));
       orderLine.setTaxableAmount(orderLine.getOrderedQuantity().multiply(price));
-      order.setSummedLineAmount(orderLine.getOrderedQuantity().multiply(price));
-      order.setGrandTotalAmount(orderLine.getOrderedQuantity().multiply(price));
 
       OBDal.getInstance().save(order);
       OBDal.getInstance().flush();
@@ -10043,8 +10041,8 @@
 
       invoiceClone.setInvoiceDate(DateUtils.addDays(today, day));
       invoiceClone.setAccountingDate(DateUtils.addDays(today, day));
-      invoiceClone.setSummedLineAmount(quantity.multiply(price));
-      invoiceClone.setGrandTotalAmount(quantity.multiply(price));
+      invoiceClone.setSummedLineAmount(BigDecimal.ZERO);
+      invoiceClone.setGrandTotalAmount(BigDecimal.ZERO);
       invoiceClone.setPriceList(OBDal.getInstance().get(Product.class, productId)
           .getPricingProductPriceList().get(0).getPriceListVersion().getPriceList());
       if (bpartnerId != null) {
@@ -10414,8 +10412,6 @@
       invoiceLine.setUnitPrice(price);
       invoiceLine.setStandardPrice(price);
       invoiceLine.setLineNetAmount(invoiceLine.getInvoicedQuantity().multiply(price));
-      invoice.setSummedLineAmount(invoiceLine.getInvoicedQuantity().multiply(price));
-      invoice.setGrandTotalAmount(invoiceLine.getInvoicedQuantity().multiply(price));
 
       OBDal.getInstance().save(invoice);
       OBDal.getInstance().flush();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/modularity/ModuleScriptsVersions.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,145 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.modularity;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.modulescript.ModuleScript;
+import org.openbravo.modulescript.ModuleScriptExecutionLimits;
+import org.openbravo.modulescript.OpenbravoVersion;
+
+/**
+ * Test cases covering module script executions when updating database regarding the original
+ * version the module is being updated from.
+ * 
+ * @author alostale
+ * 
+ */
+@RunWith(Parameterized.class)
+public class ModuleScriptsVersions {
+
+  /** current module version we are updating from */
+  final static Map<String, OpenbravoVersion> modulesVersionMap;
+  static {
+    String currentCoreVersion = "3.0.10000";
+
+    modulesVersionMap = new HashMap<String, OpenbravoVersion>();
+    modulesVersionMap.put("0", new OpenbravoVersion(currentCoreVersion));
+  }
+
+  private String moduleId;
+  private String fromVersion;
+  private String toVersion;
+  private boolean onInstall;
+  private boolean shouldExecute;
+
+  /**
+   * @param moduleId
+   *          UUID of the module to establish the dependency with
+   * @param fromVersion
+   *          defines the first module version of the execution dependency
+   * @param toVersion
+   *          defines the last module version of the execution dependency
+   * @param onInstall
+   *          flag to indicate if the moduleScript should be executed on install
+   * @param shouldExecute
+   *          flag to indicate the final result, i.e., if the moduleScript should be executed or not
+   * @param description
+   *          description for the test case
+   */
+  public ModuleScriptsVersions(String moduleId, String fromVersion, String toVersion,
+      boolean onInstall, boolean shouldExecute, String description) {
+    this.moduleId = moduleId;
+    this.fromVersion = fromVersion;
+    this.toVersion = toVersion;
+    this.onInstall = onInstall;
+    this.shouldExecute = shouldExecute;
+  }
+
+  @Parameters(name = "{index}: ''{5}'' -- moduleId: {0} - version limits: [{1}-{2}] - on install: {3} - should execute: {4}")
+  public static Collection<Object[]> data() {
+    return Arrays
+        .asList(new Object[][] {
+            { "AAA", null, null, true, true, "New module should be executed on install" },
+            { "AAA", null, null, false, false, "New module should not be executed on install" },
+
+            // fromVersion defined without toVersion
+            { "0", "3.0.9000", null, true, true,
+                "Minimum version does not affect, is lower than current one, should execute" },
+            { "0", "3.0.20000", null, true, false,
+                "Minimum version is higher than current one, should not execute (issue does not exist yet)" },
+
+            // toVersion defined without fromVersion
+            { "0", null, "3.0.9000", true, false,
+                "Updating from newer, should not execute (issue was already fixed)" },
+            { "0", null, "3.0.20000", true, true,
+                "Updating from older, should execute (issue was not yet fixed)" },
+
+            // both boundaries defined
+            { "0", "3.0.20000", "3.0.9000", true, false, "Incorrect definition" },
+            { "0", "3.0.8000", "3.0.20000", true, true, "---" },
+            { "0", "3.0.8000", "3.0.9000", true, false, "---" },
+            { "0", "3.0.15000", "3.0.20000", true, false, "---" } });
+  }
+
+  /** Executes the module script with current version boundaries */
+  @Test
+  public void moduleScriptIsExecutedBasedOnVersionLimits() {
+    FakeModuleScript ms = new FakeModuleScript();
+    ms.preExecute(modulesVersionMap);
+    assertThat("Script was executed", ms.wasExecuted, is(shouldExecute));
+  }
+
+  /** Fake module script with version limits, it simply flags when it is executed */
+  public class FakeModuleScript extends ModuleScript {
+    /** flag set when the script has been executed */
+    boolean wasExecuted = false;
+
+    @Override
+    public void execute() {
+      wasExecuted = true;
+    }
+
+    @Override
+    public ModuleScriptExecutionLimits getModuleScriptExecutionLimits() {
+      if (moduleId == null) {
+        return null;
+      }
+      return new ModuleScriptExecutionLimits(moduleId, //
+          fromVersion == null ? null : new OpenbravoVersion(fromVersion),//
+          toVersion == null ? null : new OpenbravoVersion(toVersion));
+    }
+
+    @Override
+    public boolean executeOnInstall() {
+      return onInstall;
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/TaxesTest.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,738 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes;
+
+import static org.hamcrest.Matchers.closeTo;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.hibernate.criterion.Restrictions;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.dal.core.DalUtil;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.SequenceIdData;
+import org.openbravo.model.ad.access.InvoiceLineTax;
+import org.openbravo.model.ad.access.OrderLineTax;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.invoice.Invoice;
+import org.openbravo.model.common.invoice.InvoiceLine;
+import org.openbravo.model.common.invoice.InvoiceTax;
+import org.openbravo.model.common.order.Order;
+import org.openbravo.model.common.order.OrderLine;
+import org.openbravo.model.common.order.OrderTax;
+import org.openbravo.model.common.plm.Product;
+import org.openbravo.model.financialmgmt.tax.TaxRate;
+import org.openbravo.model.pricing.pricelist.PriceList;
+import org.openbravo.test.base.OBBaseTest;
+import org.openbravo.test.taxes.data.TaxesTestData;
+import org.openbravo.test.taxes.data.TaxesTestData1;
+import org.openbravo.test.taxes.data.TaxesTestData10;
+import org.openbravo.test.taxes.data.TaxesTestData11;
+import org.openbravo.test.taxes.data.TaxesTestData12;
+import org.openbravo.test.taxes.data.TaxesTestData13;
+import org.openbravo.test.taxes.data.TaxesTestData14;
+import org.openbravo.test.taxes.data.TaxesTestData15;
+import org.openbravo.test.taxes.data.TaxesTestData16;
+import org.openbravo.test.taxes.data.TaxesTestData17;
+import org.openbravo.test.taxes.data.TaxesTestData18;
+import org.openbravo.test.taxes.data.TaxesTestData19;
+import org.openbravo.test.taxes.data.TaxesTestData2;
+import org.openbravo.test.taxes.data.TaxesTestData20;
+import org.openbravo.test.taxes.data.TaxesTestData21;
+import org.openbravo.test.taxes.data.TaxesTestData22;
+import org.openbravo.test.taxes.data.TaxesTestData23;
+import org.openbravo.test.taxes.data.TaxesTestData24;
+import org.openbravo.test.taxes.data.TaxesTestData25;
+import org.openbravo.test.taxes.data.TaxesTestData26;
+import org.openbravo.test.taxes.data.TaxesTestData27;
+import org.openbravo.test.taxes.data.TaxesTestData28;
+import org.openbravo.test.taxes.data.TaxesTestData29;
+import org.openbravo.test.taxes.data.TaxesTestData3;
+import org.openbravo.test.taxes.data.TaxesTestData30;
+import org.openbravo.test.taxes.data.TaxesTestData31;
+import org.openbravo.test.taxes.data.TaxesTestData32;
+import org.openbravo.test.taxes.data.TaxesTestData33;
+import org.openbravo.test.taxes.data.TaxesTestData34;
+import org.openbravo.test.taxes.data.TaxesTestData4;
+import org.openbravo.test.taxes.data.TaxesTestData5;
+import org.openbravo.test.taxes.data.TaxesTestData6;
+import org.openbravo.test.taxes.data.TaxesTestData7;
+import org.openbravo.test.taxes.data.TaxesTestData8;
+import org.openbravo.test.taxes.data.TaxesTestData9;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests cases to check taxes computation
+ * 
+ * 
+ */
+@RunWith(Parameterized.class)
+public class TaxesTest extends OBBaseTest {
+  final static private Logger log = LoggerFactory.getLogger(TaxesTest.class);
+  // User Openbravo
+  private final String USER_ID = "100";
+  // Client QA Testing
+  private final String CLIENT_ID = "4028E6C72959682B01295A070852010D";
+  // Organization Spain
+  private final String ORGANIZATION_ID = "357947E87C284935AD1D783CF6F099A1";
+  // Role QA Testing Admin
+  private final String ROLE_ID = "4028E6C72959682B01295A071429011E";
+  // Purchase Invoice with documentNo: 10000017
+  private final String PURCHASEINVOICE_ID = "9D0F6E57E59247F6AB6D063951811F51";
+  // Sales Invoice with documentNo: 10000017
+  private final String SALESINVOICE_ID = "F889F6E61CA6454EA50BDD6DD75582E3";
+  // PriceList: Price including taxes
+  private final String PRICEINCLUDINGTAXES_PRICELIST_SALES = "62C67BFD306C4BEF9F2738C27353380B";
+  private final String PRICEINCLUDINGTAXES_PRICELIST_PURCHASE = "83BD2A678D30447983755C4E46C6F69A";
+  // Sales order: 50012
+  private final String SALESORDER_ID = "8B53B7E6CF3B4D8D9BCF3A49EED6FCB4";
+  // Purchase Order: 800010
+  private final String PURCHASEORDER_ID = "2C9CEDC0761A41DCB276A5124F8AAA90";
+
+  private String testNumber;
+  private String testDescription;
+  private String productId;
+  private BigDecimal quantity;
+  private BigDecimal price;
+  private BigDecimal lineNet;
+  private BigDecimal quantityUpdated;
+  private BigDecimal priceUpdated;
+  private BigDecimal lineNetUpdated;
+  private String bpartnerId;
+  private String taxid;
+  private HashMap<String, String[]> linetaxes;
+  private HashMap<String, String[]> doctaxes;
+  private boolean isSalesTest;
+  private boolean isPriceIncludingTaxes;
+
+  public TaxesTest(String testNumber, String testDescription, TaxesTestData data) {
+    this.testNumber = testNumber;
+    this.testDescription = testDescription;
+    this.productId = data.getProductId();
+    this.quantityUpdated = data.getQuantityUpdated();
+    this.priceUpdated = data.getPriceUpdated();
+    this.quantity = data.getQuantity();
+    this.price = data.getPrice();
+    this.bpartnerId = data.getBpartnerId();
+    this.taxid = data.getTaxid();
+    this.linetaxes = data.getLinetaxes();
+    this.doctaxes = data.getDoctaxes();
+    this.isSalesTest = data.isSalesTest();
+    this.isPriceIncludingTaxes = data.isPriceIncludingTaxes();
+    this.lineNet = data.getLineNet();
+    this.lineNetUpdated = data.getLineNetUpdated();
+  }
+
+  /** parameterized possible combinations for taxes computation */
+  @Parameters(name = "idx:{0} name:{1}")
+  public static Collection<Object[]> params() {
+    return Arrays.asList(new Object[][] {
+        { "01", "Regular pricelist 01: Purchase Exempt positive", new TaxesTestData1() },
+        { "02", "Regular pricelist 02: Purchase Exempt negative", new TaxesTestData2() }, //
+        { "03", "Regular pricelist 03: Purchase 10% positive", new TaxesTestData3() }, //
+        { "04", "Regular pricelist 04: Purchase 10% negative", new TaxesTestData4() }, //
+        { "05", "Regular pricelist 05: Purchase 3% + Charge positive", new TaxesTestData5() }, //
+        { "06", "Regular pricelist 06: Purchase 3% + Charge negative", new TaxesTestData6() }, //
+        { "07", "Regular pricelist 07: Sales Exempt positive", new TaxesTestData7() }, //
+        { "08", "Regular pricelist 08: Sales Exempt negative", new TaxesTestData8() }, //
+        { "09", "Regular pricelist 09: Sales 10% Positive", new TaxesTestData9() }, //
+        { "10", "Regular pricelist 10: Sales 10% negative", new TaxesTestData10() }, //
+        { "11", "Regular pricelist 11: Sales 3% + charge positive", new TaxesTestData11() }, //
+        { "12", "Regular pricelist 12: Sales 3% + charge negative", new TaxesTestData12() }, //
+        { "13", "Regular pricelist 13: Sales BOM Taxes Positive", new TaxesTestData13() }, //
+        { "14", "Regular pricelist 14: Sales BOM Taxes Negative", new TaxesTestData14() }, //
+        { "15", "Regular pricelist 15: Purchase BOM Taxes Positive", new TaxesTestData15() }, //
+        { "16", "Regular pricelist 16: Purchase BOM Taxes Negative", new TaxesTestData16() }, //
+        { "17", "Price including taxes 17: Purchase Exempt positive", new TaxesTestData17() }, //
+        { "18", "Price including taxes 18: Purchase Exempt negative", new TaxesTestData18() }, //
+        { "19", "Price including taxes 19: Purchase 10% positive", new TaxesTestData19() }, //
+        { "20", "Price including taxes 20: Purchase 10% negative", new TaxesTestData20() }, //
+        { "21", "Price including taxes 21: Purchase 3% + charge positive", new TaxesTestData21() }, //
+        { "22", "Price including taxes 22: Purchase 3% + charge negative", new TaxesTestData22() }, //
+        { "23", "Price including taxes 23: Sales Exempt positive", new TaxesTestData23() }, //
+        { "24", "Price including taxes 24: Sales Exempt negative", new TaxesTestData24() }, //
+        { "25", "Price including taxes 25: Sales 10 % positive", new TaxesTestData25() }, //
+        { "26", "Price including taxes 26: Sales 10% negative", new TaxesTestData26() }, //
+        { "27", "Price including taxes 27: Sales 3% + charge positive", new TaxesTestData27() },//
+        { "28", "Price including taxes 28: Sales 3% + charge negative", new TaxesTestData28() },//
+
+        //
+
+        { "29", "Price including taxes 29: Purchase BOM Taxes negative", new TaxesTestData29() },//
+        { "30", "Price including taxes 30: Sales BOM Taxes negative", new TaxesTestData30() }, //
+        { "31", "Price including taxes 31: Purchase BOM Taxes positive", new TaxesTestData31() }, //
+        { "32", "Price including taxes 32: Sales BOM Taxes negative", new TaxesTestData32() },//
+        { "33", "Price including taxes 33: Sales BOM+Exempt negative", new TaxesTestData33() }, //
+        { "34", "Price including taxes 34: Sales BOM+Exempt positive", new TaxesTestData34() } //
+        });
+  }
+
+  /**
+   * Verifies taxes computation for invoices. Regular PriceList: Add a line, update it and delete
+   * it. Review tax computation is correct
+   */
+  @Test
+  public void testTax_Invoiceline_RegularPriceList() {
+    assumeFalse(this.isPriceIncludingTaxes);
+    // Set QA context
+    OBContext.setOBContext(USER_ID, ROLE_ID, CLIENT_ID, ORGANIZATION_ID);
+    try {
+      Invoice invoice;
+      if (isSalesTest) {
+        invoice = OBDal.getInstance().get(Invoice.class, SALESINVOICE_ID);
+      } else {
+        invoice = OBDal.getInstance().get(Invoice.class, PURCHASEINVOICE_ID);
+      }
+      Invoice testInvoice = (Invoice) DalUtil.copy(invoice, false);
+      testInvoice.setDocumentNo("RegularPriceList " + testNumber);
+      testInvoice.setDescription(testDescription);
+      testInvoice.setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class, bpartnerId));
+      testInvoice.setSummedLineAmount(BigDecimal.ZERO);
+      testInvoice.setGrandTotalAmount(BigDecimal.ZERO);
+      testInvoice.setId(SequenceIdData.getUUID());
+      testInvoice.setNewOBObject(true);
+      OBDal.getInstance().save(testInvoice);
+      OBDal.getInstance().flush();
+      log.debug("Invoice Created:" + testInvoice.getDocumentNo());
+      log.debug(testDescription);
+      InvoiceLine invoiceLine = invoice.getInvoiceLineList().get(0);
+      InvoiceLine testInvoiceLine = (InvoiceLine) DalUtil.copy(invoiceLine, false);
+      Product product = OBDal.getInstance().get(Product.class, productId);
+      testInvoiceLine.setProduct(product);
+      testInvoiceLine.setUOM(product.getUOM());
+      testInvoiceLine.setInvoicedQuantity(quantity);
+      testInvoiceLine.setUnitPrice(price);
+      testInvoiceLine.setListPrice(price);
+      testInvoiceLine.setStandardPrice(price);
+      testInvoiceLine.setLineNetAmount(quantity.multiply(price));
+      testInvoiceLine.setTax(OBDal.getInstance().get(TaxRate.class, taxid));
+      testInvoiceLine.setTaxAmount(BigDecimal.ZERO);
+      testInvoiceLine.setTaxableAmount(quantity.multiply(price));
+      if (bpartnerId != null) {
+        testInvoiceLine.setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class,
+            bpartnerId));
+      }
+      testInvoiceLine.setInvoice(testInvoice);
+      testInvoice.getInvoiceLineList().add(testInvoiceLine);
+      testInvoiceLine.setId(SequenceIdData.getUUID());
+      testInvoiceLine.setNewOBObject(true);
+      OBDal.getInstance().save(testInvoiceLine);
+      OBDal.getInstance().save(testInvoice);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testInvoice);
+      OBDal.getInstance().refresh(testInvoiceLine);
+      // Now test taxes for inserted line
+      BigDecimal totalTax = testTaxes(testInvoice, false);
+      testLineTaxes(testInvoiceLine, false);
+      // Test update of a line
+      OBDal.getInstance().getSession().clear();
+      testInvoice = OBDal.getInstance().get(Invoice.class, testInvoice.getId());
+      // Asserts for grandTotal and TotalLines
+      assertThat("Wrong Invoice GrandTotal", testInvoice.getGrandTotalAmount(),
+          closeTo(quantity.multiply(price).add(totalTax), BigDecimal.ZERO));
+      assertThat("Wrong Invoice TotalLines", testInvoice.getSummedLineAmount(),
+          closeTo(quantity.multiply(price), BigDecimal.ZERO));
+      // UpdateLine
+      testInvoiceLine.setInvoicedQuantity(quantityUpdated);
+      testInvoiceLine.setLineNetAmount(quantityUpdated.multiply(priceUpdated));
+      testInvoiceLine.setTaxableAmount(quantityUpdated.multiply(priceUpdated));
+      OBDal.getInstance().save(testInvoiceLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testInvoice);
+      // Now test taxes for inserted line
+      totalTax = testTaxes(testInvoice, true);
+      testLineTaxes(testInvoiceLine, true);
+      assertThat("Wrong Invoice GrandTotal", testInvoice.getGrandTotalAmount(),
+          closeTo(quantityUpdated.multiply(priceUpdated).add(totalTax), BigDecimal.ZERO));
+      assertThat("Wrong Invoice TotalLines", testInvoice.getSummedLineAmount(),
+          closeTo(quantityUpdated.multiply(priceUpdated), BigDecimal.ZERO));
+      // Now we can remove created data
+      OBDal.getInstance().remove(testInvoiceLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testInvoice);
+      if (testInvoice.getInvoiceTaxList().size() > 0) {
+        assertTrue("Document Taxes not properly removed", false);
+      }
+      assertThat("GrandTotal holds an amount when invoice has no lines",
+          testInvoice.getGrandTotalAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      assertThat("TotalLines holds an amount when invoice has no lines",
+          testInvoice.getSummedLineAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      OBDal.getInstance().remove(testInvoice);
+      OBDal.getInstance().flush();
+      log.debug("Invoice Deleted:" + testInvoice.getDocumentNo());
+      // log.info("Test Completed successfully");
+    } catch (Exception e) {
+      log.error("Error when executing testTax_Invoiceline_case1", e);
+      assertFalse(true);
+    }
+  }
+
+  /**
+   * Verifies taxes computation for invoices. Price including taxes: Add a line, update it and
+   * delete it. Review tax computation is correct
+   */
+  @Test
+  public void testTax_Invoiceline_PriceIncludingTaxes() {
+    assumeTrue(this.isPriceIncludingTaxes);
+    // Set QA context
+    OBContext.setOBContext(USER_ID, ROLE_ID, CLIENT_ID, ORGANIZATION_ID);
+    try {
+      Invoice invoice;
+      if (isSalesTest) {
+        invoice = OBDal.getInstance().get(Invoice.class, SALESINVOICE_ID);
+      } else {
+        invoice = OBDal.getInstance().get(Invoice.class, PURCHASEINVOICE_ID);
+      }
+      Invoice testInvoice = (Invoice) DalUtil.copy(invoice, false);
+      testInvoice.setDocumentNo("PriceIncludingTaxes" + testNumber);
+      testInvoice.setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class, bpartnerId));
+      testInvoice.setPriceIncludesTax(true);
+      if (isSalesTest) {
+        testInvoice.setPriceList(OBDal.getInstance().get(PriceList.class,
+            PRICEINCLUDINGTAXES_PRICELIST_SALES));
+      } else {
+        testInvoice.setPriceList(OBDal.getInstance().get(PriceList.class,
+            PRICEINCLUDINGTAXES_PRICELIST_PURCHASE));
+      }
+      testInvoice.setSummedLineAmount(BigDecimal.ZERO);
+      testInvoice.setGrandTotalAmount(BigDecimal.ZERO);
+      testInvoice.setId(SequenceIdData.getUUID());
+      testInvoice.setNewOBObject(true);
+      OBDal.getInstance().save(testInvoice);
+      OBDal.getInstance().flush();
+      log.debug("Invoice Created:" + testInvoice.getDocumentNo());
+      log.debug(testDescription);
+      InvoiceLine invoiceLine = invoice.getInvoiceLineList().get(0);
+      InvoiceLine testInvoiceLine = (InvoiceLine) DalUtil.copy(invoiceLine, false);
+      Product product = OBDal.getInstance().get(Product.class, productId);
+      testInvoiceLine.setProduct(product);
+      testInvoiceLine.setUOM(product.getUOM());
+      testInvoiceLine.setInvoicedQuantity(quantity);
+      testInvoiceLine.setUnitPrice(price);
+      testInvoiceLine.setListPrice(price);
+      testInvoiceLine.setGrossListPrice(price);
+      testInvoiceLine.setGrossUnitPrice(price);
+      testInvoiceLine.setStandardPrice(price);
+      testInvoiceLine.setLineNetAmount(lineNet);
+      testInvoiceLine.setGrossAmount(price.multiply(quantity));
+      testInvoiceLine.setTax(OBDal.getInstance().get(TaxRate.class, taxid));
+      testInvoiceLine.setTaxAmount(price.multiply(quantity).subtract(lineNet));
+      testInvoiceLine.setTaxableAmount(lineNet);
+      if (bpartnerId != null) {
+        testInvoiceLine.setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class,
+            bpartnerId));
+      }
+      testInvoiceLine.setInvoice(testInvoice);
+      testInvoice.getInvoiceLineList().add(testInvoiceLine);
+      testInvoiceLine.setId(SequenceIdData.getUUID());
+      testInvoiceLine.setNewOBObject(true);
+      OBDal.getInstance().save(testInvoiceLine);
+      OBDal.getInstance().save(testInvoice);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testInvoice);
+      OBDal.getInstance().refresh(testInvoiceLine);
+      // Now test taxes for inserted line
+      testTaxes(testInvoice, false);
+      testLineTaxes(testInvoiceLine, false);
+      OBDal.getInstance().getSession().clear();
+      testInvoice = OBDal.getInstance().get(Invoice.class, testInvoice.getId());
+      assertThat("Wrong Invoice GrandTotal", testInvoice.getGrandTotalAmount(),
+          closeTo(quantity.multiply(price), BigDecimal.ZERO));
+      assertThat("Wrong Invoice TotalLines", testInvoice.getSummedLineAmount(),
+          closeTo(lineNet, BigDecimal.ZERO));
+      // Test update of a line
+      testInvoiceLine = OBDal.getInstance().get(InvoiceLine.class, testInvoiceLine.getId());
+      testInvoiceLine.setInvoicedQuantity(quantityUpdated);
+      testInvoiceLine.setLineNetAmount(lineNetUpdated);
+      testInvoiceLine.setTaxableAmount(lineNetUpdated);
+      testInvoiceLine.setTaxAmount(priceUpdated.multiply(quantityUpdated).subtract(lineNetUpdated));
+      testInvoiceLine.setGrossAmount(priceUpdated.multiply(quantityUpdated));
+      OBDal.getInstance().save(testInvoiceLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testInvoice);
+      // Now test taxes for inserted line
+      testTaxes(testInvoice, true);
+      testLineTaxes(testInvoiceLine, true);
+      assertThat("Wrong Invoice GrandTotal", testInvoice.getGrandTotalAmount(),
+          closeTo(quantityUpdated.multiply(priceUpdated), BigDecimal.ZERO));
+      assertThat("Wrong Invoice TotalLines", testInvoice.getSummedLineAmount(),
+          closeTo(lineNetUpdated, BigDecimal.ZERO));
+      // Now we can remove created data
+      OBDal.getInstance().remove(testInvoiceLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testInvoice);
+      if (testInvoice.getInvoiceTaxList().size() > 0) {
+        assertTrue(testDescription + ". Document Taxes not properly removed", false);
+      }
+      assertThat("GrandTotal holds an amount when invoice has no lines",
+          testInvoice.getGrandTotalAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      assertThat("TotalLines holds an amount when invoice has no lines",
+          testInvoice.getSummedLineAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      OBDal.getInstance().remove(testInvoice);
+      OBDal.getInstance().flush();
+      log.debug("Invoice Deleted:" + testInvoice.getDocumentNo());
+      log.debug("Test Completed successfully");
+    } catch (Exception e) {
+      log.error("Error when executing: " + testDescription, e);
+      assertFalse(true);
+    }
+  }
+
+  /**
+   * Verifies taxes computation for orders. Price including taxes: Add a line, update it and delete
+   * it. Review tax computation is correct
+   */
+  @Test
+  public void testTax_Orderline_PriceIncludingTaxes() {
+    assumeTrue(this.isPriceIncludingTaxes);
+    // Set QA context
+    OBContext.setOBContext(USER_ID, ROLE_ID, CLIENT_ID, ORGANIZATION_ID);
+    try {
+      Order order;
+      if (isSalesTest) {
+        order = OBDal.getInstance().get(Order.class, SALESORDER_ID);
+      } else {
+        order = OBDal.getInstance().get(Order.class, PURCHASEORDER_ID);
+      }
+      Order testOrder = (Order) DalUtil.copy(order, false);
+      testOrder.setDocumentNo("PriceIncludingTaxes" + testNumber);
+      testOrder.setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class, bpartnerId));
+      testOrder.setPriceIncludesTax(true);
+      if (isSalesTest) {
+        testOrder.setPriceList(OBDal.getInstance().get(PriceList.class,
+            PRICEINCLUDINGTAXES_PRICELIST_SALES));
+      } else {
+        testOrder.setPriceList(OBDal.getInstance().get(PriceList.class,
+            PRICEINCLUDINGTAXES_PRICELIST_PURCHASE));
+      }
+      testOrder.setSummedLineAmount(BigDecimal.ZERO);
+      testOrder.setGrandTotalAmount(BigDecimal.ZERO);
+      testOrder.setId(SequenceIdData.getUUID());
+      testOrder.setNewOBObject(true);
+      OBDal.getInstance().save(testOrder);
+      OBDal.getInstance().flush();
+      log.debug("Order Created:" + testOrder.getDocumentNo());
+      log.debug(testDescription);
+      OrderLine orderLine = order.getOrderLineList().get(0);
+      OrderLine testOrderLine = (OrderLine) DalUtil.copy(orderLine, false);
+      Product product = OBDal.getInstance().get(Product.class, productId);
+      testOrderLine.setProduct(product);
+      testOrderLine.setUOM(product.getUOM());
+      testOrderLine.setOrderedQuantity(quantity);
+      testOrderLine.setInvoicedQuantity(BigDecimal.ZERO);
+      testOrderLine.setUnitPrice(price);
+      testOrderLine.setListPrice(price);
+      testOrderLine.setGrossListPrice(price);
+      testOrderLine.setGrossUnitPrice(price);
+      testOrderLine.setStandardPrice(price);
+      testOrderLine.setLineNetAmount(lineNet);
+      testOrderLine.setLineGrossAmount(price.multiply(quantity));
+      testOrderLine.setTax(OBDal.getInstance().get(TaxRate.class, taxid));
+      // testOrderLine.setTaxAmount(price.multiply(quantity).subtract(lineNet));
+      testOrderLine.setTaxableAmount(lineNet);
+      if (bpartnerId != null) {
+        testOrderLine
+            .setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class, bpartnerId));
+      }
+      testOrderLine.setSalesOrder(testOrder);
+      testOrder.getOrderLineList().add(testOrderLine);
+      testOrderLine.setId(SequenceIdData.getUUID());
+      testOrderLine.setNewOBObject(true);
+      OBDal.getInstance().save(testOrderLine);
+      OBDal.getInstance().save(testOrder);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testOrder);
+      OBDal.getInstance().refresh(testOrderLine);
+      // Now test taxes for inserted line
+      testTaxes(testOrder, false);
+      testLineTaxes(testOrderLine, false);
+      // Test update of a line
+      OBDal.getInstance().getSession().clear();
+      testOrder = OBDal.getInstance().get(Order.class, testOrder.getId());
+      assertThat("Wrong Order GrandTotal", testOrder.getGrandTotalAmount(),
+          closeTo(quantity.multiply(price), BigDecimal.ZERO));
+      assertThat("Wrong Invoice TotalLines", testOrder.getSummedLineAmount(),
+          closeTo(lineNet, BigDecimal.ZERO));
+      testOrderLine = OBDal.getInstance().get(OrderLine.class, testOrderLine.getId());
+      testOrderLine.setOrderedQuantity(quantityUpdated);
+      testOrderLine.setLineNetAmount(lineNetUpdated);
+      testOrderLine.setTaxableAmount(lineNetUpdated);
+      testOrderLine.setLineGrossAmount(priceUpdated.multiply(quantityUpdated));
+      OBDal.getInstance().save(testOrderLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testOrder);
+      // Now test taxes for inserted line
+      testTaxes(testOrder, true);
+      testLineTaxes(testOrderLine, true);
+      assertThat("Wrong Order GrandTotal", testOrder.getGrandTotalAmount(),
+          closeTo(quantityUpdated.multiply(priceUpdated), BigDecimal.ZERO));
+      assertThat("Wrong Invoice TotalLines", testOrder.getSummedLineAmount(),
+          closeTo(lineNetUpdated, BigDecimal.ZERO));
+      // Now we can remove created data
+      OBDal.getInstance().remove(testOrderLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testOrder);
+      if (testOrder.getOrderTaxList().size() > 0) {
+        assertTrue(testDescription + ". Document Taxes not properly removed", false);
+      }
+      assertThat("GrandTotal holds an amount when order has no lines",
+          testOrder.getGrandTotalAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      assertThat("TotalLines holds an amount when order has no lines",
+          testOrder.getSummedLineAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      OBDal.getInstance().remove(testOrder);
+      OBDal.getInstance().flush();
+      log.debug("Order Deleted:" + testOrder.getDocumentNo());
+      log.debug("Test Completed successfully");
+    } catch (Exception e) {
+      log.error("Error when executing: " + testDescription, e);
+      assertFalse(true);
+    }
+  }
+
+  /**
+   * Verifies taxes computation for orders. Price including taxes: Add a line, update it and delete
+   * it. Review tax computation is correct
+   */
+  @Test
+  public void testTax_Orderline_RegularPriceList() {
+    assumeFalse(this.isPriceIncludingTaxes);
+    // Set QA context
+    OBContext.setOBContext(USER_ID, ROLE_ID, CLIENT_ID, ORGANIZATION_ID);
+    try {
+      Order order;
+      if (isSalesTest) {
+        order = OBDal.getInstance().get(Order.class, SALESORDER_ID);
+      } else {
+        order = OBDal.getInstance().get(Order.class, PURCHASEORDER_ID);
+      }
+      Order testOrder = (Order) DalUtil.copy(order, false);
+      testOrder.setDocumentNo("RegularPriceList " + testNumber);
+      testOrder.setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class, bpartnerId));
+      testOrder.setPriceIncludesTax(false);
+      testOrder.setSummedLineAmount(BigDecimal.ZERO);
+      testOrder.setGrandTotalAmount(BigDecimal.ZERO);
+      testOrder.setId(SequenceIdData.getUUID());
+      testOrder.setNewOBObject(true);
+      OBDal.getInstance().save(testOrder);
+      OBDal.getInstance().flush();
+      log.debug("Order Created:" + testOrder.getDocumentNo());
+      log.debug(testDescription);
+      OrderLine orderLine = order.getOrderLineList().get(0);
+      OrderLine testOrderLine = (OrderLine) DalUtil.copy(orderLine, false);
+      Product product = OBDal.getInstance().get(Product.class, productId);
+      testOrderLine.setProduct(product);
+      testOrderLine.setUOM(product.getUOM());
+      testOrderLine.setOrderedQuantity(quantity);
+      testOrderLine.setInvoicedQuantity(BigDecimal.ZERO);
+      testOrderLine.setUnitPrice(price);
+      testOrderLine.setListPrice(price);
+      testOrderLine.setGrossListPrice(BigDecimal.ZERO);
+      testOrderLine.setGrossUnitPrice(BigDecimal.ZERO);
+      testOrderLine.setStandardPrice(price);
+      testOrderLine.setLineNetAmount(price.multiply(quantity));
+      testOrderLine.setLineGrossAmount(BigDecimal.ZERO);
+      testOrderLine.setTax(OBDal.getInstance().get(TaxRate.class, taxid));
+      testOrderLine.setTaxableAmount(price.multiply(quantity));
+      if (bpartnerId != null) {
+        testOrderLine
+            .setBusinessPartner(OBDal.getInstance().get(BusinessPartner.class, bpartnerId));
+      }
+      testOrderLine.setSalesOrder(testOrder);
+      testOrder.getOrderLineList().add(testOrderLine);
+      testOrderLine.setId(SequenceIdData.getUUID());
+      testOrderLine.setNewOBObject(true);
+      OBDal.getInstance().save(testOrderLine);
+      OBDal.getInstance().save(testOrder);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testOrder);
+      OBDal.getInstance().refresh(testOrderLine);
+      // Now test taxes for inserted line
+      BigDecimal totalTax = testTaxes(testOrder, false);
+      testLineTaxes(testOrderLine, false);
+      // Test update of a line
+      OBDal.getInstance().getSession().clear();
+      testOrder = OBDal.getInstance().get(Order.class, testOrder.getId());
+      // Asserts
+      assertThat("Wrong Order GrandTotal", testOrder.getGrandTotalAmount(),
+          closeTo(quantity.multiply(price).add(totalTax), BigDecimal.ZERO));
+      assertThat("Wrong Order TotalLines", testOrder.getSummedLineAmount(),
+          closeTo(price.multiply(quantity), BigDecimal.ZERO));
+      testOrderLine = OBDal.getInstance().get(OrderLine.class, testOrderLine.getId());
+      testOrderLine.setOrderedQuantity(quantityUpdated);
+      testOrderLine.setLineNetAmount(priceUpdated.multiply(quantityUpdated));
+      testOrderLine.setTaxableAmount(priceUpdated.multiply(quantityUpdated));
+      testOrderLine.setLineGrossAmount(BigDecimal.ZERO);
+      OBDal.getInstance().save(testOrderLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testOrder);
+      // Now test taxes for inserted line
+      totalTax = testTaxes(testOrder, true);
+      testLineTaxes(testOrderLine, true);
+      assertThat("Wrong Order GrandTotal", testOrder.getGrandTotalAmount(),
+          closeTo(quantityUpdated.multiply(priceUpdated).add(totalTax), BigDecimal.ZERO));
+      assertThat("Wrong Order TotalLines", testOrder.getSummedLineAmount(),
+          closeTo(priceUpdated.multiply(quantityUpdated), BigDecimal.ZERO));
+      // Now we can remove created data
+      OBDal.getInstance().remove(testOrderLine);
+      OBDal.getInstance().flush();
+      OBDal.getInstance().refresh(testOrder);
+      if (testOrder.getOrderTaxList().size() > 0) {
+        assertTrue(testDescription + ". Document Taxes not properly removed", false);
+      }
+      assertThat("GrandTotal holds an amount when invoice has no lines",
+          testOrder.getGrandTotalAmount(), closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      assertThat("Wrong Order TotalLines", testOrder.getSummedLineAmount(),
+          closeTo(BigDecimal.ZERO, BigDecimal.ZERO));
+      OBDal.getInstance().remove(testOrder);
+      OBDal.getInstance().flush();
+      log.debug("Order Deleted:" + testOrder.getDocumentNo());
+      log.debug("Test Completed successfully");
+    } catch (Exception e) {
+      log.error("Error when executing: " + testDescription, e);
+      assertFalse(true);
+    }
+  }
+
+  private void testLineTaxes(OrderLine orderLine, boolean isUpdate) {
+    int counter = 0;
+    OBCriteria<OrderLineTax> obc = OBDal.getInstance().createCriteria(OrderLineTax.class);
+    obc.add(Restrictions.eq(OrderLineTax.PROPERTY_SALESORDERLINE, orderLine));
+    for (OrderLineTax linetax : obc.list()) {
+      log.debug(linetax.getTax().getIdentifier());
+      BigDecimal expectedTaxableAmount = new BigDecimal(isUpdate ? linetaxes.get(linetax.getTax()
+          .getId())[2] : linetaxes.get(linetax.getTax().getId())[0]);
+      BigDecimal expectedTaxAmount = new BigDecimal(isUpdate ? linetaxes.get(linetax.getTax()
+          .getId())[3] : linetaxes.get(linetax.getTax().getId())[1]);
+      assertThat("Wrong taxable amount for line in document", linetax.getTaxableAmount(),
+          closeTo(expectedTaxableAmount, BigDecimal.ZERO));
+      assertThat("Wrong tax amount for line in document", linetax.getTaxAmount(),
+          closeTo(expectedTaxAmount, BigDecimal.ZERO));
+      counter++;
+    }
+    if (linetaxes.size() != counter) {
+      assertTrue(testDescription + ". Number of lines obtained(" + linetaxes.size()
+          + ") different than expected (" + counter + ")", false);
+    }
+  }
+
+  private void testLineTaxes(InvoiceLine invoiceLine, boolean isUpdate) {
+    int counter = 0;
+    OBCriteria<InvoiceLineTax> obc = OBDal.getInstance().createCriteria(InvoiceLineTax.class);
+    obc.add(Restrictions.eq(InvoiceLineTax.PROPERTY_INVOICELINE, invoiceLine));
+    for (InvoiceLineTax linetax : obc.list()) {
+      log.debug(linetax.getTax().getIdentifier());
+      log.debug(linetax.getTax().getId());
+      log.debug(linetax.getTaxableAmount().toString());
+      log.debug(linetax.getTaxAmount().toString());
+      BigDecimal expectedTaxableAmount = new BigDecimal(isUpdate ? linetaxes.get(linetax.getTax()
+          .getId())[2] : linetaxes.get(linetax.getTax().getId())[0]);
+      BigDecimal expectedTaxAmount = new BigDecimal(isUpdate ? linetaxes.get(linetax.getTax()
+          .getId())[3] : linetaxes.get(linetax.getTax().getId())[1]);
+      assertThat("Wrong taxable amount for line in document", linetax.getTaxableAmount(),
+          closeTo(expectedTaxableAmount, BigDecimal.ZERO));
+      assertThat("Wrong tax amount for line in document", linetax.getTaxAmount(),
+          closeTo(expectedTaxAmount, BigDecimal.ZERO));
+      counter++;
+    }
+    if (linetaxes.size() != counter) {
+      assertTrue(testDescription + ". Number of lines obtained(" + linetaxes.size()
+          + ") different than expected (" + counter + ")", false);
+    }
+  }
+
+  private BigDecimal testTaxes(Invoice invoice, boolean isUpdate) {
+    int counter = 0;
+    BigDecimal totalTax = BigDecimal.ZERO;
+    OBCriteria<InvoiceTax> obc = OBDal.getInstance().createCriteria(InvoiceTax.class);
+    obc.add(Restrictions.eq(InvoiceTax.PROPERTY_INVOICE, invoice));
+    for (InvoiceTax tax : obc.list()) {
+      log.debug(tax.getTax().getIdentifier());
+      log.debug(tax.getTax().getId());
+      log.debug(tax.getTaxableAmount().toString());
+      log.debug(tax.getTaxAmount().toString());
+
+      if (!doctaxes.containsKey(tax.getTax().getId())) {
+        assertTrue(
+            testDescription + ". Tax Should not be present: " + tax.getTax().getIdentifier(), false);
+      }
+      BigDecimal expectedTaxableAmount = new BigDecimal(isUpdate ? doctaxes.get(tax.getTax()
+          .getId())[2] : doctaxes.get(tax.getTax().getId())[0]);
+      BigDecimal expectedTaxAmount = new BigDecimal(
+          isUpdate ? doctaxes.get(tax.getTax().getId())[3] : doctaxes.get(tax.getTax().getId())[1]);
+      assertThat("Wrong taxable amount for document", tax.getTaxableAmount(),
+          closeTo(expectedTaxableAmount, BigDecimal.ZERO));
+      assertThat("Wrong tax amount for document", tax.getTaxAmount(),
+          closeTo(expectedTaxAmount, BigDecimal.ZERO));
+      totalTax = totalTax.add(expectedTaxAmount);
+      counter++;
+    }
+    if (doctaxes.size() != counter) {
+      assertTrue(testDescription + ". Number of lines obtained(" + doctaxes.size()
+          + ") different than expected (" + counter + ")", false);
+    }
+    return totalTax;
+  }
+
+  private BigDecimal testTaxes(Order testOrder, boolean isUpdate) {
+    int counter = 0;
+    BigDecimal totalTax = BigDecimal.ZERO;
+    OBCriteria<OrderTax> obc = OBDal.getInstance().createCriteria(OrderTax.class);
+    obc.add(Restrictions.eq(OrderTax.PROPERTY_SALESORDER, testOrder));
+    for (OrderTax tax : obc.list()) {
+      log.debug(tax.getTax().getIdentifier());
+      log.debug(tax.getTax().getId());
+      log.debug(tax.getTaxableAmount().toString());
+      log.debug(tax.getTaxAmount().toString());
+      if (!doctaxes.containsKey(tax.getTax().getId())) {
+        assertTrue(
+            testDescription + ". Tax Should not be present: " + tax.getTax().getIdentifier(), false);
+      }
+      BigDecimal expectedTaxableAmount = new BigDecimal(isUpdate ? doctaxes.get(tax.getTax()
+          .getId())[2] : doctaxes.get(tax.getTax().getId())[0]);
+      BigDecimal expectedTaxAmount = new BigDecimal(
+          isUpdate ? doctaxes.get(tax.getTax().getId())[3] : doctaxes.get(tax.getTax().getId())[1]);
+      assertThat("Wrong taxable amount order", tax.getTaxableAmount(),
+          closeTo(expectedTaxableAmount, BigDecimal.ZERO));
+      assertThat("Wrong tax amount for order", tax.getTaxAmount(),
+          closeTo(expectedTaxAmount, BigDecimal.ZERO));
+      totalTax = totalTax.add(expectedTaxAmount);
+      counter++;
+    }
+    if (doctaxes.size() != counter) {
+      assertTrue(testDescription + ". Number of lines obtained(" + doctaxes.size()
+          + ") different than expected (" + counter + ")", false);
+    }
+    return totalTax;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/BPartnerDataConstants.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,27 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+public class BPartnerDataConstants {
+  // Business Partner Id: Vendor A
+  public final static String VENDOR_A = "4028E6C72959682B01295F40BDDF02E3";
+  // Business Partner Id: Customer A
+  public final static String CUSTOMER_A = "4028E6C72959682B01295F40C3CB02EC";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/ProductDataConstants.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,31 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+public class ProductDataConstants {
+  // ProducT Id: Raw material A
+  public final static String RAW_MATERIAL_A = "4028E6C72959682B01295ADC1AD40222";
+  // ProducT Id: Final Good A
+  public final static String FINAL_GOOD_A = "4028E6C72959682B01295ADC1D07022A";
+  // ProducT Id: Distribution Good D (BOM Taxes)
+  public final static String DISTRIBUTION_GOOD_D = "8581A3A503C44FC18727516E12A85575";
+  // ProducT Id: Distribution Good E (BOM Taxes)
+  public final static String DISTRIBUTION_GOOD_E = "144339F3C9CA4B32986754D3BB0B6D7F";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxDataConstants.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,40 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+public class TaxDataConstants {
+
+  // Tax: Exempt
+  public final static String TAX_EXEMPT = "37222B873B6447D7A1FEC837799B222F";
+  // Tax: Exempt 10%
+  public final static String TAX_EXEMPT_10 = "BA7059430C0A43A9B86A21C4EECF3A21";
+  // Tax: VAT 10%
+  public final static String TAX_VAT_10 = "F9D9AF81F4FA459C9CE7A2D9697DF1E4";
+  // Tax: VAT(3)+CHARGE(0.5) - Summary tax
+  public final static String TAX_VAT_CHARGE = "58A7B9D1DDDD442CAD08052C1B735AFC";
+  // Tax: VAT(3) - Child tax
+  public final static String TAX_VAT_3_Child = "667A8194F0264B0AAA997B8B51F72024";
+  // Tax: VAT(3) - Child tax
+  public final static String TAX_VAT_3 = "5A74E390B82747F9A5754C8EB1BDB47A";
+  // Tax: CHARGE(0.5) - Child tax
+  public final static String TAX_CHARGE = "5690F12F2C934F5384FA94F063F63C5F";
+  // Tax: As Per BOM
+  public final static String TAX_AS_PER_BOM = "D85D2465A01C464BA75E053D36FC28EC";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,168 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public abstract class TaxesTestData {
+  private String testNumber;
+  private String testDescription;
+  private String productId;
+  private BigDecimal quantity;
+  private BigDecimal price;
+  private BigDecimal lineNet;
+  private BigDecimal quantityUpdated;
+  private BigDecimal priceUpdated;
+  private BigDecimal lineNetUpdated;
+  private String bpartnerId;
+  private String taxid;
+  private HashMap<String, String[]> linetaxes;
+  private HashMap<String, String[]> doctaxes;
+  private boolean isSalesTest;
+  private boolean isPriceIncludingTaxes;
+
+  public TaxesTestData() {
+    initialize();
+  }
+
+  public String getTestNumber() {
+    return testNumber;
+  }
+
+  public String getTestDescription() {
+    return testDescription;
+  }
+
+  public String getProductId() {
+    return productId;
+  }
+
+  public BigDecimal getQuantity() {
+    return quantity;
+  }
+
+  public BigDecimal getPrice() {
+    return price;
+  }
+
+  public BigDecimal getLineNet() {
+    return lineNet;
+  }
+
+  public BigDecimal getQuantityUpdated() {
+    return quantityUpdated;
+  }
+
+  public BigDecimal getPriceUpdated() {
+    return priceUpdated;
+  }
+
+  public BigDecimal getLineNetUpdated() {
+    return lineNetUpdated;
+  }
+
+  public String getBpartnerId() {
+    return bpartnerId;
+  }
+
+  public String getTaxid() {
+    return taxid;
+  }
+
+  public HashMap<String, String[]> getLinetaxes() {
+    return linetaxes;
+  }
+
+  public HashMap<String, String[]> getDoctaxes() {
+    return doctaxes;
+  }
+
+  public boolean isSalesTest() {
+    return isSalesTest;
+  }
+
+  public boolean isPriceIncludingTaxes() {
+    return isPriceIncludingTaxes;
+  }
+
+  public void setTestNumber(String testNumber) {
+    this.testNumber = testNumber;
+  }
+
+  public void setTestDescription(String testDescription) {
+    this.testDescription = testDescription;
+  }
+
+  public void setProductId(String productId) {
+    this.productId = productId;
+  }
+
+  public void setQuantity(BigDecimal quantity) {
+    this.quantity = quantity;
+  }
+
+  public void setPrice(BigDecimal price) {
+    this.price = price;
+  }
+
+  public void setLineNet(BigDecimal lineNet) {
+    this.lineNet = lineNet;
+  }
+
+  public void setQuantityUpdated(BigDecimal quantityUpdated) {
+    this.quantityUpdated = quantityUpdated;
+  }
+
+  public void setPriceUpdated(BigDecimal priceUpdated) {
+    this.priceUpdated = priceUpdated;
+  }
+
+  public void setLineNetUpdated(BigDecimal lineNetUpdated) {
+    this.lineNetUpdated = lineNetUpdated;
+  }
+
+  public void setBpartnerId(String bpartnerId) {
+    this.bpartnerId = bpartnerId;
+  }
+
+  public void setTaxid(String taxid) {
+    this.taxid = taxid;
+  }
+
+  public void setLinetaxes(HashMap<String, String[]> linetaxes) {
+    this.linetaxes = linetaxes;
+  }
+
+  public void setDoctaxes(HashMap<String, String[]> doctaxes) {
+    this.doctaxes = doctaxes;
+  }
+
+  public void setSalesTest(boolean isSalesTest) {
+    this.isSalesTest = isSalesTest;
+  }
+
+  public void setPriceIncludingTaxes(boolean isPriceIncludingTaxes) {
+    this.isPriceIncludingTaxes = isPriceIncludingTaxes;
+  }
+
+  public abstract void initialize();
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData1.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData1 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("1");
+    setTestDescription("Regular pricelist 1: Purchase Exempt positive");
+    setSalesTest(false);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.VENDOR_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.RAW_MATERIAL_A);
+    setTaxid(TaxDataConstants.TAX_EXEMPT_10);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE);
+    setPrice(new BigDecimal("3"));
+    setLineNet(BigDecimal.ZERO);
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(BigDecimal.ZERO);
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_EXEMPT_10, new String[] { "3", "0", "6", "0" });
+    // Both taxes for linelevel and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData10.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData10 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("10");
+    setTestDescription("Regular pricelist 10: Sales 10% negative");
+    setSalesTest(true);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.CUSTOMER_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.FINAL_GOOD_A);
+    setTaxid(TaxDataConstants.TAX_VAT_10);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE.negate());
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("-3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("-2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("-6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_VAT_10, new String[] { "-3", "-0.3", "-6", "-0.6" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData11.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,60 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData11 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("11");
+    setTestDescription("Regular pricelist 11: Sales 3% + charge positive");
+    setSalesTest(true);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.CUSTOMER_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.FINAL_GOOD_A);
+    setTaxid(TaxDataConstants.TAX_VAT_CHARGE);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE);
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_VAT_3_Child, new String[] { "3", "0.09", "6", "0.18" });
+    lineTaxes.put(TaxDataConstants.TAX_CHARGE, new String[] { "3", "0.02", "6", "0.03" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData12.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,60 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData12 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("12");
+    setTestDescription("Regular pricelist 12: Sales 3% + charge negative");
+    setSalesTest(true);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.CUSTOMER_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.FINAL_GOOD_A);
+    setTaxid(TaxDataConstants.TAX_VAT_CHARGE);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE.negate());
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("-3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2").negate());
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("-6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_VAT_3_Child, new String[] { "-3", "-0.09", "-6", "-0.18" });
+    lineTaxes.put(TaxDataConstants.TAX_CHARGE, new String[] { "-3", "-0.02", "-6", "-0.03" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData13.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,62 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData13 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("13");
+    setTestDescription("Regular pricelist 13: Sales BOM Taxes Positive");
+    setSalesTest(true);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.CUSTOMER_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.DISTRIBUTION_GOOD_D);
+    setTaxid(TaxDataConstants.TAX_AS_PER_BOM);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE);
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_CHARGE, new String[] { "1.87", "0.01", "3.75", "0.02" });
+    lineTaxes
+        .put(TaxDataConstants.TAX_VAT_3_Child, new String[] { "1.87", "0.06", "3.75", "0.11" });
+    lineTaxes.put(TaxDataConstants.TAX_VAT_10, new String[] { "1.13", "0.11", "2.25", "0.23" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData14.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,62 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData14 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("14");
+    setTestDescription("Regular pricelist 13: Sales BOM Taxes Negative");
+    setSalesTest(true);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.CUSTOMER_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.DISTRIBUTION_GOOD_D);
+    setTaxid(TaxDataConstants.TAX_AS_PER_BOM);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE.negate());
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("-3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("-2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("-6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_CHARGE, new String[] { "-1.87", "-0.01", "-3.75", "-0.02" });
+    lineTaxes.put(TaxDataConstants.TAX_VAT_3_Child, new String[] { "-1.87", "-0.06", "-3.75",
+        "-0.11" });
+    lineTaxes.put(TaxDataConstants.TAX_VAT_10, new String[] { "-1.13", "-0.11", "-2.25", "-0.23" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData15.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,60 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData15 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("15");
+    setTestDescription("Regular pricelist 13: Purchase BOM Taxes Positive");
+    setSalesTest(false);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.VENDOR_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.DISTRIBUTION_GOOD_D);
+    setTaxid(TaxDataConstants.TAX_AS_PER_BOM);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE);
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_VAT_3, new String[] { "1.87", "0.06", "3.75", "0.11" });
+    lineTaxes.put(TaxDataConstants.TAX_VAT_10, new String[] { "1.13", "0.11", "2.25", "0.23" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData16.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,60 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData16 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("16");
+    setTestDescription("Regular pricelist 16: Purchase BOM Taxes Negative");
+    setSalesTest(false);
+    setPriceIncludingTaxes(false);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.VENDOR_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.DISTRIBUTION_GOOD_D);
+    setTaxid(TaxDataConstants.TAX_AS_PER_BOM);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE.negate());
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("-3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("-2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("-6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_VAT_3, new String[] { "-1.87", "-0.06", "-3.75", "-0.11" });
+    lineTaxes.put(TaxDataConstants.TAX_VAT_10, new String[] { "-1.13", "-0.11", "-2.25", "-0.23" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData17.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData17 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("17");
+    setTestDescription("Price including taxes 17: Purchase Exempt positive");
+    setSalesTest(false);
+    setPriceIncludingTaxes(true);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.VENDOR_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.RAW_MATERIAL_A);
+    setTaxid(TaxDataConstants.TAX_EXEMPT_10);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE);
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_EXEMPT_10, new String[] { "3", "0", "6", "0" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData18.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData18 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("18");
+    setTestDescription("Price including taxes 18: Purchase Exempt negative");
+    setSalesTest(false);
+    setPriceIncludingTaxes(true);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.VENDOR_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.RAW_MATERIAL_A);
+    setTaxid(TaxDataConstants.TAX_EXEMPT_10);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE.negate());
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("-3"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("-2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("-6"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_EXEMPT_10, new String[] { "-3", "0", "-6", "0" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData19.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.taxes.data;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+
+public class TaxesTestData19 extends TaxesTestData {
+
+  @Override
+  public void initialize() {
+    setTestNumber("19");
+    setTestDescription("Price including taxes 19: Purchase 10% positive");
+    setSalesTest(false);
+    setPriceIncludingTaxes(true);
+    // This info will be set in header
+    setBpartnerId(BPartnerDataConstants.VENDOR_A);
+    // This info will be used in line
+    setProductId(ProductDataConstants.RAW_MATERIAL_A);
+    setTaxid(TaxDataConstants.TAX_VAT_10);
+    // This info is used for inserting the line
+    setQuantity(BigDecimal.ONE);
+    setPrice(new BigDecimal("3"));
+    setLineNet(new BigDecimal("2.73"));
+    // This info is used to update the line
+    setQuantityUpdated(new BigDecimal("2"));
+    setPriceUpdated(new BigDecimal("3"));
+    setLineNetUpdated(new BigDecimal("5.46"));
+
+    // These are the expected results
+    // Each line contains the taxID - {taxableAmtAfterInsert, taxAmtAfterInsert,
+    // taxableAmtAfterUpdate, taxAmtAfterUpdate}
+    // Exempt tax positive amount
+    HashMap<String, String[]> lineTaxes = new HashMap<String, String[]>();
+    lineTaxes.put(TaxDataConstants.TAX_VAT_10, new String[] { "2.73", "0.27", "5.46", "0.54" });
+    // Both taxes for line level and for document level are provided
+    setLinetaxes(lineTaxes);
+    setDoctaxes(lineTaxes);
+
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/taxes/data/TaxesTestData2.java	Mon Jul 27 19:05:39 2015 +0200
@@ -0,0 +1,59 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version