Class: BRDocuments::IE::AL

Inherits:
Base
  • Object
show all
Defined in:
lib/br_documents/documents/ie/al.rb

Constant Summary collapse

COMPANIES_TYPES =
{
  "0": "Normal",
  "3": "Produtor Rural",
  "5": "Substituta",
  "7": "Micro-Empresa Ambulante",
  "8": "Micro-Empresa"
}

Constants inherited from Base

Base::FIXED_INITIAL_NUMBERS, Base::INITIAL_FIX_NUMBERS_POSITION

Class Method Summary collapse

Methods inherited from Base

fixed_digits, fixed_digits_positions, set_fixed_digits, #valid?, valid_fixed_digits?, #valid_fixed_digits?, #validate_fixed_digits?

Class Method Details

.companies_types_labelsObject



22
23
24
# File 'lib/br_documents/documents/ie/al.rb', line 22

def companies_types_labels
  COMPANIES_TYPES.values
end

.company_type(number) ⇒ Object



38
39
40
41
# File 'lib/br_documents/documents/ie/al.rb', line 38

def company_type(number)
  # .to_s.to_sym to avoid nil.to_sym
  COMPANIES_TYPES[company_type_digit(number).to_s.to_sym]
end

.company_type_digit(number) ⇒ Object



43
44
45
46
47
# File 'lib/br_documents/documents/ie/al.rb', line 43

def company_type_digit(number)
  number = new(number).strip

  number.match(/^\d{2}(\d{1})/) && $1
end

.generate_root_numbersObject



30
31
32
33
34
35
36
# File 'lib/br_documents/documents/ie/al.rb', line 30

def generate_root_numbers
  numbers = super
  # force digit
  numbers[2] = sample_company_type_digit.to_i

  numbers
end

.sample_company_type_digitObject



26
27
28
# File 'lib/br_documents/documents/ie/al.rb', line 26

def sample_company_type_digit
  COMPANIES_TYPES.keys.sample.to_s
end