Fixed bug 28482: Exchange rate and Converted Amt in Add Payment
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Wed, 24 Dec 2014 13:29:10 +0100
changeset 24110 578fa0f1f471
parent 24109 243df7e72860
child 24111 67689c9dda24
Fixed bug 28482: Exchange rate and Converted Amt in Add Payment

The Exchange rate and Converted amount fields were not properly updated when 2 financial accounts (the first one of them with different currency than the invoice and the second one with the same currency) are selected sequentially into the Add Payment process.

Casue: the conversion rate was wrongly sent back to the JS as a String ("1") instead of using a number. The OB.APRM.AddPayment.paymentMethodMulticurrency function checks the received conversion rate is a number before updating the converted amount. Since the converted amount wasn't a number but a string, the amounts were not updated.
After the fix, the conversion rate is sent back using a integer 1
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentMethodMulticurrencyActionHandler.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentMethodMulticurrencyActionHandler.java	Mon Dec 22 12:06:48 2014 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentMethodMulticurrencyActionHandler.java	Wed Dec 24 13:29:10 2014 +0100
@@ -67,7 +67,7 @@
       }
       if (finAccPaymentMethod != null) {
         if (finAccPaymentMethod.getAccount().getCurrency().getId().equals(currencyId)) {
-          result.put("conversionrate", "1");
+          result.put("conversionrate", 1);
         } else {
           ConversionRate convRate = FinancialUtils.getConversionRate(paymentDate, OBDal
               .getInstance().get(Currency.class, currencyId), finAccPaymentMethod.getAccount()
@@ -76,14 +76,14 @@
           if (convRate != null) {
             result.put("conversionrate", convRate.getMultipleRateBy());
           } else {
-            result.put("conversionrate", "1");
+            result.put("conversionrate", 1);
           }
         }
         result.put("currencyToId", finAccPaymentMethod.getAccount().getCurrency().getId());
         result.put("currencyToIdentifier", finAccPaymentMethod.getAccount().getCurrency()
             .getIdentifier());
       } else {
-        result.put("conversionrate", "1");
+        result.put("conversionrate", 1);
         result.put("currencyToId", currencyId);
       }
       return result;