Class: Valvat::Checksum::IT

Inherits:
Base
  • Object
show all
Defined in:
lib/valvat/checksum/it.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



13
14
15
16
# File 'lib/valvat/checksum/it.rb', line 13

def check_digit
  chk = 10 - sum_of_figures_for_at_es_it_se(reverse_ints: true).modulo(10)
  chk == 10 ? 0 : chk
end

#validateObject



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

def validate
  y = figures_str[7..9].to_i
  y >= 1 && (y <= 100 || [120, 121, 999].include?(y)) &&
    figures_str[0..6] != '0000000' &&
    super
end