Currency Conversion In 4.1.0

I’m probably doing something wrong (it’s been known to happen, heh), but I can’t seem to get currency conversions to work in the new version. I see where there’s the option to manually specify an exchange rate when entering a payment, but I’m not seeing an exchange rate in the quote or invoice page as the screenshot would suggest. And when I select a client who I’ve assigned a different currency (for example, Japanese Yen), selecting a product still shows the same numerical price, only with the Yen symbol in place of the Dollar.

As far as I know, the daily crons are fetching the rates, as they say they’re doing so when I run them manually. Did I miss something somewhere? I even manually copied 4.1.0 over thinking that maybe something got messed up in an update, but no change.

There’s a new setting on /settings/products to auto-convert product prices.

I have that checked.

Do you see the exchange rate in the currencies table?

select code, exchange_rate from currencies where code = 'JPY';

| code | exchange_rate |
| JPY  |      134.8800 |

So it’s in the database, but still not showing on the invoice creation page, or converting at all.

But that value brings up another issue. By default, converts from EUR as a base. So what’s in the database is the rate from Euros, not dollars (which would be around 110, I believe). Shouldn’t the code for getting the exchange rates from use the users primary currency from localization settings as a base?

To show the exchange rate on the invoice you need to add a custom ‘Exchange Rate’ invoice field, it should be automatically set when choosing a product.

Here’s the relevant JavaScript code:

We use this library to handle rate conversions:

Added an Exchange Rate field, but it seems to keep defaulting to 1.0000

I think I may know the problem, try adding ?clear_cache=true to the URL

That seems to have done the trick. Thanks!

Would it be a good idea for me to add that to the autoupdate script?

Great to hear!

I think the problem is the crons don’t have permission to clear the cache, you should be able to fix it by running the crons as the web user or root.

We’ll update the docs…

I have the crons in the root crontab, so it doesn’t seem to be a permission issue (at least from that standpoint).

Can you try changing this line:


CurlUtils::get(SITE_URL . '?clear_cache=true');

Made the change (was still Cache::forget(‘currencies’); in my copy) and noted the exchange rate showing right now. We’ll see what happens tomorrow, I guess.

Thanks for all the help!

So far so good. However, I did notice that the conversion for VND was way off. Currently, the rate is at about 22,560 (give or take), but in Invoice Ninja, it’s showing as 0.8177.

I’m not sure… by default we use which doesn’t provide an exchange rate for VND.