Git Product home page Git Product logo

google_currency's Introduction

ARCHIVED

Google's Finance Converter is no more. This exists only for historical purposes. Please see below for alternatives.

Google Currency

Build Status

This gem extends Money::Bank::VariableExchange with Money::Bank::GoogleCurrency and gives you access to the current Google Currency exchange rates.

Warning

This gem relies on Google's Finance Converter, which is getting deprecated without a known replacement. The network failures you might be getting are most likely the result of the deprecation. Use at your own risk!

Here's a list of alternative currency converters that you might wanna use instead โ€” https://github.com/RubyMoney/money#implementations.

Usage

require 'money'
require 'money/bank/google_currency'

# (optional)
# set the seconds after than the current rates are automatically expired
# by default, they never expire
Money::Bank::GoogleCurrency.ttl_in_seconds = 86400

# set default bank to instance of GoogleCurrency
Money.default_bank = Money::Bank::GoogleCurrency.new

# create a new money object, and use the standard #exchange_to method
money = Money.new(1_00, "USD") # amount is in cents
money.exchange_to(:EUR)

# or install and use the 'monetize' gem
require 'monetize'
money = 1.to_money(:USD)
money.exchange_to(:EUR)

An UnknownRate will be thrown if #exchange_to is called with a Currency that Money knows, but Google does not.

An UnknownCurrency will be thrown if #exchange_to is called with a Currency that Money does not know.

A GoogleCurrencyCaptchaError will be thrown if the Google Finance Converter API page responds with a Captcha instead of a rate (#52).

A GoogleCurrencyFetchError will be thrown if there is an unknown issue with the Google Finance Converter API.

Caveats

This gem uses Google Finance Converter under the hood.

Exchange rates are,

  1. Based on 1 unit of the original currency.
  2. Have a precision of 4 decimal places.

What this means is that if the JPY to USD exchange rate is 0.0083660, Google will report the JPY to USD exchange rate as 0.0084. As a result, a larger JPY to USD conversion such as 10000 JPY to USD would yield 84 USD instead of 83.66 USD.

Consequently, this means that small exchange rates will be imprecise. For example, if the IDR to USD exchange rate were 0.00007761, Google will report it as 0.0001. This means 100000 IDR would exchange to 10 USD instead of 7.76 USD.

To accommodate for this, the reverse rate will be obtained if the rate is small (below 0.1) and the reciprocal of this reverse rate is used.

Copyright

Copyright (c) 2011 Shane Emmons. See LICENSE for details.

google_currency's People

Contributors

alexwayfer avatar andersonbrandon avatar antstorm avatar ashchan avatar basex avatar bf4 avatar calvincorreli avatar cianmce avatar cover avatar ct-clearhaus avatar danschultzer avatar dball avatar dblock avatar jlecour avatar pavolzbell avatar phallstrom avatar richhollis avatar semmons99 avatar smennesson avatar sowenjub avatar spk avatar tarang avatar thinkandrun avatar wootenblatz avatar yinquanteo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google_currency's Issues

undefined method `to_money' for 1:Fixnum

Hi from the README.md file. I tried to run the whole usage code and it gives me this error.

1.001.00test.rb:22:in <main>': undefined methodto_money' for 1:Fixnum (NoMethodError)

Incorrect rates for IDR and (other currencies with complex_rate)

I get an incorrect exchange rate when converting IDR to USD

require 'money/bank/google_currency'
Money::Bank::GoogleCurrency.new.get_rate(:IDR, :USD).to_s
# => "0.93215105E1"

Literal response from http://www.google.com/ig/calculator?hl=en&q=1IDR%3D%3FUSD
{lhs: "1 Indonesian rupiah",rhs: "9.3 \x26#215; 10\x3csup\x3e-5\x3c/sup\x3e U.S. dollars",error: "",icc: true}

The correct rate should be 9.3 x 10e-5.

I see the same problem with other currencies that return complex rates (e.g. VND)

ArgumentError: invalid byte sequence in Big5

What does this error mean?

pry(main)> o.total
=> #<Money fractional:5250 currency:USD>

pry(main)> o.total.exchange_to(:EUR)
ArgumentError: invalid byte sequence in Big5

pry(main)> o.total.exchange_to('EUR')
ArgumentError: invalid byte sequence in Big5

Bitcoin not working with exchange_to

Bitcoin (BTC) is not exchanged properly:

money = Money.new(1, "BTC")
money.exchange_to('USD')

This should be something about $400 but I get $0 as result. Other exchanges like USD to EUR are working.

@rounding_method for #exchange_with

What does everyone think about moving @rounding_method from VariableExchange to Base so that it can be used in all Money::Bank implementations?

Update money dependency to 5.0.0?

Hi, I would like to use this gem in my rails application, but I need the latest money-rails gem which requires money 5.0.0 and this gem depends on money 4 Is it possible to update the money dependency for this gem to version 5.0.0?

Money::Bank::GoogleCurrencyFetchError

We are getting an error today
Money::Bank::GoogleCurrencyFetchError (Money::Bank::GoogleCurrencyFetchError)
Not sure if it's something you can fix! But I'd appreciate any feedback.

Money::Bank::GoogleCurrencyFetchError: Money::Bank::GoogleCurrencyFetchError
        from /.../google_currency-3.2.0/lib/money/bank/google_currency.rb:160:in `extract_rate'
        from /.../google_currency-3.2.0/lib/money/bank/google_currency.rb:129:in `fetch_rate'
        from /.../google_currency-3.2.0/lib/money/bank/google_currency.rb:99:in `block in get_rate'
        from /.../google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `synchronize'
        from /.../google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `get_rate'
        from /.../money-6.5.1/lib/money/bank/variable_exchange.rb:92:in `exchange_with'
        from /.../money-6.5.1/lib/money/money.rb:412:in `exchange_to'```

Problem using GoogleCurrency with the Chilean Peso

We had a customer from Chile order a product today and our system charged them upwards of $4700 USD for something that should have been $47.28. We get some of our pricing from a third party and they said that this item should have cost 29555.0 CLP.

Google's finance site converts that amount of CLP to 47.2880 USD so this doesn't seem to be something wrong on their end. https://www.google.com/finance/converter?a=29555.0&from=CLP&to=USD

Every time I get pricing from this third party I always put it into "cents" because that is how the Money gem operates. In this case I guess these would be Chilean Centavos (according to wikipedia anyway). When I run that number through the gem it converts to $4,728.80 USD instead of $47.28 USD.

Here is some rails console output showing this in action for CLP currency:
2.1.3 :047 > p.selling_price
=> 2955500
2.1.3 :048 > p.currency
=> "CLP"
2.1.3 :049 > p.selling_price / 100.0
=> 29555.0
2.1.3 :050 > foreign_price = Money.new(p.selling_price, p.currency)
=> #
2.1.3 :051 > exchanged_price = foreign_price.exchange_to(:USD)
=> #
2.1.3 :052 > foreign_price.to_f
=> 2955500.0
2.1.3 :053 > exchanged_price.to_f
=> 4728.8

Here is the same logic but with Mexican Pesos instead:
2.1.3 :055 > p.selling_price
=> 74353
2.1.3 :056 > p.currency
=> "MXN"
2.1.3 :057 > p.selling_price / 100.0
=> 743.53
2.1.3 :058 > foreign_price = Money.new(p.selling_price, p.currency)
=> #
2.1.3 :059 > exchanged_price = foreign_price.exchange_to(:USD)
=> #
2.1.3 :060 > foreign_price.to_f
=> 743.53
2.1.3 :061 > exchanged_price.to_f
=> 48.47

Am I doing something wrong or is this a bug? The results make it look like the original CLP price is already in centavos, but Google's Finance site indicates otherwise.

IDR: ArgumentError: invalid byte sequence in UTF-8

require 'money'
require 'money/bank/google_currency'
require 'json'
MultiJson.engine = :json_gem
Money.default_bank = Money::Bank::GoogleCurrency.new
n = 1.to_money(:USD)
n.exchange_to(:IDR)
ArgumentError: invalid byte sequence in UTF-8
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:140:in `match'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:140:in `match'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:140:in `complex_rate?'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:126:in `decode_rate'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:85:in `fetch_rate'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:64:in `block in get_rate'
    from <internal:prelude>:10:in `synchronize'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/google_currency-2.2.0/lib/money/bank/google_currency.rb:63:in `get_rate'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/money-5.1.1/lib/money/bank/variable_exchange.rb:90:in `exchange_with'
    from /Users/dblock/.rvm/gems/ruby-1.9.3-p385/gems/money-5.1.1/lib/money/money.rb:427:in `exchange_to'
    from (irb):20
    from /Users/dblock/.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'

Having hard time reproducing this in a spec ...

Release new version to Rubygems

Hi there,

Would it be possible to release a new version to Rubygems including the Money 6.6 support?

Thanks and happy holidays! ๐ŸŽ„

Google Currency changes CLP settings for the Money gem

If I load the Money Gem version 6.6.1:
Money.new(5000,'CLP').amount.to_f => 5000.0

When I load also the Google Currency Gem version
Money.new(5000,'CLP').amount.to_f => 50.0

The bug was introduced in the commit 6e36370

The changes to the CLP due to Google issues, should only apply inside the google_currency gem.

Issue while converting from Indonesian currency to British Pound

I tried using google currency converter its giving me error while converting currency from Indonesian rupee(IDR) to British pound(GBP).

subunit_to_unit = Money.new(1, "GBP").currency.subunit_to_unit
=> 100
Money.new(0*subunit_to_unit, 'IDR').exchange_to("GBP")
*** Money::Bank::UnknownRate Exception: Money::Bank::UnknownRate

Thanks for help

Zambia currency exchange rate

I'm having trouble with converting to Zambias ZMW/ZMK.
Apparently Google Finance supports both, but only has the change rates available for the new ZMW.
So ZMW should be recognised instead of ZMK.
Thanks in advance!

Google discontinued their currency converter page

This Gem no longer works as Google discontinued their currency converter page
They just redirect to a search for finance

$ curl "http://finance.google.com/finance/converter?a=1&from=USD&to=EUR"
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com/search?q=finance">here</A>.
</BODY></HTML>

Money::Bank::GoogleCurrencyFetchError and NoMethodError: undefined method `to_money' for 1:Fixnum

I just try to run example code from readme

In Gemfile:

gem "google_currency", '3.2.0'
gem "money", "6.5.0"
gem 'monetize'

This code work fine in production for several years. Now i have issue.

>> require 'money'
=> []
>> require 'money/bank/google_currency'
=> []
>> 
?> # (optional)
?> # set the seconds after than the current rates are automatically expired
?> # by default, they never expire
?> Money::Bank::GoogleCurrency.ttl_in_seconds = 86400
=> 86400
>> 
?> # set default bank to instance of GoogleCurrency
?> Money.default_bank = Money::Bank::GoogleCurrency.new
=> #<Money::Bank::GoogleCurrency:0x000000037ae9e8 @rounding_method=nil, @rates={}, @mutex=#<Mutex:0x000000037ae880>>
>> 
?> # create a new money object, and use the standard #exchange_to method
?> money = Money.new(1_00, "USD") # amount is in cents
=> #<Money fractional:100 currency:USD>
>> money.exchange_to(:EUR)
Money::Bank::GoogleCurrencyFetchError: Money::Bank::GoogleCurrencyFetchError
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:160:in `extract_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:129:in `fetch_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:99:in `block in get_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `synchronize'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `get_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/money-6.5.0/lib/money/bank/variable_exchange.rb:92:in `exchange_with'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/money-6.5.0/lib/money/money.rb:454:in `exchange_to'
	from (irb):34
	from /home/mpz/.rvm/rubies/ruby-2.1.10/bin/irb:11:in `<main>'
>> 
?> # or install and use the 'monetize' gem
?> require 'monetize'
=> []
>> money = 1.to_money(:USD)
NoMethodError: undefined method `to_money' for 1:Fixnum
	from (irb):38
	from /home/mpz/.rvm/rubies/ruby-2.1.10/bin/irb:11:in `<main>'
>> money.exchange_to(:EUR)
Money::Bank::GoogleCurrencyFetchError: Money::Bank::GoogleCurrencyFetchError
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:160:in `extract_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:129:in `fetch_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:99:in `block in get_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `synchronize'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `get_rate'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/money-6.5.0/lib/money/bank/variable_exchange.rb:92:in `exchange_with'
	from /home/mpz/.rvm/gems/ruby-2.1.10/gems/money-6.5.0/lib/money/money.rb:454:in `exchange_to'
	from (irb):39
	from /home/mpz/.rvm/rubies/ruby-2.1.10/bin/irb:11:in `<main>'

Occasional `OpenURI::HTTPError: 404 Not Found` starting ~3/9/2018

Has anyone else been getting occasional OpenURI::HTTPError: 404 Not Found errors when trying to fetch rates?

open-uri.rb" line 363 in open_http
open-uri.rb" line 741 in buffer_open
open-uri.rb" line 212 in block in open_loop
open-uri.rb" line 210 in catch
open-uri.rb" line 210 in open_loop
open-uri.rb" line 151 in open_uri
open-uri.rb" line 721 in open
open-uri.rb" line 729 in read
gems/google_currency-3.4.0/lib/money/bank/google_currency.rb" line 133 in fetch_rate

Ruby: 2.4.3
Example URL that it tries to hit: http://finance.google.com/finance/converter?a=1&from=USD&to=EUR

I can't seem to deterministically reproduce this... has anyone else been running into this recently?

incorrect conversion of IDR to USD

The gem gives an incorrect conversion rate from IDR to USD. The USD to IDR rate is correct.

irb> Money.new(10000000, :IDR).exchange_to(:USD)
=>

irb> Money.new(1000, :USD).exchange_to(:IDR)
=>

The wrong result isn't really the gem's fault.
Google's web service is rounding it's result to 4 decimal places, which isn't enough precision for a currency like IDR (where the exchange rate is currently around 12950:1).

$ GET 'http://www.google.com/finance/converter?a=1&from=IDR&to=USD'

1 IDR = 0.0001 USD

The resulting behaviour is nasty because apps that use such conversion silently get an incorrect exchange rate.

Options for a fix:

  1. ask Google to increase the precision of their service
    and/or
  2. when Google returns an exchange rate of 0.0001, the gem could lookup the reverse rate and then swap the numerator and denominator
    or
  3. when Google returns an exchange rate of 0.0001, the gem could ignore it. Better that clients get no rate than an incorrect one.

Money::Bank::GoogleCurrencyFetchError

I use this gem in one of my projects and it was working perfectly until sometime earlier this week when it started throwing a Money::Bank::GoogleCurrencyFetchError exception anytime I called the exchange_to method.

Did something change?

Money dependency to 5.1.0

~> 5.0.0 locks us on 5.0. This also conflicts with money-rails which require ~> 5.1.1.

I can send a PR if necessary.

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Google endpoint returning a Captcha form

I started getting an error on a page that is using the Money::Bank::GoogleCurrency class. A page that has been working for many months suddenley started throwing a Money::Bank::GoogleCurrencyFetchError.

When I tested locally it all worked OK.

After a closer look and calling the raw endpoint through ruby and examining the returned HTML it isn't including the currency rate form, but a capatcha form.

So I guess Google have possibly made some changes or some auto detection has triggered. The page itself is very low usage and uses a high TTL on the bank.

Just thought I'd share my findings in case you guys weren't aware or it helps others. I guess I will need to investigate other money currency exchanges.

Maybe we could update the README to reflect this? I'm happy to submit a PR if you wish. Let me know.

Thanks!

Invalid rubygems version specified in .gemspec.

I think that if google_currency is intended to work with the money gem, it should require the same version of rubygems. In one server we have rubygems version 1.3.6 and we are not able to install google_currency gem.

https://github.com/RubyMoney/google_currency/blob/master/google_currency.gemspec
s.required_rubygems_version = ">= 1.3.7"

https://github.com/RubyMoney/money/blob/master/money.gemspec
s.required_rubygems_version = ">= 1.3.6"

The same problem happened for the money gem: https://github.com/RubyMoney/money/issuesearch?state=closed&q=1.3.6#issue/26 and it was resolved.

Money dependency ~> 6.0.0

Hi there,

I noticed that the last version of google_currency has a dependency with money gem ~> 6.0.0. However, I am using another of your gem "money-rails" which has a runtime dependency to money ~> 5.1.0. Therefore I couldn't find a solution to use these three gems at the same time.
Are you going to fix this sooner?

Thank you!

JSON requirement

Hi,

I'd like to use google_currency in a project where I already have a JSON library installed (yajl-ruby), but it seems that google_currency has a hard dependency on the "json" implementation.

Is there a specific reason?

It could use multi-json and load whichever implementation is available.

Thanks for your input on this.

Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com"

Hello,

Firstly thanks for the great gem, we have been using it with great success in the past months.

I have just started getting a Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" from this gem but can't think of any changes made that would cause this. Do you have any ideas why this could be? I have tried updating to the latest gem version but to no effect.

Thanks very much.

rake db:migrate                                                                                                                                       
rake aborted!                                                                                                                                                                                                                       
Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" port 80                                                                                                                                                
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:128:in `fetch_rate'                                                                                                                       
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:99:in `block in get_rate'                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `synchronize'                                                                                                                       
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `get_rate'                                                                                                                          
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:22:in `block in <top (required)>'                                                                                                                                  
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:1:in `<top (required)>'                                                                                                                                            
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'                                                                                                                              
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `block in load'                                                                                                                     
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'                                                                                                                   
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'                                                                                                                              
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `block in run_tasks_blocks'                                                                                                                             
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `each'                                                                                                                                                  
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `run_tasks_blocks'                                                                                                                                      
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/application.rb:362:in `run_tasks_blocks'                                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:449:in `load_tasks'                                                                                                                                            
/home/action/workspace/trendosaur/Rakefile:6:in `<top (required)>'                                                                                                                                                                  
(See full trace by running task with --trace)                   

Incorrect amount converting USD -> VND

I'm missing a few decimal places when converting from US dollars to Vietnamese Dong.

irb(main):001:0> usd = Money.new(50, 'USD')
=> #<Money fractional:50 currency:USD>
irb(main):002:0> vnd = usd.exchange_to('VND')
=> #<Money fractional:10902 currency:VND>
irb(main):003:0> vnd.to_i
=> 10902

The google finance converter shows 50 USD = 1090250 VND

Could this be a bug?

undefined method `synchronize' for nil:NilClass

Hi,

Just trying google_currency and attempting to run a simple test detailed in "Usage":
require 'money'
require 'money/bank/google_currency'
Money.default_bank = Money::Bank::GoogleCurrency.new
money = Money.new(1_00, "USD")
money.exchange_to(:EUR)

The exchnage_to operation fails with:
NoMethodError: undefined method 'synchronize' for nil:NilClass
from /Users/knleva/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/google_currency-3.1.0/lib/money/bank/google_currency.rb:98:in `get_rate'

Here is the routine that fails:
def get_rate(from, to)
expire_rates
@mutex.synchronize{
@rates[rate_key_for(from, to)] ||= fetch_rate(from, to)
}
end

Tried googling, but can't find anything definitive on how to fix this. Would appreciate a tip.

Thanks,
Lev

google currency support

i noticed that i get quite a few currencies throw an UnknownRate exception even though the currency is listed on site google links you to. (http://www.currency-iso.org/dl_iso_table_a1.xls)

MVR is an iso code i have been using as an example. it returns false. (http://www.google.com/ig/calculator?hl=en&q=1USD=?MVR)

anyone know why there is such a vast discrepancy between valid iso codes and what google can/will process?

google's public interface for conversion (http://www.google.com/finance/converter) does indeed list those currencies. i would think they would have a common source.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.