Class: Valvat::Checksum::FI

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

Instance Attribute Summary

Attributes inherited from Base

#vat

Instance Method Summary collapse

Methods inherited from Base

check_digit_length, #initialize, #validate

Constructor Details

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

Instance Method Details

#check_digitObject



6
7
8
9
10
11
12
# File 'lib/valvat/checksum/fi.rb', line 6

def check_digit
  weight = [7, 9, 10, 5, 8, 4, 2]
  chk = 11 - figures.map do |fig|
    fig * weight.shift
  end.inject(:+).modulo(11)
  chk == 11 ? 0 : chk
end