lib/faker/company.rb in faker-1.6.3 vs lib/faker/company.rb in faker-1.6.4
- old
+ new
@@ -46,10 +46,17 @@
def swedish_organisation_number
base = ('%09d' % rand(10 ** 9))
base + luhn_algorithm(base).to_s
end
+ def australian_business_number
+ base = ('%09d' % rand(10 ** 9))
+ abn = '00' + base
+
+ (99 - (abn_checksum(abn) % 89)).to_s + base
+ end
+
def profession
fetch('company.profession')
end
private
@@ -79,8 +86,20 @@
control_digit = (sum / 10 + 1) * 10 - sum
end
control_digit
end
+
+ def abn_checksum(abn)
+ abn_weights = [10,1,3,5,7,9,11,13,15,17,19]
+ sum = 0
+
+ abn_weights.each_with_index do |weight, i|
+ sum += weight * abn[i].to_i
+ end
+
+ sum
+ end
+
end
end
end