[HGVOL] Merged from PI
authorSandra Huguet <sandra.huguet@openbravo.com>
Wed, 17 Feb 2016 10:37:09 +0100
changeset 28740 633e0ab1bb38
parent 28710 605a0a57aa06 (current diff)
parent 28739 12dcb6800a9c (diff)
child 28741 ac1180b4b8d0
[HGVOL] Merged from PI
lib/runtime/fop.jar
modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RemoveFilesEventHandler.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FileActionHandler.java
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-file.js
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/erase_icon.png
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/form/upload_icon.png
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FileUIDefinition.java
src-db/database/lib/dbsourcemanager.jar
src-db/database/model/tables/AD_FILE.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_TAB.xml
src-db/database/sourcedata/AD_TABLE.xml
src-db/database/sourcedata/AD_WINDOW.xml
src/org/openbravo/erpCommon/info/FileInfoBLOB.java
src/org/openbravo/erpCommon/utility/GetFile.java
--- a/legal/Licensing.txt	Wed Feb 10 08:53:43 2016 +0100
+++ b/legal/Licensing.txt	Wed Feb 17 10:37:09 2016 +0100
@@ -111,7 +111,7 @@
 # commons-lang-2.6.jar
 # commons-logging-1.1.1.jar
 # commons-pool-1.5.6.jar
-# fop.jar
+# fop-1.1.jar
 # jakarta-oro-2.0.8.jar
 # jettison-1.3.jar
 # log4j-1.2.16.jar
Binary file lib/runtime/fop-1.1.jar has changed
Binary file lib/runtime/fop.jar has changed
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -1070,6 +1070,20 @@
       IF (v_count <> 0) THEN
         RAISE_APPLICATION_ERROR(-20000, '@APRM_InvoiceWithPayments@' || ' ' || v_documentno);
       END IF;
+
+      SELECT count(*)
+      INTO v_count
+      FROM DUAL
+      WHERE EXISTS (SELECT 1
+                    FROM C_InvoiceTax_CashVAT itcv
+                    INNER JOIN C_InvoiceTax it on (it.C_InvoiceTax_ID = itcv.C_InvoiceTax_ID)
+                    WHERE it.C_Invoice_ID = p_record_id
+                    AND itcv.IsManualSettlement = 'Y'
+                    );
+      IF (v_count > 0) THEN
+        RAISE_APPLICATION_ERROR(-20000, '@APRM_InvoiceWithManualCashVATSettlement@');
+      END IF;
+
       SELECT count(*), max(p.documentno)
         INTO v_count, v_documentno
       FROM fin_payment_schedule ps, fin_payment_scheduledetail psd, fin_payment_prop_detail pd, fin_payment_proposal p
@@ -1121,6 +1135,20 @@
       UPDATE C_BPARTNER
          SET SO_CREDITUSED = COALESCE(SO_CREDITUSED,0) - v_convertedAmount
       WHERE C_BPARTNER_ID = v_BPartner_ID;
+
+      -- Delete C_InvoiceTax_CashVAT records for this invoice
+      --  this only happens for prepayments, which are bypassed by the previous check
+      DELETE FROM C_InvoiceTax_CashVAT itcv
+      WHERE EXISTS (SELECT 1
+                    FROM C_InvoiceTax it
+                    WHERE it.C_InvoiceTax_ID = itcv.C_InvoiceTax_ID
+                    AND it.C_Invoice_ID = p_record_id
+                    )
+      AND EXISTS (SELECT 1
+                  FROM FIN_Payment_Detail fpd
+                  WHERE fpd.FIN_Payment_Detail_ID = itcv.FIN_Payment_Detail_ID
+                  AND fpd.IsPrepayment = 'Y')
+      AND itcv.IsManualSettlement = 'N';
     END;
 
   ELSIF (p_docaction = 'RC') THEN
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_COLUMN.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -287,8 +287,8 @@
 <!--07DD87B8F3BE41C18546260D616E1404-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--07DD87B8F3BE41C18546260D616E1404-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--07DD87B8F3BE41C18546260D616E1404-->  <SQLLOGIC><![CDATA[(SELECT count(*) FROM fin_bankstatementline bl, fin_bankstatement b, fin_reconciliation r WHERE (bl.fin_finacc_transaction_id IS NULL OR (EXISTS ( SELECT 1 FROM fin_finacc_transaction t, fin_reconciliation rec WHERE t.fin_reconciliation_id  = rec.fin_reconciliation_id AND bl.fin_finacc_transaction_id  = t.fin_finacc_transaction_id  AND t.fin_financial_account_id  = b.fin_financial_account_id  AND rec.created > r.created))) AND bl.datetrx <= r.dateto AND b.fin_bankstatement_id  = bl.fin_bankstatement_id AND b.fin_financial_account_id  = r.fin_financial_account_id and r.fin_reconciliation_id = fin_reconciliation_id)]]></SQLLOGIC>
-<!--07DD87B8F3BE41C18546260D616E1404-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--07DD87B8F3BE41C18546260D616E1404-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--07DD87B8F3BE41C18546260D616E1404-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--07DD87B8F3BE41C18546260D616E1404-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--07DD87B8F3BE41C18546260D616E1404--></AD_COLUMN>
 
 <!--09A1C598D8134CAC92CB30E476A213B0--><AD_COLUMN>
@@ -2272,8 +2272,8 @@
 <!--3FE18B378FA24031A2E24B058414729F-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--3FE18B378FA24031A2E24B058414729F-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--3FE18B378FA24031A2E24B058414729F-->  <SQLLOGIC><![CDATA[(SELECT COALESCE(sum(t.depositamt), 0) FROM fin_finacc_transaction t,  fin_reconciliation rec WHERE (t.fin_reconciliation_id IS NULL OR (EXISTS ( SELECT 1 FROM fin_reconciliation r WHERE r.dateto > rec.dateto AND t.fin_reconciliation_id  = r.fin_reconciliation_id ))) AND t.statementdate <= rec.dateto AND t.depositamt <> 0 AND t.fin_financial_account_id  = rec.fin_financial_account_id AND rec.fin_reconciliation_id = fin_reconciliation_id)]]></SQLLOGIC>
-<!--3FE18B378FA24031A2E24B058414729F-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--3FE18B378FA24031A2E24B058414729F-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--3FE18B378FA24031A2E24B058414729F-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--3FE18B378FA24031A2E24B058414729F-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--3FE18B378FA24031A2E24B058414729F--></AD_COLUMN>
 
 <!--40405759C1E1456E99B537D36A06F987--><AD_COLUMN>
@@ -3090,8 +3090,8 @@
 <!--590088D9DDB34C1FB99E97CF50022B62-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--590088D9DDB34C1FB99E97CF50022B62-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--590088D9DDB34C1FB99E97CF50022B62-->  <SQLLOGIC><![CDATA[( SELECT count(*) FROM fin_finacc_transaction WHERE fin_finacc_transaction.fin_reconciliation_id = fin_reconciliation_id)]]></SQLLOGIC>
-<!--590088D9DDB34C1FB99E97CF50022B62-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--590088D9DDB34C1FB99E97CF50022B62-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--590088D9DDB34C1FB99E97CF50022B62-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--590088D9DDB34C1FB99E97CF50022B62-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--590088D9DDB34C1FB99E97CF50022B62--></AD_COLUMN>
 
 <!--5961F18CC4934FCCA8AB18B2B3AFC960--><AD_COLUMN>
@@ -4208,8 +4208,8 @@
 <!--7791426B8C214F0EB68C13D99A577229-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--7791426B8C214F0EB68C13D99A577229-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--7791426B8C214F0EB68C13D99A577229-->  <SQLLOGIC><![CDATA[(SELECT COALESCE(sum(fin_finacc_transaction.depositamt - fin_finacc_transaction.paymentamt), 0) FROM fin_finacc_transaction WHERE fin_finacc_transaction.fin_reconciliation_id = fin_reconciliation_id)]]></SQLLOGIC>
-<!--7791426B8C214F0EB68C13D99A577229-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--7791426B8C214F0EB68C13D99A577229-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--7791426B8C214F0EB68C13D99A577229-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--7791426B8C214F0EB68C13D99A577229-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--7791426B8C214F0EB68C13D99A577229--></AD_COLUMN>
 
 <!--78A3367822B35459E040007F01012510--><AD_COLUMN>
@@ -4612,8 +4612,8 @@
 <!--81822D492C88480C8830E5059387A771-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--81822D492C88480C8830E5059387A771-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--81822D492C88480C8830E5059387A771-->  <SQLLOGIC><![CDATA[(SELECT count(*) FROM fin_finacc_transaction t,  fin_reconciliation rec WHERE (t.fin_reconciliation_id IS NULL OR (EXISTS ( SELECT 1 FROM fin_reconciliation r WHERE r.dateto > rec.dateto AND t.fin_reconciliation_id  = r.fin_reconciliation_id ))) AND t.statementdate <= rec.dateto AND t.depositamt <> 0 AND t.fin_financial_account_id  = rec.fin_financial_account_id AND rec.fin_reconciliation_id = fin_reconciliation_id) ]]></SQLLOGIC>
-<!--81822D492C88480C8830E5059387A771-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--81822D492C88480C8830E5059387A771-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--81822D492C88480C8830E5059387A771-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--81822D492C88480C8830E5059387A771-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--81822D492C88480C8830E5059387A771--></AD_COLUMN>
 
 <!--82EFB8E4043C19C9E040007F01003778--><AD_COLUMN>
@@ -6792,8 +6792,8 @@
 <!--91BC2133F04647938F702192A5156C25-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--91BC2133F04647938F702192A5156C25-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--91BC2133F04647938F702192A5156C25-->  <SQLLOGIC><![CDATA[(SELECT count(*) FROM fin_finacc_transaction t,  fin_reconciliation rec WHERE (t.fin_reconciliation_id IS NULL OR (EXISTS ( SELECT 1 FROM fin_reconciliation r WHERE r.dateto > rec.dateto AND t.fin_reconciliation_id  = r.fin_reconciliation_id ))) AND t.statementdate <= rec.dateto AND t.paymentamt <> 0 AND t.fin_financial_account_id  = rec.fin_financial_account_id AND rec.fin_reconciliation_id = fin_reconciliation_id) ]]></SQLLOGIC>
-<!--91BC2133F04647938F702192A5156C25-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--91BC2133F04647938F702192A5156C25-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--91BC2133F04647938F702192A5156C25-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--91BC2133F04647938F702192A5156C25-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--91BC2133F04647938F702192A5156C25--></AD_COLUMN>
 
 <!--923F5B228E5F4D2D96C00C206D47BC63--><AD_COLUMN>
@@ -10230,8 +10230,8 @@
 <!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <SQLLOGIC><![CDATA[(SELECT COALESCE(sum(t.paymentamt), 0) FROM fin_finacc_transaction t,  fin_reconciliation rec WHERE (t.fin_reconciliation_id IS NULL OR (EXISTS ( SELECT 1 FROM fin_reconciliation r WHERE r.dateto > rec.dateto AND t.fin_reconciliation_id  = r.fin_reconciliation_id ))) AND t.statementdate <= rec.dateto AND t.paymentamt <> 0 AND t.fin_financial_account_id  = rec.fin_financial_account_id AND rec.fin_reconciliation_id = fin_reconciliation_id)]]></SQLLOGIC>
-<!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--BBE47252ECEF4B5BA7116E0E23CA5D8D-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--BBE47252ECEF4B5BA7116E0E23CA5D8D--></AD_COLUMN>
 
 <!--BC78354AB2F7403FA9725CDF267C0A70--><AD_COLUMN>
@@ -10674,8 +10674,8 @@
 <!--C72EC790B2EF4BEEA2A843D30770B85D-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--C72EC790B2EF4BEEA2A843D30770B85D-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--C72EC790B2EF4BEEA2A843D30770B85D-->  <SQLLOGIC><![CDATA[(SELECT COALESCE(sum(bl.cramount - bl.dramount), 0) FROM fin_bankstatementline bl, fin_bankstatement b, fin_reconciliation r WHERE (bl.fin_finacc_transaction_id IS NULL OR (EXISTS ( SELECT 1 FROM fin_finacc_transaction t, fin_reconciliation rec WHERE t.fin_reconciliation_id  = rec.fin_reconciliation_id AND bl.fin_finacc_transaction_id  = t.fin_finacc_transaction_id  AND t.fin_financial_account_id  = b.fin_financial_account_id  AND rec.created > r.created))) AND bl.datetrx <= r.dateto AND b.fin_bankstatement_id  = bl.fin_bankstatement_id AND b.fin_financial_account_id  = r.fin_financial_account_id and r.fin_reconciliation_id = fin_reconciliation_id)]]></SQLLOGIC>
-<!--C72EC790B2EF4BEEA2A843D30770B85D-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--C72EC790B2EF4BEEA2A843D30770B85D-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--C72EC790B2EF4BEEA2A843D30770B85D-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--C72EC790B2EF4BEEA2A843D30770B85D-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--C72EC790B2EF4BEEA2A843D30770B85D--></AD_COLUMN>
 
 <!--C9FD369BECE545828033CC49CAB85D9D--><AD_COLUMN>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -1309,6 +1309,18 @@
 <!--D0F129E2F69F4D199DAE68813D2327A2-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--D0F129E2F69F4D199DAE68813D2327A2--></AD_MESSAGE>
 
+<!--D1CF6692476E409DBACAC1809BBC1788--><AD_MESSAGE>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <AD_MESSAGE_ID><![CDATA[D1CF6692476E409DBACAC1809BBC1788]]></AD_MESSAGE_ID>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <VALUE><![CDATA[APRM_InvoiceWithManualCashVATSettlement]]></VALUE>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <MSGTEXT><![CDATA[The invoice is already included into a Manual Cash VAT Settlement]]></MSGTEXT>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--D1CF6692476E409DBACAC1809BBC1788-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--D1CF6692476E409DBACAC1809BBC1788--></AD_MESSAGE>
+
 <!--D2585EEAC94945C7B3CF79C209FD7650--><AD_MESSAGE>
 <!--D2585EEAC94945C7B3CF79C209FD7650-->  <AD_MESSAGE_ID><![CDATA[D2585EEAC94945C7B3CF79C209FD7650]]></AD_MESSAGE_ID>
 <!--D2585EEAC94945C7B3CF79C209FD7650-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js	Wed Feb 10 08:53:43 2016 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js	Wed Feb 17 10:37:09 2016 +0100
@@ -41,11 +41,8 @@
     return this.Super('init', arguments);
   },
 
-  // after a change also store the textual value in the form
-  // for precision, the textual value is sent to the server
-  // which can be transferred to a bigdecimal there
   changed: function (form, item, value) {
-    if (item && item.setValue) {
+    if (this.form.className === 'OBViewForm' && item && item.setValue) {
       item.setValue(this.getEnteredValue());
     }
     this.Super('changed', arguments);
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DefaultDataSourceService.java	Wed Feb 10 08:53:43 2016 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DefaultDataSourceService.java	Wed Feb 17 10:37:09 2016 +0100
@@ -11,13 +11,14 @@
  * 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-2015 Openbravo SLU
+ * All portions are Copyright (C) 2010-2016 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
  */
 package org.openbravo.service.datasource;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -252,10 +253,15 @@
       fieldQuery.setNamedParameter("tabId", tab.getId());
       fieldQuery.setNamedParameter("roleId", roleId);
       for (Field f : fieldQuery.list()) {
-        String key = KernelUtils.getProperty(f).getName();
+        Property property = KernelUtils.getProperty(f);
+        String key = property.getName();
         if (data.has(key)) {
           String newValue = getValue(data, key);
           String oldValue = getValue(oldData, key);
+          if (property.isPrimitive() && property.isNumericType()
+              && isSameNumericValue(newValue, oldValue)) {
+            continue;
+          }
           if (oldValue == null && newValue != null || oldValue != null
               && !oldValue.equals(newValue)) {
             throw new RuntimeException(KernelUtils.getInstance().getI18N(
@@ -284,6 +290,17 @@
       return val.toString();
   }
 
+  private static boolean isSameNumericValue(String str1, String str2) {
+    try {
+      BigDecimal bd1 = new BigDecimal(str1);
+      BigDecimal bd2 = new BigDecimal(str2);
+      return bd1.doubleValue() == bd2.doubleValue();
+    } catch (NumberFormatException nfex) {
+      log4j.error("Could not compare numeric values", nfex);
+    }
+    return false;
+  }
+
   public List<DataSourceProperty> getDataSourceProperties(Map<String, Object> parameters) {
     final Entity entity = getEntity();
     final List<DataSourceProperty> dsProperties;
--- a/src-core/.classpath	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-core/.classpath	Wed Feb 17 10:37:09 2016 +0100
@@ -4,7 +4,7 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/commons-dbcp-1.4.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/commons-pool-1.5.6.jar"/>
-	<classpathentry kind="lib" path="/openbravo/lib/runtime/fop.jar"/>
+	<classpathentry kind="lib" path="/openbravo/lib/runtime/fop-1.1.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/renderFoRmi.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/avalon-framework-4.1.5.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/commons-fileupload-1.2.2.jar"/>
Binary file src-db/database/lib/dbsourcemanager.jar has changed
--- a/src-db/database/model/functions/MRP_PURCHASEORDER.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/model/functions/MRP_PURCHASEORDER.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -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-2007 Openbravo SLU
+* All portions are Copyright (C) 2001-2016 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -53,6 +53,15 @@
   v_ProductName NVARCHAR2(90);
   v_IsAPRMinstalled NUMBER;
   v_DefaultPaymentRule VARCHAR2(60):=null;
+  v_PriceListVersion_ID M_PRICELIST_VERSION.M_PRICELIST_VERSION_ID%TYPE;
+  v_istaxincluded CHAR(1);
+  v_LineNetAmt NUMBER:=0;
+  v_gross_unit_price NUMBER:=0;
+  v_stdprecision NUMBER:=0;
+  v_priceprecision NUMBER:=0;
+  v_line_gross_amount NUMBER:=0;
+  v_gross_price_std NUMBER:=0;
+  v_gross_price_list NUMBER:=0;
 
   v_Count NUMBER;
 
@@ -191,14 +200,7 @@
                           AND plv.AD_Client_ID =v_Client_ID));
 
       IF (v_count > 0) THEN
-        SELECT PriceList, PriceStd,
-               M_Get_Offers_Price(v_DateDoc,Cur_workproposal.C_BPartner_ID,Cur_workproposal.M_Product_ID,PriceStd,Cur_workproposal.QTY, Cur_workproposal.PO_PRICELIST_ID),
-               PriceLimit
-          INTO v_PriceList, v_PriceStd, v_PriceActual, v_PriceLimit
-        FROM M_ProductPrice
-        WHERE M_Product_ID = Cur_workproposal.M_Product_ID
-          AND M_PRICELIST_VERSION_ID = (
-                SELECT min(plv.M_PriceList_Version_ID) as M_PriceList_Version_ID
+        SELECT min(plv.M_PriceList_Version_ID) INTO v_PriceListVersion_ID
                 FROM M_PriceList_Version plv
                 WHERE plv.M_PriceList_ID = Cur_workproposal.PO_PRICELIST_ID
                   AND plv.IsActive= 'Y'
@@ -210,7 +212,15 @@
                                     AND plv.IsActive= 'Y'
                                     AND pl.M_PriceList_ID = Cur_workproposal.PO_PRICELIST_ID
                                     AND plv.ValidFrom <= v_DateDoc
-                                    AND plv.AD_Client_ID =v_Client_ID));
+                                    AND plv.AD_Client_ID =v_Client_ID);
+
+        SELECT PriceList, PriceStd,
+               M_Get_Offers_Price(v_DateDoc,Cur_workproposal.C_BPartner_ID,Cur_workproposal.M_Product_ID,PriceStd,Cur_workproposal.QTY, Cur_workproposal.PO_PRICELIST_ID),
+               PriceLimit
+          INTO v_PriceList, v_PriceStd, v_PriceActual, v_PriceLimit
+        FROM M_ProductPrice
+        WHERE M_Product_ID = Cur_workproposal.M_Product_ID
+          AND M_PRICELIST_VERSION_ID = v_PriceListVersion_ID;
       ELSE
         SELECT NAME INTO v_ProductName
         FROM M_PRODUCT
@@ -220,8 +230,33 @@
         RAISE_APPLICATION_ERROR(-20000, v_Message);
       END IF;
 
+      SELECT istaxincluded INTO v_istaxincluded
+          FROM M_PRICELIST
+            WHERE M_PRICELIST_ID = (SELECT M_PRICELIST_ID
+              FROM M_PRICELIST_VERSION
+                WHERE M_PRICELIST_VERSION_ID = v_PriceListVersion_ID);
+
       v_TaxID := C_GetTax(Cur_workproposal.M_Product_ID, v_DateDoc, v_Org_ID, v_M_Warehouse_ID, v_BillTo_ID, v_BPartner_Location_ID, null, 'N');
+      v_LineNetAmt:= v_PriceActual*Cur_workproposal.QTY;
+      IF (v_istaxincluded = 'Y') THEN
+        SELECT PricePrecision, stdprecision
+            INTO v_priceprecision, v_stdprecision
+          FROM C_CURRENCY
+          WHERE C_CURRENCY_ID = Cur_workproposal.C_Currency_ID;
 
+        v_gross_unit_price:= v_PriceActual;
+        v_gross_price_std:= v_PriceStd;
+        v_gross_price_list:= v_PriceList;
+        v_line_gross_amount:= ROUND(v_gross_unit_price * Cur_workproposal.QTY, v_stdprecision);
+        v_PriceActual:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceActual, 0, v_priceprecision, 1);
+        v_PriceStd:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceStd, 0, v_priceprecision, 1);
+        v_PriceList:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceList, 0, v_priceprecision, 1);
+        v_PriceLimit:= C_GET_NET_PRICE_FROM_GROSS(v_TaxID, v_PriceLimit, 0, v_priceprecision, 1);
+        v_LineNetAmt:= ROUND(v_PriceActual * Cur_workproposal.QTY, v_stdprecision);
+
+        UPDATE C_ORDER SET ISTAXINCLUDED='Y' WHERE C_ORDER_ID = v_COrder_ID;
+
+      END IF;
       v_ResultStr:='Insert order line';
 
       INSERT INTO C_OrderLine
@@ -232,7 +267,8 @@
          M_WAREHOUSE_ID, C_UOM_ID, QTYORDERED, C_CURRENCY_ID,
          PRICELIST, PRICEACTUAL, PRICELIMIT,
          PRICESTD, LINENETAMT, DISCOUNT,
-         C_TAX_ID)
+         C_TAX_ID, gross_unit_price, line_gross_amount,
+         grosspricestd, grosspricelist)
      VALUES
       (v_COrderLine_ID,v_Client_ID, v_Org_ID,'Y',
        now(), v_User_ID, now(), v_User_ID,
@@ -240,8 +276,9 @@
        Cur_workproposal.PLANNEDORDERDATE, Cur_workproposal.PLANNEDDATE, v_Description, Cur_workproposal.M_Product_ID,
        v_M_Warehouse_ID, Cur_workproposal.C_UOM_ID, Cur_workproposal.QTY, Cur_workproposal.C_Currency_ID,
        v_PriceList, v_PriceActual, v_PriceLimit,
-       v_PriceStd, v_PriceActual*Cur_workproposal.QTY,CASE v_PriceList WHEN 0 THEN 0 ELSE ROUND((((v_PriceList-v_PriceStd) / v_PriceList) * 100),2) END,
-       v_TaxID
+       v_PriceStd, v_LineNetAmt, CASE v_PriceList WHEN 0 THEN 0 ELSE ROUND((((v_PriceList-v_PriceStd) / v_PriceList) * 100),2) END,
+       v_TaxID, v_gross_unit_price, v_line_gross_amount,
+       v_gross_price_std, v_gross_price_list
       );
 
       UPDATE MRP_RUN_PURCHASELINE
--- a/src-db/database/model/functions/M_RESERVE_STOCK_AUTO.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/model/functions/M_RESERVE_STOCK_AUTO.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -22,7 +22,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-2015 Openbravo SLU
+* All portions are Copyright (C) 2012-2016 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -93,6 +93,7 @@
         JOIN m_locator l ON sd.m_locator_id = l.m_locator_id
         JOIN m_warehouse w ON l.m_warehouse_id = w.m_warehouse_id
     WHERE sp.ad_pinstance_id = v_pinstance_id
+    AND sd.m_product_uom_id IS NULL
     ORDER BY sp.priority
   ) LOOP
     v_qty := LEAST(cur_stock.quantity, v_pendingqty);
--- a/src-db/database/model/functions/M_RESERVE_STOCK_MANUAL.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/model/functions/M_RESERVE_STOCK_MANUAL.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -34,7 +34,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-2015 Openbravo SLU
+* All portions are Copyright (C) 2012-2016 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************/
@@ -125,7 +125,7 @@
 
   IF (v_aux_rs_id IS NOT NULL) THEN
     UPDATE m_reservation_stock
-    SET quantity = quantity + p_qty
+    SET quantity = CASE WHEN (quantity + p_qty) <= 0 THEN 0 ELSE quantity + p_qty END
     WHERE m_reservation_stock_id = v_aux_rs_id;
     p_reservation_stock_id := v_aux_rs_id;
     RETURN;
--- a/src-db/database/model/triggers/M_TRANSACTION_TRG.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/model/triggers/M_TRANSACTION_TRG.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -38,6 +38,7 @@
   v_doIncrease BOOLEAN:= FALSE;
   v_doDecrease BOOLEAN:= FALSE;
   v_stockdiff NUMBER:= 0;
+  v_checkuom NUMBER:= 0;
 BEGIN
     
     IF AD_isTriggerEnabled()='N' THEN RETURN;
@@ -92,7 +93,11 @@
 		IF INSERTING THEN
 			IF(COALESCE(v_UOM_ID, '0') <> COALESCE(:NEW.C_UOM_ID, '0')) THEN
         IF (:new.M_InventoryLine_ID IS NOT NULL) THEN
-	  SELECT line INTO v_DocumentLineNo FROM M_InventoryLine WHERE M_InventoryLine_ID = :new.M_InventoryLine_ID;
+	  SELECT il.line, CASE WHEN i.inventory_type = 'O' OR i.inventory_type = 'C' THEN 1 ELSE 0 END
+	  INTO v_DocumentLineNo, v_checkuom
+	  FROM M_Inventory i JOIN M_InventoryLine il
+	  ON i.m_inventory_id = il.m_inventory_id
+	  WHERE il.m_inventoryline_id = :new.M_InventoryLine_ID;
 	END IF;
 	IF (:new.M_MovementLine_ID IS NOT NULL) THEN
 	  SELECT line INTO v_DocumentLineNo FROM M_MovementLine WHERE M_MovementLine_ID = :new.M_MovementLine_ID;
@@ -106,8 +111,10 @@
 	IF (:new.M_Internal_ConsumptionLine_ID IS NOT NULL) THEN
 	  SELECT line INTO v_DocumentLineNo FROM M_Internal_ConsumptionLine WHERE M_Internal_ConsumptionLine_ID = :new.M_Internal_ConsumptionLine_ID;
 	END IF;
-	  
-	RAISE_APPLICATION_ERROR(-20000, '@DocUOMMismatch@' || ' ' || COALESCE(v_DocumentLineNo, 0));
+
+	IF (v_checkuom = 0) THEN
+	  RAISE_APPLICATION_ERROR(-20000, '@DocUOMMismatch@' || ' ' || COALESCE(v_DocumentLineNo, 0));
+	END IF;
      	END IF;
       IF(v_attributeset_id IS NOT NULL AND (v_AttrSetValueType IS NULL OR v_AttrSetValueType <> 'F') AND v_IsOneAtSetValReq = 'Y' AND COALESCE(:NEW.M_ATTRIBUTESETINSTANCE_ID, '0') = '0') THEN
        	RAISE_APPLICATION_ERROR(-20000, '@20112@' || ' - ' || v_Name) ;
--- a/src-db/database/model/views/C_INVOICETAX_CASHVAT_V.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/model/views/C_INVOICETAX_CASHVAT_V.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
   <database name="VIEW C_INVOICETAX_CASHVAT_V">
-    <view name="C_INVOICETAX_CASHVAT_V"><![CDATA[SELECT itcv.c_invoicetax_cashvat_id AS c_invoicetax_cashvat_v_id, itcv.ad_client_id, itcv.ad_org_id, itcv.created, itcv.createdby, itcv.updated, itcv.updatedby, itcv.isactive, fp.paymentdate, itcv.percentage, itcv.taxamt, itcv.taxbaseamt, fpsd.iscanceled, fp.fin_payment_id, fpd.fin_payment_detail_id, fp.isreceipt, fp.c_bpartner_id, fp.fin_paymentmethod_id, fp.status, fp.amount, fp.c_currency_id, itcv.c_invoicetax_id, itcv.ismanualsettlement FROM c_invoicetax_cashvat itcv LEFT JOIN fin_payment_detail fpd ON fpd.fin_payment_detail_id = itcv.fin_payment_detail_id LEFT JOIN fin_payment fp ON fp.fin_payment_id = fpd.fin_payment_id LEFT JOIN fin_payment_scheduledetail fpsd ON fpd.fin_payment_detail_id = fpsd.fin_payment_detail_id]]></view>
+    <view name="C_INVOICETAX_CASHVAT_V"><![CDATA[SELECT itcv.c_invoicetax_cashvat_id AS c_invoicetax_cashvat_v_id, itcv.ad_client_id, itcv.ad_org_id, itcv.created, itcv.createdby, itcv.updated, itcv.updatedby, itcv.isactive, fp.paymentdate, itcv.percentage, itcv.taxamt, itcv.taxbaseamt, fpsd.iscanceled, fp.fin_payment_id, fpd.fin_payment_detail_id, fp.isreceipt, fp.c_bpartner_id, fp.fin_paymentmethod_id, fp.status, fp.amount, fp.c_currency_id, itcv.c_invoicetax_id, itcv.ismanualsettlement FROM c_invoicetax_cashvat itcv JOIN c_invoicetax it ON it.c_invoicetax_id = itcv.c_invoicetax_id JOIN fin_payment_detail fpd ON fpd.fin_payment_detail_id = itcv.fin_payment_detail_id JOIN fin_payment fp ON fp.fin_payment_id = fpd.fin_payment_id JOIN fin_payment_scheduledetail fpsd ON fpd.fin_payment_detail_id = fpsd.fin_payment_detail_id JOIN fin_payment_schedule fpsi ON fpsi.fin_payment_schedule_id = fpsd.fin_payment_schedule_invoice WHERE itcv.ismanualsettlement = 'N' AND fpsi.c_invoice_id = it.c_invoice_id UNION ALL SELECT itcv.c_invoicetax_cashvat_id AS c_invoicetax_cashvat_v_id, itcv.ad_client_id, itcv.ad_org_id, itcv.created, itcv.createdby, itcv.updated, itcv.updatedby, itcv.isactive, NULL AS paymentdate, itcv.percentage, itcv.taxamt, itcv.taxbaseamt, 'N' AS iscanceled, NULL AS fin_payment_id, NULL AS fin_payment_detail_id, NULL AS isreceipt, NULL AS c_bpartner_id, NULL AS fin_paymentmethod_id, NULL AS status, NULL AS amount, NULL AS c_currency_id, itcv.c_invoicetax_id, itcv.ismanualsettlement FROM c_invoicetax_cashvat itcv WHERE itcv.ismanualsettlement = 'Y']]></view>
   </database>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -238428,8 +238428,8 @@
 <!--062D7EC34B074DC4BF2BB6A1E973D171-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--062D7EC34B074DC4BF2BB6A1E973D171-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--062D7EC34B074DC4BF2BB6A1E973D171-->  <SQLLOGIC><![CDATA[(select ps.duedate from FIN_Payment_ScheduleDetail psd, FIN_Payment_Schedule ps where ps.FIN_Payment_Schedule_ID = coalesce(psd.fin_payment_schedule_invoice, psd.fin_payment_schedule_order) and psd.FIN_Payment_ScheduleDetail_ID = fin_payment_scheduledetail_id)]]></SQLLOGIC>
-<!--062D7EC34B074DC4BF2BB6A1E973D171-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--062D7EC34B074DC4BF2BB6A1E973D171-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--062D7EC34B074DC4BF2BB6A1E973D171-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--062D7EC34B074DC4BF2BB6A1E973D171-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--062D7EC34B074DC4BF2BB6A1E973D171--></AD_COLUMN>
 
 <!--0665AD61112844B18C999D519EDB12A0--><AD_COLUMN>
@@ -239727,8 +239727,8 @@
 <!--0C6CC9768B5144EBB4827B9B98976816-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--0C6CC9768B5144EBB4827B9B98976816-->  <SQLLOGIC><![CDATA[(select ff.writeofflimit  from fin_financial_account ff where ff.fin_financial_account_id=fin_financial_account_id)
 ]]></SQLLOGIC>
-<!--0C6CC9768B5144EBB4827B9B98976816-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--0C6CC9768B5144EBB4827B9B98976816-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--0C6CC9768B5144EBB4827B9B98976816-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--0C6CC9768B5144EBB4827B9B98976816-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--0C6CC9768B5144EBB4827B9B98976816--></AD_COLUMN>
 
 <!--0C9CABC3B4CE4F5993D1A08CF5EEF302--><AD_COLUMN>
@@ -241639,8 +241639,8 @@
 <!--13A5B506645546CA8054A88CFD263DF0-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--13A5B506645546CA8054A88CFD263DF0-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--13A5B506645546CA8054A88CFD263DF0-->  <SQLLOGIC><![CDATA[SELECT coalesce(sum(psd.doubtfuldebt_amount),0) FROM fin_payment_scheduledetail psd left join fin_payment_detail pd on psd.fin_payment_detail_id = pd.fin_payment_detail_id left join fin_payment p on pd.fin_payment_id = p.fin_payment_id WHERE psd.fin_payment_schedule_invoice = fin_payment_schedule_id and psd.isinvoicepaid = 'N']]></SQLLOGIC>
-<!--13A5B506645546CA8054A88CFD263DF0-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--13A5B506645546CA8054A88CFD263DF0-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--13A5B506645546CA8054A88CFD263DF0-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--13A5B506645546CA8054A88CFD263DF0-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--13A5B506645546CA8054A88CFD263DF0--></AD_COLUMN>
 
 <!--13AB438B6900462FB3B92343175BFDD2--><AD_COLUMN>
@@ -242469,8 +242469,8 @@
 <!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <SQLLOGIC><![CDATA[(SELECT count(distinct pd.fin_payment_id) FROM fin_payment_detail pd, fin_payment_scheduledetail psd, fin_payment_schedule ps WHERE pd.fin_payment_detail_id = psd.fin_payment_detail_id AND psd.fin_payment_schedule_invoice = ps.fin_payment_schedule_id AND ps.c_invoice_id IS NOT NULL  AND ps.fin_payment_schedule_id = fin_payment_schedule_id)]]></SQLLOGIC>
-<!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--16AF14EF22134D3FB1D700EA0EE3D16C-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--16AF14EF22134D3FB1D700EA0EE3D16C--></AD_COLUMN>
 
 <!--16C389B66EE04CE7B2A6A15CC7739A76--><AD_COLUMN>
@@ -249630,8 +249630,8 @@
 <!--2D56F14A0C524D8F95282389F1A45878-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--2D56F14A0C524D8F95282389F1A45878-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--2D56F14A0C524D8F95282389F1A45878-->  <SQLLOGIC><![CDATA[SELECT coalesce(sum(psd.doubtfuldebt_amount),0) FROM fin_payment_scheduledetail psd left join fin_payment_detail pd on psd.fin_payment_detail_id = pd.fin_payment_detail_id left join fin_payment p on pd.fin_payment_id = p.fin_payment_id WHERE psd.fin_payment_schedule_invoice = fin_payment_schedule_id and psd.isinvoicepaid = 'N']]></SQLLOGIC>
-<!--2D56F14A0C524D8F95282389F1A45878-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--2D56F14A0C524D8F95282389F1A45878-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--2D56F14A0C524D8F95282389F1A45878-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--2D56F14A0C524D8F95282389F1A45878-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--2D56F14A0C524D8F95282389F1A45878--></AD_COLUMN>
 
 <!--2D64DA0BA824432DB229752F8B22A487--><AD_COLUMN>
@@ -293251,6 +293251,7 @@
 <!--7891269C8418655DE040007F010155CE-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--7891269C8418655DE040007F010155CE-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
 <!--7891269C8418655DE040007F010155CE-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--7891269C8418655DE040007F010155CE-->  <READONLYLOGIC><![CDATA[@Processed@='Y']]></READONLYLOGIC>
 <!--7891269C8418655DE040007F010155CE-->  <ISIDENTIFIER><![CDATA[Y]]></ISIDENTIFIER>
 <!--7891269C8418655DE040007F010155CE-->  <SEQNO><![CDATA[110]]></SEQNO>
 <!--7891269C8418655DE040007F010155CE-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
@@ -306815,6 +306816,7 @@
 <!--828EE0AE801C5FA1E040007F010067C7-->  <ISPARENT><![CDATA[N]]></ISPARENT>
 <!--828EE0AE801C5FA1E040007F010067C7-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
 <!--828EE0AE801C5FA1E040007F010067C7-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--828EE0AE801C5FA1E040007F010067C7-->  <READONLYLOGIC><![CDATA[@Processed@='Y']]></READONLYLOGIC>
 <!--828EE0AE801C5FA1E040007F010067C7-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
 <!--828EE0AE801C5FA1E040007F010067C7-->  <SEQNO><![CDATA[260]]></SEQNO>
 <!--828EE0AE801C5FA1E040007F010067C7-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
@@ -308073,8 +308075,8 @@
 <!--831F84E0E0904C22B9E00AD729DDECAE-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--831F84E0E0904C22B9E00AD729DDECAE-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--831F84E0E0904C22B9E00AD729DDECAE-->  <SQLLOGIC><![CDATA[(select coalesce(c_invoice.grandtotal, c_order.grandtotal) from FIN_Payment_ScheduleDetail psd, FIN_Payment_Schedule ps left join c_invoice on c_invoice.c_invoice_id = ps.c_invoice_id left join c_order on c_order.c_order_id = ps.c_order_id where ps.FIN_Payment_Schedule_ID = coalesce(psd.fin_payment_schedule_invoice, psd.fin_payment_schedule_order) and psd.FIN_Payment_ScheduleDetail_ID = fin_payment_scheduledetail_id)]]></SQLLOGIC>
-<!--831F84E0E0904C22B9E00AD729DDECAE-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--831F84E0E0904C22B9E00AD729DDECAE-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--831F84E0E0904C22B9E00AD729DDECAE-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--831F84E0E0904C22B9E00AD729DDECAE-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--831F84E0E0904C22B9E00AD729DDECAE--></AD_COLUMN>
 
 <!--833CD522133546A994DFE6AECC8B1F77--><AD_COLUMN>
@@ -309251,8 +309253,8 @@
 <!--8638D66DE4474084BC8F44BEEF3C9F22-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--8638D66DE4474084BC8F44BEEF3C9F22-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--8638D66DE4474084BC8F44BEEF3C9F22-->  <SQLLOGIC><![CDATA[(select ps.amount from FIN_Payment_ScheduleDetail psd, FIN_Payment_Schedule ps where ps.FIN_Payment_Schedule_ID = coalesce(psd.fin_payment_schedule_invoice, psd.fin_payment_schedule_order) and psd.FIN_Payment_ScheduleDetail_ID = fin_payment_scheduledetail_id)]]></SQLLOGIC>
-<!--8638D66DE4474084BC8F44BEEF3C9F22-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--8638D66DE4474084BC8F44BEEF3C9F22-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--8638D66DE4474084BC8F44BEEF3C9F22-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--8638D66DE4474084BC8F44BEEF3C9F22-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--8638D66DE4474084BC8F44BEEF3C9F22--></AD_COLUMN>
 
 <!--86486D2A475A452DB3A739D1FA2F5F4E--><AD_COLUMN>
@@ -312927,8 +312929,8 @@
 <!--87EA9943323E40E38DBCF9863880E8E1-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--87EA9943323E40E38DBCF9863880E8E1-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--87EA9943323E40E38DBCF9863880E8E1-->  <SQLLOGIC><![CDATA[SELECT sum(tc.cost) FROM m_transaction_cost tc WHERE tc.m_transaction_id = m_transaction_id]]></SQLLOGIC>
-<!--87EA9943323E40E38DBCF9863880E8E1-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--87EA9943323E40E38DBCF9863880E8E1-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--87EA9943323E40E38DBCF9863880E8E1-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--87EA9943323E40E38DBCF9863880E8E1-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--87EA9943323E40E38DBCF9863880E8E1--></AD_COLUMN>
 
 <!--87EABF329C5211DD9C0C001D09C4A2FE--><AD_COLUMN>
@@ -322227,8 +322229,8 @@
 <!--9AFE960A44A147ECAADB875D96399AA2-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--9AFE960A44A147ECAADB875D96399AA2-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--9AFE960A44A147ECAADB875D96399AA2-->  <SQLLOGIC><![CDATA[(select C_GETINVOICESTATUSFROMSHIPMENT(m_inout_id) from dual)]]></SQLLOGIC>
-<!--9AFE960A44A147ECAADB875D96399AA2-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--9AFE960A44A147ECAADB875D96399AA2-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--9AFE960A44A147ECAADB875D96399AA2-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--9AFE960A44A147ECAADB875D96399AA2-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--9AFE960A44A147ECAADB875D96399AA2--></AD_COLUMN>
 
 <!--9B52F391EFDF42798A630FE55E6AC709--><AD_COLUMN>
@@ -324237,8 +324239,8 @@
 round(coalesce(sum(abs(ol.qtydelivered)), 0)/sum(abs(ol.qtyordered)) * 100, 0)  end 
  from c_orderline ol where ol.c_order_id=c_order_id and ol.c_order_discount_id is null
  ),0))]]></SQLLOGIC>
-<!--9E82E728716246B393C40D2CDCA0133A-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--9E82E728716246B393C40D2CDCA0133A-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--9E82E728716246B393C40D2CDCA0133A-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--9E82E728716246B393C40D2CDCA0133A-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--9E82E728716246B393C40D2CDCA0133A--></AD_COLUMN>
 
 <!--9E96300C46ED4928E040007F01006BD5--><AD_COLUMN>
@@ -324507,8 +324509,8 @@
  when sum(fps.amount) = 0 then 0
  else round(sum(fps.paidamt)/sum(fps.amount) * 100, 0) end
 from FIN_Payment_Schedule fps where fps.c_order_id=c_order_id),0))]]></SQLLOGIC>
-<!--9F1044EB393B4D60895532DB5D568BEE-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--9F1044EB393B4D60895532DB5D568BEE-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--9F1044EB393B4D60895532DB5D568BEE-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--9F1044EB393B4D60895532DB5D568BEE-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--9F1044EB393B4D60895532DB5D568BEE--></AD_COLUMN>
 
 <!--9F3ADE0CE0734BE2BD059AAEFCF1D51C--><AD_COLUMN>
@@ -326289,8 +326291,8 @@
 <!--A3D348CF2D9346D4BEDF3952226927B5-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--A3D348CF2D9346D4BEDF3952226927B5-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--A3D348CF2D9346D4BEDF3952226927B5-->  <SQLLOGIC><![CDATA[SELECT sum(tc.cost) FROM m_transaction_cost tc WHERE tc.m_transaction_id = m_transaction_id and tc.isunitcost = 'Y']]></SQLLOGIC>
-<!--A3D348CF2D9346D4BEDF3952226927B5-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--A3D348CF2D9346D4BEDF3952226927B5-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--A3D348CF2D9346D4BEDF3952226927B5-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--A3D348CF2D9346D4BEDF3952226927B5-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--A3D348CF2D9346D4BEDF3952226927B5--></AD_COLUMN>
 
 <!--A3E2CADB797A491688CC2FB0DBED5F78--><AD_COLUMN>
@@ -329942,8 +329944,8 @@
 <!--AECA45F025F14E6DBA669E12DDA55D17-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--AECA45F025F14E6DBA669E12DDA55D17-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--AECA45F025F14E6DBA669E12DDA55D17-->  <SQLLOGIC><![CDATA[SELECT max(p.paymentdate) FROM fin_payment p, fin_payment_detail pd, fin_payment_scheduledetail psd, fin_payment_schedule ps WHERE p.fin_payment_id = pd.fin_payment_id AND   pd.fin_payment_detail_id = psd.fin_payment_detail_id AND   psd.fin_payment_schedule_invoice = ps.fin_payment_schedule_id AND   ps.c_invoice_id IS NOT NULL AND   ps.fin_payment_schedule_id = fin_payment_schedule_id]]></SQLLOGIC>
-<!--AECA45F025F14E6DBA669E12DDA55D17-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--AECA45F025F14E6DBA669E12DDA55D17-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--AECA45F025F14E6DBA669E12DDA55D17-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--AECA45F025F14E6DBA669E12DDA55D17-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--AECA45F025F14E6DBA669E12DDA55D17--></AD_COLUMN>
 
 <!--AF03184D0C395E0CE040A8C091661ED6--><AD_COLUMN>
@@ -334903,8 +334905,8 @@
 <!--B5B203AE8D674B8DABC6669419815CA7-->  <SQLLOGIC><![CDATA[(coalesce((select case when sum(abs(ol.qtyordered)) = 0 then 0 else 
 round(coalesce(sum(abs(ol.qtyinvoiced)), 0)/sum(abs(ol.qtyordered)) * 100, 0)  end 
 from c_orderline ol   where ol.c_order_id=c_order_id and  ol.c_order_discount_id is null), 0))]]></SQLLOGIC>
-<!--B5B203AE8D674B8DABC6669419815CA7-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--B5B203AE8D674B8DABC6669419815CA7-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--B5B203AE8D674B8DABC6669419815CA7-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--B5B203AE8D674B8DABC6669419815CA7-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--B5B203AE8D674B8DABC6669419815CA7--></AD_COLUMN>
 
 <!--B5B4E54AEAC82679E040007F01004CAA--><AD_COLUMN>
@@ -362930,8 +362932,8 @@
 <!--F02817A43E904DF394E07DE81E98C767-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--F02817A43E904DF394E07DE81E98C767-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--F02817A43E904DF394E07DE81E98C767-->  <SQLLOGIC><![CDATA[(SELECT CASE WHEN to_number(trunc((case when max(ps.outstandingamt) = 0 then max(p.paymentdate) else now() end)) -trunc(min(ps.expecteddate))) > 0 THEN to_number(trunc((case when max(ps.outstandingamt) = 0 then max(p.paymentdate) else now() end)) -trunc(min(ps.expecteddate)))ELSE 0 END AS "case" FROM fin_payment_schedule ps LEFT JOIN fin_payment_scheduledetail psd ON ps.fin_payment_schedule_id =  psd.fin_payment_schedule_invoice LEFT JOIN fin_payment_detail pd ON pd.fin_payment_detail_id = psd.fin_payment_detail_id LEFT JOIN fin_payment p ON p.fin_payment_id = pd.fin_payment_id WHERE ps.fin_payment_schedule_id = fin_payment_schedule_id)]]></SQLLOGIC>
-<!--F02817A43E904DF394E07DE81E98C767-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
-<!--F02817A43E904DF394E07DE81E98C767-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--F02817A43E904DF394E07DE81E98C767-->  <ALLOWSORTING><![CDATA[N]]></ALLOWSORTING>
+<!--F02817A43E904DF394E07DE81E98C767-->  <ALLOWFILTERING><![CDATA[N]]></ALLOWFILTERING>
 <!--F02817A43E904DF394E07DE81E98C767--></AD_COLUMN>
 
 <!--F038FDD2AAEC47AAA752573384DF5DCB--><AD_COLUMN>
--- a/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -72,17 +72,6 @@
 <!--800114-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--800114--></AD_TEXTINTERFACES>
 
-<!--800116--><AD_TEXTINTERFACES>
-<!--800116-->  <AD_TEXTINTERFACES_ID><![CDATA[800116]]></AD_TEXTINTERFACES_ID>
-<!--800116-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--800116-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--800116-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--800116-->  <TEXT><![CDATA[New address entrance]]></TEXT>
-<!--800116-->  <FILENAME><![CDATA[/org/openbravo/erpCommon/info/Location_F1.html]]></FILENAME>
-<!--800116-->  <ISUSED><![CDATA[Y]]></ISUSED>
-<!--800116-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--800116--></AD_TEXTINTERFACES>
-
 <!--800117--><AD_TEXTINTERFACES>
 <!--800117-->  <AD_TEXTINTERFACES_ID><![CDATA[800117]]></AD_TEXTINTERFACES_ID>
 <!--800117-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_VAL_RULE.xml	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-db/database/sourcedata/AD_VAL_RULE.xml	Wed Feb 17 10:37:09 2016 +0100
@@ -1719,7 +1719,7 @@
 <!--71188F0005494DA08311B4FFB2C5A993-->  <NAME><![CDATA[AD_Org child orgs any table]]></NAME>
 <!--71188F0005494DA08311B4FFB2C5A993-->  <DESCRIPTION><![CDATA[Filters the rows to show only those in that belong to child organizations of the organization of the record.]]></DESCRIPTION>
 <!--71188F0005494DA08311B4FFB2C5A993-->  <TYPE><![CDATA[S]]></TYPE>
-<!--71188F0005494DA08311B4FFB2C5A993-->  <CODE><![CDATA[AD_ISORGINCLUDED(@AD_ORG_ID@, ad_org_id, ad_client_id)<>-1]]></CODE>
+<!--71188F0005494DA08311B4FFB2C5A993-->  <CODE><![CDATA[AD_ISORGINCLUDED(ad_org_id, @AD_ORG_ID@, ad_client_id)<>-1]]></CODE>
 <!--71188F0005494DA08311B4FFB2C5A993-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--71188F0005494DA08311B4FFB2C5A993--></AD_VAL_RULE>
 
--- a/src-test/src/org/openbravo/test/costing/TestCosting.java	Wed Feb 10 08:53:43 2016 +0100
+++ b/src-test/src/org/openbravo/test/costing/TestCosting.java	Wed Feb 17 10:37:09 2016 +0100
@@ -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-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2014-2016 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -13094,11 +13094,17 @@
           rate = BigDecimal.ONE;
         }
 
-        else if ((document.getEntityName().equals(ShipmentInOut.ENTITY_NAME) || document
-            .getEntityName().equals(CostAdjustment.ENTITY_NAME))
+        else if ((document.getEntityName().equals(ShipmentInOut.ENTITY_NAME)
+            || document.getEntityName().equals(CostAdjustment.ENTITY_NAME) || (document
+            .getEntityName().equals(ReceiptInvoiceMatch.ENTITY_NAME) && (line.getEntityName()
+            .equals(ShipmentInOutLine.ENTITY_NAME) || (line.getEntityName().equals(
+            InvoiceLine.ENTITY_NAME) && ((InvoiceLine) line).getInvoice().getCurrency()
+            .equals(CURRENCY2_ID)))))
             && OBDal.getInstance().get(Organization.class, ORGANIZATION_ID).getCurrency() != null
             && OBDal.getInstance().get(Organization.class, ORGANIZATION_ID).getCurrency().getId()
-                .equals(CURRENCY2_ID)) {
+                .equals(CURRENCY2_ID)
+            && !accountingFact.getCurrency().getId()
+                .equals(accountingFact.getAccountingSchema().getCurrency().getId())) {
           Calendar calendar = Calendar.getInstance();
           calendar.set(9999, 0, 1);
           OBCriteria<ConversionRate> criteria = OBDal.getInstance().createCriteria(
@@ -13113,6 +13119,15 @@
           rate = criteria.list().get(0).getMultipleRateBy();
         }
 
+        else if (document.getEntityName().equals(ReceiptInvoiceMatch.ENTITY_NAME)
+            && line.getEntityName().equals(InvoiceLine.ENTITY_NAME)
+            && !((InvoiceLine) line).getInvoice().getCurrencyConversionRateDocList().isEmpty()
+            && BigDecimal.ZERO.compareTo(((InvoiceLine) line).getInvoice()
+                .getCurrencyConversionRateDocList().get(0).getRate()) != 0) {
+          rate = BigDecimal.ONE.divide(((InvoiceLine) line).getInvoice()
+              .getCurrencyConversionRateDocList().get(0).getRate());
+        }
+
         assertEquals(
             accountingFact.getForeignCurrencyDebit().setScale(2, BigDecimal.ROUND_HALF_UP),
             documentPostAssert
@@ -13243,6 +13258,9 @@
         if ((productId != null && productId.equals(LANDEDCOSTTYPE3_ID))
             || (document.getEntityName().equals(Invoice.ENTITY_NAME) && ((Invoice) document)
                 .getCurrency().getId().equals(CURRENCY2_ID))
+            || (document.getEntityName().equals(ReceiptInvoiceMatch.ENTITY_NAME)
+                && line.getEntityName().equals(InvoiceLine.ENTITY_NAME) && ((InvoiceLine) line)
+                .getInvoice().getCurrency().getId().equals(CURRENCY2_ID))
             || (document.getEntityName().equals(LandedCost.ENTITY_NAME) && ((LCReceiptLineAmt) line)
                 .getLandedCostCost()
                 .getLandedCostType()
@@ -13253,10 +13271,12 @@
                 && ((LCMatched) line).getInvoiceLine().getProduct() != null && ((LCMatched) line)
                 .getInvoiceLine().getProduct().getId().equals(LANDEDCOSTTYPE3_ID))
             || (!document.getEntityName().equals(Invoice.ENTITY_NAME)
-                && !document.getEntityName().equals(ReceiptInvoiceMatch.ENTITY_NAME)
-                && OBDal.getInstance().get(Organization.class, ORGANIZATION_ID).getCurrency() != null && OBDal
-                .getInstance().get(Organization.class, ORGANIZATION_ID).getCurrency().getId()
-                .equals(CURRENCY2_ID))) {
+                && !(document.getEntityName().equals(ReceiptInvoiceMatch.ENTITY_NAME) && line
+                    .getEntityName().equals(InvoiceLine.ENTITY_NAME))
+                && OBDal.getInstance().get(Organization.class, ORGANIZATION_ID).getCurrency() != null
+                && OBDal.getInstance().get(Organization.class, ORGANIZATION_ID).getCurrency()
+                    .getId().equals(CURRENCY2_ID) && !accountingFact.getCurrency().getId()
+                .equals(accountingFact.getAccountingSchema().getCurrency().getId()))) {
           assertEquals(accountingFact.getCurrency(),
               OBDal.getInstance().get(Currency.class, CURRENCY2_ID));
         } else {
--- a/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java	Wed Feb 10 08:53:43 2016 +0100
+++ b/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java	Wed Feb 17 10:37:09 2016 +0100
@@ -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-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -32,12 +32,13 @@
   private static final String returnToVendorTabId = "5A5CCFC8359B4D79BA705DC487FE8173";
 
   private static final String rtv_unitPriceLeftClause = "(case when (select e.salesOrderLine.salesOrder.priceList.priceIncludesTax from ProcurementPOInvoiceMatch as e where e.goodsShipmentLine = iol) = true then  coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), (select e.salesOrderLine.grossUnitPrice from ProcurementPOInvoiceMatch as e where e.goodsShipmentLine = iol)) else   coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), (select e.salesOrderLine.unitPrice from ProcurementPOInvoiceMatch as e where e.goodsShipmentLine = iol)) end)";
-  private static final String rtv_orderNoLeftClause = " coalesce ((select e.salesOrderLine.salesOrder.documentNo from ProcurementPOInvoiceMatch as e where e.goodsShipmentLine = iol), '0')";
-  private static final String rfc_unitPriceLeftClause = "(case when (iol.salesOrderLine.salesOrder.priceList.priceIncludesTax) = true then  coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), (iol.salesOrderLine.grossUnitPrice)) else   coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), (coalesce(iol.salesOrderLine.unitPrice,''))) end)";
-  private static final String rfc_orderNoLeftClause = " (select e.salesOrderLine.salesOrder.documentNo from MaterialMgmtShipmentInOutLine as e where e.id = iol)";
+  private static final String rtv_orderNoLeftClause = " coalesce ((select e.salesOrderLine.salesOrder.documentNo from ProcurementPOInvoiceMatch as e where e.goodsShipmentLine = iol), '')";
+  private static final String rfc_unitPriceLeftClause = "(case when (iol.salesOrderLine.salesOrder.priceList.priceIncludesTax) = true then  coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), (iol.salesOrderLine.grossUnitPrice)) else   coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), (coalesce(iol.salesOrderLine.unitPrice,0))) end)";
+  private static final String rfc_orderNoLeftClause = " coalesce((select e.salesOrderLine.salesOrder.documentNo from MaterialMgmtShipmentInOutLine as e where e.id = iol), '')";
   private static final String returnedLeftClause = " coalesce((select ol.orderedQuantity from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol),0)";
   private static final String returnedOthersLeftClause = " coalesce((select sum(ol.orderedQuantity) from OrderLine as ol left join ol.salesOrder as o where ol.goodsShipmentLine = iol and o.processed = true and o.documentStatus <> 'VO'), 0)";
   private static final String returnReasonLeftClause = " coalesce((select ol.returnReason.id from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), '')";
+  private static final String returnReasonLeftClause2 = " coalesce((select ol.returnReason.name from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), '')";
   private static final String returnReasonCountQuery = " select count(distinct e.name) from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId  and ol.goodsShipmentLine is not null) ";
   private static final String returnReasonDataQuery = " select distinct e, e.name from ReturnReason as e where exists (select distinct ol.returnReason from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine is not null) ";
   private static final String unitPriceProperty = "unitPrice";
@@ -118,6 +119,8 @@
     } else {
       transformedHqlQuery = transformedHqlQuery.replace("@returnReasonLeftClause@.id",
           returnReasonLeftClause);
+      transformedHqlQuery = transformedHqlQuery.replace("@returnReasonLeftClause@.name",
+          returnReasonLeftClause2);
     }
     return transformedHqlQuery;
   }
@@ -148,6 +151,8 @@
     } else {
       transformedHqlQuery = transformedHqlQuery.replace("@returnReasonLeftClause@.id",
           returnReasonLeftClause);
+      transformedHqlQuery = transformedHqlQuery.replace("@returnReasonLeftClause@.name",
+          returnReasonLeftClause2);
     }
     return transformedHqlQuery;
   }
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Wed Feb 10 08:53:43 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Wed Feb 17 10:37:09 2016 +0100
@@ -11,7 +11,7 @@
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
  * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
  * Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2015 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -2954,8 +2954,7 @@
   public HashMap<String, BigDecimal> getPaymentDetailWriteOffAndAmount(
       List<FIN_PaymentDetail> paymentDetails, FIN_PaymentSchedule ps, FIN_PaymentSchedule psi,
       FIN_PaymentSchedule pso, int currentPaymentDetailIndex, final FieldProvider fieldProvider) {
-    FIN_PaymentDetail paymentDetail = OBDal.getInstance().get(FIN_PaymentDetail.class,
-        paymentDetails.get(currentPaymentDetailIndex));
+    FIN_PaymentDetail paymentDetail = paymentDetails.get(currentPaymentDetailIndex);
     String paymentDetailNextId = null;
     String paymentDetailPreviousId = null;
     if (currentPaymentDetailIndex < paymentDetails.size() - 1) {
--- a/src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java	Wed Feb 10 08:53:43 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java	Wed Feb 17 10:37:09 2016 +0100
@@ -11,7 +11,7 @@
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
  * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
  * Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2014 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -313,7 +313,17 @@
     String strInvoiceCurrency = invoiceData[0].cCurrencyId;
     String strIsSOTrx = invoiceData[0].issotrx;
     String strRecordId = invoiceData[0].cInvoiceId;
-    String strReceiptDate = data[0].getField("ORDERDATEACCT");
+    String strReceiptDate = data[0].getField("orderAcctDate");
+    int invoiceCurrencyPrecission = 2;
+    try {
+      OBContext.setAdminMode();
+      invoiceCurrencyPrecission = OBDal.getInstance().get(Currency.class, strInvoiceCurrency)
+          .getStandardPrecision().intValue();
+    } catch (Exception ignore) {
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+
     BigDecimal bdExpenses = new BigDecimal(strExpenses).multiply(
         new BigDecimal(data[0].getField("QTY"))).divide(
         new BigDecimal(data[0].getField("QTYINVOICED")));
@@ -330,9 +340,6 @@
     docLine.m_C_Campaign_ID = data[0].getField("INOUTCAMPAING");
     docLine.m_C_Activity_ID = data[0].getField("INOUTACTIVITY");
     docLine.m_C_Costcenter_ID = data[0].getField("INOUTCOSCENTER");
-    // Calculate Difference amount in schema currency
-    bdCost = new BigDecimal(getConvertedAmt(bdCost.toString(), costCurrency.getId(),
-        as.m_C_Currency_ID, strReceiptDate, "", vars.getClient(), vars.getOrg(), conn));
 
     if (ZERO.compareTo(bdCost) == 0) {
       strMessage = "@MatchedInvIsZero@";
@@ -343,32 +350,22 @@
       DocLine_Material line = (DocLine_Material) p_inOutlines[i];
       BigDecimal lineAmount = bdCost.multiply(new BigDecimal(line.m_qty)).divide(
           new BigDecimal(data[0].getField("MOVEMENTQTY")),
-          OBDal.getInstance().get(Currency.class, as.m_C_Currency_ID).getStandardPrecision()
-              .intValue(), BigDecimal.ROUND_HALF_UP);
+          costCurrency.getStandardPrecision().intValue(), BigDecimal.ROUND_HALF_UP);
       if (i == p_inOutlines.length - 1) {
         lineAmount = bdCost.subtract(totalInOutLines);
       }
       dr = fact.createLine(line, getAccount(AcctServer.ACCTTYPE_NotInvoicedReceipts, as, conn),
-          as.m_C_Currency_ID, lineAmount.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo),
-          DocumentType, conn);
+          costCurrency.getId(), lineAmount.toString(), "0", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+          DocumentType, strReceiptDate, conn);
       totalInOutLines = totalInOutLines.add(lineAmount);
     }
 
-    bdExpenses = convertAmount(bdExpenses, strIsSOTrx.equalsIgnoreCase("Y") ? true : false,
-        DateAcct, TABLEID_Invoice, strRecordId, strInvoiceCurrency, as.m_C_Currency_ID, docLine,
-        as, fact, Fact_Acct_Group_ID, SeqNo, conn, false);
-
-    BigDecimal bdExpensesAcctCurrency = new BigDecimal(
-        getConvertedAmt(bdExpenses.toString(), strInvoiceCurrency, as.m_C_Currency_ID, DateAcct,
-            "", vars.getClient(), vars.getOrg(), conn));
-
-    BigDecimal bdDifference = bdExpensesAcctCurrency.subtract(bdCost);
-
     if (dr == null) {
       log4j.warn("createFact - unable to calculate line with "
           + " cost of the product to not invoiced receipt account.");
       return null;
     }
+
     ProductInfo p = new ProductInfo(data[0].getField("M_Product_Id"), conn);
     BigDecimal totalLines = BigDecimal.ZERO;
     for (int i = 0; i < p_lines.length; i++) {
@@ -376,16 +373,14 @@
       BigDecimal lineAmount = BigDecimal.ZERO;
       BigDecimal linenetamt = new BigDecimal(invoiceData[0].linenetamt);
       if (!(linenetamt.compareTo(BigDecimal.ZERO) == 0)) {
-        lineAmount = bdExpensesAcctCurrency.multiply(new BigDecimal(line.getAmount())).divide(
-            linenetamt,
-            OBDal.getInstance().get(Currency.class, strInvoiceCurrency).getStandardPrecision()
-                .intValue(), BigDecimal.ROUND_HALF_UP);
+        lineAmount = bdExpenses.multiply(new BigDecimal(line.getAmount())).divide(linenetamt,
+            invoiceCurrencyPrecission, BigDecimal.ROUND_HALF_UP);
         if (i == p_lines.length - 1) {
-          lineAmount = bdExpensesAcctCurrency.subtract(totalLines);
+          lineAmount = bdExpenses.subtract(totalLines);
         }
         cr = fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Expense, as, conn),
-            as.m_C_Currency_ID, "0", lineAmount.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo),
-            DocumentType, conn);
+            strInvoiceCurrency, "0", lineAmount.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+            DocumentType, DateAcct, conn);
         totalLines = totalLines.add(lineAmount);
       }
     }
@@ -404,6 +399,17 @@
     }
     updateProductInfo(as.getC_AcctSchema_ID(), conn, con); // only API
 
+    bdExpenses = convertAmount(bdExpenses, strIsSOTrx.equalsIgnoreCase("Y") ? true : false,
+        DateAcct, TABLEID_Invoice, strRecordId, strInvoiceCurrency, as.m_C_Currency_ID, docLine,
+        as, fact, Fact_Acct_Group_ID, SeqNo, conn, false);
+
+    BigDecimal bdExpensesAcctCurrency = new BigDecimal(
+        getConvertedAmt(bdExpenses.toString(), strInvoiceCurrency, as.m_C_Currency_ID, DateAcct,
+            "", vars.getClient(), vars.getOrg(), conn));
+    // Calculate Difference amount in schema currency
+    bdCost = new BigDecimal(getConvertedAmt(bdCost.toString(), costCurrency.getId(),
+        as.m_C_Currency_ID, strReceiptDate, "", vars.getClient(), vars.getOrg(), conn));
+    BigDecimal bdDifference = bdExpensesAcctCurrency.subtract(bdCost);
     if (bdDifference.signum() != 0) {
       BigDecimal totalDiffLines = BigDecimal.ZERO;
       for (int i = 0; i < p_inOutlines.length; i++) {
--- a/src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java	Wed Feb 10 08:53:43 2016 +0100
+++ b/src/org/openbravo/erpCommon/businessUtility/PriceAdjustment.java	Wed Feb 17 10:37:09 2016 +0100
@@ -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-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2014-2016 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -147,7 +147,8 @@
     String hql = "as p ";
     hql += "where active = true ";
     hql += "and client = :client ";
-    hql += "and (endingDate is null or endingDate>:date) ";
+    hql += "and (endingDate is null or trunc(endingDate) + 1 > :date) ";
+    hql += "and trunc(startingDate)<=:date ";
     hql += "and p.discountType.id = '5D4BAF6BB86D4D2C9ED3D5A6FC051579' ";
     hql += "and (minQuantity is null or minQuantity <= :qty) ";
     hql += "and (maxQuantity is null or maxQuantity >= :qty) ";
--- a/src/org/openbravo/erpCommon/info/Location_F1.html	Wed Feb 10 08:53:43 2016 +0100
+++ b/src/org/openbravo/erpCommon/info/Location_F1.html	Wed Feb 17 10:37:09 2016 +0100
@@ -19,7 +19,7 @@
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>New address entrance</title>
+<title>Location selector</title>
 <link rel="shortcut icon" href="../../../../../web/images/favicon.ico" type="image/x-icon" />
 
 <link rel="stylesheet" type="text/css" href="../../../../../web/skins/Default/Openbravo_ERP_250.css" id="paramCSS"></link>