Class: Faker::Company

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/company.rb

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale

Class Method Details

.australian_business_numberString

Produces a company australian business number.

Examples:

Faker::Company.australian_business_number #=> "93579396170"

Returns:



288
289
290
291
292
293
# File 'lib/faker/default/company.rb', line 288

def australian_business_number
  base = format('%09d', rand(10**9))
  abn = "00#{base}"

  (99 - (abn_checksum(abn) % 89)).to_s + base
end

.brazilian_company_number(formatted: false) ⇒ String

Produces a company brazilian company number.

Examples:

Faker::Company.brazilian_company_number #=> "37205322000500"

Returns:



423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/faker/default/company.rb', line 423

def brazilian_company_number(formatted: false)
  digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]

  factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle

  2.times do
    checksum = digits.inject(0) { |acc, digit| acc + digit * factors.next } % 11
    digits << (checksum < 2 ? 0 : 11 - checksum)
  end

  number = digits.join

  formatted ? format('%s.%s.%s/%s-%s', *number.scan(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/).flatten) : number
end

.bsString

Produces some company BS.

When a straight answer won’t do, BS to the rescue!

Examples:

Faker::Company.bs #=> "empower customized functionalities"

Returns:



83
84
85
# File 'lib/faker/default/company.rb', line 83

def bs
  translate('faker.company.bs').collect { |list| sample(list) }.join(' ')
end

.buzzwordString

Produces a company buzzword.

Examples:

Faker::Company.buzzword #=> "flexibility"

Returns:



69
70
71
# File 'lib/faker/default/company.rb', line 69

def buzzword
  sample(translate('faker.company.buzzwords').flatten)
end

.catch_phraseString

Produces a company catch phrase.

Examples:

Faker::Company.catch_phrase #=> "Grass-roots grid-enabled portal"

Returns:



56
57
58
# File 'lib/faker/default/company.rb', line 56

def catch_phrase
  translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ')
end

.czech_organisation_numberString

Produces a company czech organisation number.

Examples:

Faker::Company.czech_organisation_number #=> "90642741"

Returns:



218
219
220
221
222
223
224
225
226
227
# File 'lib/faker/default/company.rb', line 218

def czech_organisation_number
  sum = 0
  base = []
  [8, 7, 6, 5, 4, 3, 2].each do |weight|
    base << sample((0..9).to_a)
    sum += (weight * base.last)
  end
  base << (11 - (sum % 11)) % 10
  base.join
end

.departmentString

Produces a company department.

Examples:

Faker::Company.department #=> "Information Technology"

Returns:



163
164
165
# File 'lib/faker/default/company.rb', line 163

def department
  fetch('company.department')
end

.duns_numberString

Produces a company duns number.

Examples:

Faker::Company.duns_number #=> "70-655-5105"

Returns:



109
110
111
# File 'lib/faker/default/company.rb', line 109

def duns_number
  format('%09d', rand(10**9)).gsub(/(\d{2})(\d{3})(\d{4})/, '\\1-\\2-\\3')
end

.einString

Produces a company EIN (Employer Identification Number).

Examples:

Faker::Company.ein #=> "07-4009024"

Returns:



96
97
98
# File 'lib/faker/default/company.rb', line 96

def ein
  format('%09d', rand(10**9)).gsub(/(\d{2})(\d{7})/, '\\1-\\2')
end

.french_siren_numberString

Produces a company french siren number.

Get a random French SIREN number. See more here fr.wikipedia.org/wiki/Syst%C3%A8me_d%27identification_du_r%C3%A9pertoire_des_entreprises

Examples:

Faker::Company.french_siren_number #=> "163417827"

Returns:



239
240
241
242
# File 'lib/faker/default/company.rb', line 239

def french_siren_number
  base = (1..8).map { rand(10) }.join
  base + luhn_algorithm(base).to_s
end

.french_siret_numberString

Produces a company french siret number.

Examples:

Faker::Company.french_siret_number #=> "76430067900496"

Returns:



253
254
255
256
257
# File 'lib/faker/default/company.rb', line 253

def french_siret_number
  location = rand(100).to_s.rjust(4, '0')
  org_no = french_siren_number + location
  org_no + luhn_algorithm(org_no).to_s
end

.indian_gst_number(state_code: nil) ⇒ String

Get a random Indian Goods and Services Tax (GST) number. For more on Indian tax number here: simple.wikipedia.org/wiki/GSTIN

Examples:

Faker::Company.indian_gst_number #=> "15VQPNZ2126J2ZU"
Faker::Company.indian_gst_number(state_code: "22") #=> "22ZVWEY6632K0ZN"

Returns:



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/faker/default/company.rb', line 479

def indian_gst_number(state_code: nil)
  # Check if state code is valid
  state_code_ranges = [('02'..'38'), ['98']]
  if state_code && !(state_code_ranges[0].include?(state_code) || state_code == '98')
    raise ArgumentError, 'state code must be in a range of 02 to 38 or 98'
  end

  PositionalGenerator.new(:string) do |gen|
    # Generate a state code if not given
    if state_code
      gen.lit(state_code, name: :state_code_param)
    else
      gen.letter(name: :state_code_param, length: 1, ranges: state_code_ranges)
    end

    # Construct taxpayer number
    gen.group(name: :taxpayer_number) do |g_|
      g_.letter(length: 3, ranges: ['A'..'Z'])
      g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]].to_a)
      g_.letter(length: 1, ranges: ['A'..'Z'])
      g_.int(length: 4, ranges: [0..9999])
      g_.letter(length: 1, ranges: ['A'..'Z'])
    end

    gen.int(name: :registration_number, length: 1, ranges: [0..9])

    gen.letter(name: :z_char, length: 1, ranges: [['Z']])

    gen.computed(deps: %i[state_code_param taxpayer_number registration_number]) do |state_code_param, taxpayer_number, registration_number|
      gst_base = "#{state_code_param}#{taxpayer_number}#{registration_number}"
      chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars
      values = gst_base.chars
      sum = values.map.with_index do |char, index|
        product = chars.index(char) * (index.odd? ? 2 : 1)
        (product / chars.length).floor + (product % chars.length)
      end.reduce(:+)

      checksum = (chars.length - (sum % chars.length)) % chars.length
      chars[checksum]
    end
  end.generate
end

.industryString

Produces a company industry.

Examples:

Faker::Company.industry #=> "Food & Beverages"

Returns:



43
44
45
# File 'lib/faker/default/company.rb', line 43

def industry
  fetch('company.industry')
end

.logoString

Produces a company logo.

Get a random company logo url in PNG format.

Examples:

Faker::Company. #=> "https://pigment.github.io/fake-logos/logos/medium/color/12.png"

Returns:



123
124
125
126
# File 'lib/faker/default/company.rb', line 123

def 
  rand_num = rand(1..13)
  "https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png"
end

.nameString

Produces a company name.

Examples:

Faker::Company.name #=> "Roberts Inc"

Returns:



17
18
19
# File 'lib/faker/default/company.rb', line 17

def name
  parse('company.name')
end

.norwegian_organisation_numberString

Produces a company norwegian organisation number.

Get a random Norwegian organization number. Info: www.brreg.no/om-oss/samfunnsoppdraget-vart/registera-vare/einingsregisteret/organisasjonsnummeret/

Examples:

Faker::Company.norwegian_organisation_number #=> "842457173"

Returns:



269
270
271
272
273
274
275
276
277
# File 'lib/faker/default/company.rb', line 269

def norwegian_organisation_number
  # Valid leading digit: 8, 9
  mod11_check = nil
  while mod11_check.nil?
    base = [sample([8, 9]), format('%07d', rand(10**7))].join
    mod11_check = mod11(base)
  end
  base + mod11_check.to_s
end

.polish_register_of_national_economy(length: 9) ⇒ String

Produces a company polish register of national economy.

Get a random Polish register of national economy number. More info pl.wikipedia.org/wiki/REGON

Examples:

Faker::Company.polish_register_of_national_economy #=> "788435970"

Returns:

Raises:

  • (ArgumentError)


325
326
327
328
329
330
331
332
333
334
# File 'lib/faker/default/company.rb', line 325

def polish_register_of_national_economy(length: 9)
  raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length

  random_digits = []
  loop do
    random_digits = Array.new(length) { rand(10) }
    break if collect_regon_sum(random_digits) == random_digits.last
  end
  random_digits.join
end

.polish_taxpayer_identification_numberString

Produces a company polish taxpayer identification_number.

Get a random Polish taxpayer identification number More info pl.wikipedia.org/wiki/NIP

Examples:

Faker::Company.polish_taxpayer_identification_number #=> "2767549463"

Returns:



305
306
307
308
309
310
311
312
313
# File 'lib/faker/default/company.rb', line 305

def polish_taxpayer_identification_number
  result = []
  weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
  loop do
    result = Array.new(3) { rand(1..9) } + Array.new(7) { rand(10) }
    break if (weight_sum(result, weights) % 11) == result[9]
  end
  result.join
end

.professionString

Produces a company profession.

Examples:

Faker::Company.profession #=> "factory worker"

Returns:



150
151
152
# File 'lib/faker/default/company.rb', line 150

def profession
  fetch('company.profession')
end

.russian_tax_number(region: nil, type: :legal) ⇒ String

Get a random Russian tax number.

Examples:

Faker::Company.russian_tax_number                             #=> "0415584064"
Faker::Company.russian_tax_number(region: 'AZ')               #=> "AZ50124562"
Faker::Company.russian_tax_number(region: 'AZ', type: false)  #=> "AZ8802315465"

Parameters:

  • region (String) (defaults to: nil)

    Any region string

  • type (Symbol) (defaults to: :legal)

    Legeal or not, defaults to :legal

Returns:



450
451
452
# File 'lib/faker/default/company.rb', line 450

def russian_tax_number(region: nil, type: :legal)
  inn_number(region, type)
end

.sic_codeString

Produces a company sic code.

Examples:

Faker::Company.sic_code #=> "7383"

Returns:



463
464
465
# File 'lib/faker/default/company.rb', line 463

def sic_code
  fetch('company.sic_code')
end

.south_african_close_corporation_registration_numberString

Produces a company south african close corporation registration number.

Examples:

Faker::Company.south_african_close_corporation_registration_number #=> "CK38/5739937418/23"

Returns:



363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/faker/default/company.rb', line 363

def south_african_close_corporation_registration_number
  generate(:string) do |g|
    g.oneof do |one|
      one.group do |g_|
        g_.lit('CK')
        g_.int(length: 2)
      end
      one.int(length: 4)
    end
    g.lit('/')
    g.int(ranges: [1000..9_999_999_999])
    g.lit('/23')
  end
end

.south_african_listed_company_registration_numberString

Produces a company south african listed company registration number.

Examples:

Faker::Company.south_african_listed_company_registration_number #=> "2512/87676/06"

Returns:



387
388
389
390
391
392
393
394
# File 'lib/faker/default/company.rb', line 387

def south_african_listed_company_registration_number
  generate(:string) do |g|
    g.int(length: 4)
    g.lit('/')
    g.int(ranges: [1000..9_999_999_999])
    g.lit('/06')
  end
end

.south_african_pty_ltd_registration_numberString

Produces a company south african pty ltd registration number.

Examples:

Faker::Company.south_african_pty_ltd_registration_number #=> "7043/2400717902/07"

Returns:



345
346
347
348
349
350
351
352
# File 'lib/faker/default/company.rb', line 345

def south_african_pty_ltd_registration_number
  generate(:string) do |g|
    g.int(length: 4)
    g.lit('/')
    g.int(ranges: [1000..9_999_999_999])
    g.lit('/07')
  end
end

.south_african_trust_registration_numberString

Produces a company south african trust registration number.

Examples:

Faker::Company.south_african_trust_registration_number #=> "IT5673/937519896"

Returns:



405
406
407
408
409
410
411
412
# File 'lib/faker/default/company.rb', line 405

def south_african_trust_registration_number
  generate(:string) do |g|
    g.lit('IT')
    g.int(ranges: [10..9999])
    g.lit('/')
    g.int(ranges: [10..9_999_999_999])
  end
end

.spanish_organisation_number(organization_type: nil) ⇒ String

Produces a company spanish organisation number.

Get a random Spanish organization number. See more here es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal

Examples:

Faker::Company.spanish_organisation_number #=> "D6819358"

Returns:



178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/faker/default/company.rb', line 178

def spanish_organisation_number(organization_type: nil)
  # Valid leading character: A, B, C, D, E, F, G, H, J, N, P, Q, R, S, U, V, W
  # format: 1 digit letter (organization type) + 7 digit numbers + 1 digit control (letter or number based on
  # organization type)
  letters = %w[A B C D E F G H J N P Q R S U V W]

  organization_type = sample(letters) unless letters.include?(organization_type)
  code = format('%07d', rand(10**7))
  control = spanish_cif_control_digit(organization_type, code)

  [organization_type, code, control].join
end

.suffixString

Produces a company suffix.

Examples:

Faker::Company.suffix #=> "LLC"

Returns:



30
31
32
# File 'lib/faker/default/company.rb', line 30

def suffix
  fetch('company.suffix')
end

.swedish_organisation_numberString

Produces a company swedish organisation number.

Get a random Swedish organization number. See more here sv.wikipedia.org/wiki/Organisationsnummer

Examples:

Faker::Company.swedish_organisation_number #=> "3866029808"

Returns:



201
202
203
204
205
206
207
# File 'lib/faker/default/company.rb', line 201

def swedish_organisation_number
  # Valid leading digit: 1, 2, 3, 5, 6, 7, 8, 9
  # Valid third digit: >= 2
  # Last digit is a control digit
  base = [sample([1, 2, 3, 5, 6, 7, 8, 9]), sample((0..9).to_a), sample((2..9).to_a), format('%06d', rand(10**6))].join
  base + luhn_algorithm(base).to_s
end

.typeString

Produces a company type.

Examples:

Faker::Company.type #=> "Partnership"

Returns:



137
138
139
# File 'lib/faker/default/company.rb', line 137

def type
  fetch('company.type')
end