valvat 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,10 +1,16 @@
1
1
  ### dev
2
2
 
3
- [full changelog](http://github.com/yolk/valvat/compare/v0.4.2...master)
3
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.3...master)
4
4
 
5
5
  ### 0.4.2 / 2012-11-16
6
6
 
7
- [full changelog](http://github.com/yolk/valvat/compare/v0.4,1...v0.4.2)
7
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.2...v0.4.3)
8
+
9
+ * Fixed error handling in Lookup (by [bmurzeau](https://github.com/bmurzeau))
10
+
11
+ ### 0.4.2 / 2012-11-16
12
+
13
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.1...v0.4.2)
8
14
 
9
15
  * Fixed usage with savon version 1.2
10
16
  * Require version 1.2 of the savon gem from now on
@@ -12,53 +18,53 @@
12
18
 
13
19
  ### 0.4.1 / 2012-07-17
14
20
 
15
- [full changelog](http://github.com/yolk/valvat/compare/v0.4,0...v0.4.1)
21
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.0...v0.4.1)
16
22
 
17
23
  * Fixed issue with current savon version & required more recent savon version
18
24
 
19
25
  ### 0.4.0 / 2012-07-17
20
26
 
21
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,6...v0.4.0)
27
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.6...v0.4.0)
22
28
 
23
29
  * Added support for company details and requester identifiers in successful responses
24
- (by [lcx](https://github.com/lcx))
25
- * Added Valvat::Lookup.last_error for debugging
30
+ (by [lcx](https://github.com/lcx))
31
+ * Added Valvat::Lookup.last_error for debugging
26
32
 
27
33
  ### 0.3.6 / 2012-04-10
28
34
 
29
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,5...v0.3.6)
35
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.5...v0.3.6)
30
36
 
31
37
  * Fixed wrong regexp for Belgium numbers (by [opsidao](https://github.com/opsidao))
32
38
 
33
39
  ### 0.3.5 / 2012-02-02
34
40
 
35
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,4...v0.3.5)
41
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.4...v0.3.5)
36
42
 
37
43
  * Swedish translation (by [henrik](https://github.com/henrik))
38
44
  * English fixes (by [henrik](https://github.com/henrik))
39
45
 
40
46
  ### 0.3.4 / 2011-08-01
41
47
 
42
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,3...v0.3.4)
48
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.3...v0.3.4)
43
49
 
44
50
  * Normalize all input on initialization (by [SpoBo](https://github.com/SpoBo))
45
51
 
46
52
  ### 0.3.3 / 2011-06-02
47
53
 
48
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,2...v0.3.3)
54
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.2...v0.3.3)
49
55
 
50
56
  * Add Valvat::Utils.iso_country_to_vat_country (by [Deb Bassett](https://github.com/urbanwide))
51
57
 
52
58
  ### 0.3.2 / 2011-01-14
53
59
 
54
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,1...v0.3.2)
60
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.1...v0.3.2)
55
61
 
56
62
  * Fixed localization strings (en/de)
57
63
  * Moved locales folder to lib/valvat/locales
58
64
 
59
65
  ### 0.3.1 / 2011-01-12
60
66
 
61
- [full changelog](http://github.com/yolk/valvat/compare/v0.3,0...v0.3.1)
67
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.0...v0.3.1)
62
68
 
63
69
  * ActiveModel validation: Failed validations with _match_country_ now use error message with country from given attribute
64
70
  * ActiveModel validation: Failed validations with _match_country_ skip lookup and syntax checks
data/README.md CHANGED
@@ -10,7 +10,7 @@ Validates european vat numbers. Standalone or as a ActiveModel validator.
10
10
  * Works standalone without ActiveModel
11
11
  * I18n locales for country specific error messages
12
12
 
13
- valvat is tested and works with ruby 1.8.7/1.9.2 and ActiveModel 3.0.
13
+ valvat is tested and works with ruby 1.8.7/1.9.3 and ActiveModel 3.2.9
14
14
 
15
15
  ## Installation
16
16
 
@@ -22,12 +22,12 @@ To verify the syntax of a vat number:
22
22
 
23
23
  Valvat.new("DE345789003").valid?
24
24
  => true or false
25
-
25
+
26
26
  To check if the given vat number exists via the VIES web service:
27
27
 
28
28
  Valvat.new("DE345789003").exists?
29
29
  => true or false or nil
30
-
30
+
31
31
  *IMPORTANT* Keep in mind that the VIES web service might be offline at some time for some countries. If this happens `exists?` or `Valvat::Lookup.validate` will return `nil`.
32
32
 
33
33
  Visit [http://ec.europa.eu/taxation_customs/vies/viesspec.do](http://ec.europa.eu/taxation_customs/vies/viesspec.do) for more accurate information at what time the service for a specific country will be down.
@@ -36,47 +36,47 @@ It is also possible to bypass initializing a Valvat instance and check the synta
36
36
 
37
37
  Valvat::Syntax.validate("DE345789003")
38
38
  => true or false
39
-
39
+
40
40
  Or to lookup a vat number string directly via VIES web service:
41
41
 
42
42
  Valvat::Lookup.validate("DE345789003")
43
43
  => true or false or nil
44
-
44
+
45
45
  ## Details & request identifier
46
46
 
47
47
  If you need all details and not only if the VAT is valid, pass {:detail => true} as second parameter to the lookup call.
48
48
 
49
49
  Valvat.new("IE6388047V").exists?(:detail => true)
50
50
  => {
51
- :country_code=>"IE", :vat_number => "6388047V",
52
- :request_date => Date.today, :name=>"GOOGLE IRELAND LIMITED",
51
+ :country_code=>"IE", :vat_number => "6388047V",
52
+ :request_date => Date.today, :name=>"GOOGLE IRELAND LIMITED",
53
53
  :address=>"1ST & 2ND FLOOR ,GORDON HOUSE ,BARROW STREET ,DUBLIN 4"
54
54
  } or false or nil
55
-
55
+
56
56
  According to EU law, or at least as Austria sees it, it's mandatory to verify the UID number of every new customer, but also to check the UID Number periodicaly. To prove that you have checked the UID number, the VIES Web service can return a requestIdentifier.
57
57
 
58
58
  To receive a requestIdentifier you need to pass your own VAT number in the options hash. In this Example, Google (VAT IE6388047V) is checking the validity of eBays VAT number (LU21416127)
59
59
 
60
60
  Valvat.new("LU21416127").exists?(:my_vat => "IE6388047V")
61
61
  => {
62
- :country_code=>"LU", :vat_number => "21416127",
63
- :request_date => Date.today, :name=>"EBAY EUROPE S.A R.L.",
62
+ :country_code=>"LU", :vat_number => "21416127",
63
+ :request_date => Date.today, :name=>"EBAY EUROPE S.A R.L.",
64
64
  :address => "22, BOULEVARD ROYAL\nL-2449 LUXEMBOURG",
65
65
  :company_type => nil, :request_identifier => "some_uniq_string"
66
66
  } or false or nil
67
67
 
68
- ## ActiveModel/Rails3 Usage
68
+ ## Usage with ActiveModel / Rails 3
69
69
 
70
70
  ### Loading
71
71
 
72
72
  When the valvat gem is required and ActiveModel is already loaded, everything will work fine out of the box. If your load order differs just add
73
73
 
74
74
  require 'valvat/active_model'
75
-
75
+
76
76
  after ActiveModel has been loaded.
77
77
 
78
78
  ### Simple syntax validation
79
-
79
+
80
80
  To validate the attribute `vat_number` add this to your model:
81
81
 
82
82
  class MyModel < ActiveRecord::Base
@@ -84,18 +84,18 @@ To validate the attribute `vat_number` add this to your model:
84
84
  end
85
85
 
86
86
  ### Additional lookup validation
87
-
87
+
88
88
  To additionally perform a lookup via VIES:
89
89
 
90
90
  validates :vat_number, :valvat => {:lookup => true}
91
-
91
+
92
92
  By default this will validate to true if the VIES web service is down. To fail in this case simply add the `:fail_if_down` option:
93
93
 
94
94
  validates :vat_number, :valvat => {:lookup => :fail_if_down}
95
95
 
96
96
  ### Additional ISO country code validation
97
97
 
98
- If you want the vat number’s (ISO) country to match another country attribute, use the _match_country_ option:
98
+ If you want the vat number’s (ISO) country to match another country attribute, use the _match_country_ option:
99
99
 
100
100
  validates :vat_number, :valvat => {:match_country => :country}
101
101
 
@@ -108,36 +108,36 @@ By default blank vat numbers validate to false. To change this add the `:allow_b
108
108
  validates :vat_number, :valvat => {:allow_blank => true}
109
109
 
110
110
  ### Allow vat numbers outside of europe
111
-
111
+
112
112
  To allow vat numbers from outside of europe, add something like this to your model (country_code should return a upcase ISO country code):
113
113
 
114
114
  class MyModel < ActiveRecord::Base
115
115
  validates :vat_number, :valvat => true, :if => :eu?
116
-
116
+
117
117
  def eu?
118
118
  Valvat::Utils::EU_COUNTRIES.include?(country_code)
119
119
  end
120
120
  end
121
-
121
+
122
122
  ## Utilities
123
123
 
124
124
  To split a vat number into the country code and the remaining chars:
125
125
 
126
126
  Valvat::Utils.split("ATU345789003")
127
127
  => ["AT", "U345789003"]
128
-
128
+
129
129
  or
130
130
 
131
131
  Valvat.new("ATU345789003").to_a
132
132
  => ["AT", "U345789003"]
133
-
133
+
134
134
  Both methods always return an array. If it can not detect the country or the given country is located outside of europe it returns `[nil, nil]`. Please note that this does not strictly return the ISO country code: for greek vat numbers this returns the ISO language code 'EL' instead of the ISO country code 'GR'.
135
135
 
136
136
  To extract the ISO country code of a given vat number:
137
137
 
138
138
  Valvat.new("EL7345789003").iso_country_code
139
139
  => "GR"
140
-
140
+
141
141
  To extract the vat country code (first two chars in every european vat number):
142
142
 
143
143
  Valvat.new("EL7345789003").vat_country_code
@@ -147,7 +147,7 @@ To normalize a vat number:
147
147
 
148
148
  Valvat::Utils.normalize("atu345789003")
149
149
  => "ATU345789003"
150
-
150
+
151
151
  This basically just removes trailing spaces and ensures all chars are uppercase.
152
152
 
153
153
  ## Links
@@ -166,6 +166,6 @@ This basically just removes trailing spaces and ensures all chars are uppercase.
166
166
 
167
167
  ## BlaBla
168
168
 
169
- Copyright (c) 2011 Yolk Sebastian Munz & Julia Soergel GbR
169
+ Copyright (c) 2011-2012 Yolk Sebastian Munz & Julia Soergel GbR
170
170
 
171
171
  Beyond that, the implementation is licensed under the MIT License.
data/lib/valvat/lookup.rb CHANGED
@@ -18,7 +18,7 @@ class Valvat
18
18
  response[:valid] && (options[:detail] || options[:requester_vat]) ?
19
19
  filter_detail(response) : response[:valid]
20
20
  rescue => err
21
- if err.respond_to?(:to_hash) && err.to_hash[:fault] && e(rr.to_hash[:fault][:faultstring] || "").upcase =~ /INVALID_INPUT/
21
+ if err.respond_to?(:to_hash) && err.to_hash[:fault] && (err.to_hash[:fault][:faultstring] || "").upcase =~ /INVALID_INPUT/
22
22
  return false
23
23
  end
24
24
  raise err if options[:raise_error]
@@ -1,3 +1,3 @@
1
1
  class Valvat
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valvat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-16 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon