Class: Valvat::Checksum::NL

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/nl.rb

Instance Attribute Summary

Attributes inherited from Base

#vat

Instance Method Summary collapse

Methods inherited from Base

check_digit_length, #initialize

Constructor Details

This class inherits a constructor from Valvat::Checksum::Base

Instance Method Details

#check_digitObject



11
12
13
14
15
# File 'lib/valvat/checksum/nl.rb', line 11

def check_digit
  sum_figures_by do |fig, i|
    fig * (i + 2)
  end.modulo(11)
end

#str_wo_countryObject



17
18
19
# File 'lib/valvat/checksum/nl.rb', line 17

def str_wo_country
  super[0..-4]
end

#validateObject



6
7
8
9
# File 'lib/valvat/checksum/nl.rb', line 6

def validate
  vat.to_s.gsub(/[A-Z]/) { |let| (let.ord - 55).to_s }.to_i % 97 == 1 ||
    super
end