Class: Valvat::Checksum::EE

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/ee.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
13
14
# File 'lib/valvat/checksum/ee.rb', line 6

def check_digit
  multipliers = [7, 3, 1, 7, 3, 1, 7, 3]

  sum = sum_figures_by do |digit, index|
    digit * multipliers[index]
  end

  ((sum / 10.0).ceil * 10).to_i - sum
end