module FakeBsmobil::Generator::Movements::Util
Public Instance Methods
basic(timestamp: Util.timestamp, amount:, balance: positive(1000))
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 62 def basic(timestamp: Util.timestamp, amount:, balance: positive(1000)) puts "{ timestamp: #{timestamp}, amount: #{amount}, balance: #{balance} }" { date: date = timestamp.strftime('%d-%m-%y'), valueDate: (timestamp + [0, 0, 0, 1].sample).strftime('%d-%m-%y'), canSplit: amount < -200, amount: Util.currency(amount), balance: Util.currency(balance + amount), apuntNumber: Generator.number(12), existDocument: false, cardNumber: '', productCode: '0', numPAN: '', returnBillCode: '', timeStamp: timestamp.strftime('%Y%m%d%H%M%S%6N'), sessionDate: date } end
card(timestamp: Util.timestamp, **options)
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 85 def card(timestamp: Util.timestamp, **options) puts "{timestamp: #{timestamp}, #{options}}" basic(timestamp: timestamp, **options).merge( numPAN: card = full_card_number, referencor: "#{card} #{timestamp.strftime('%Y-%m-%d %H:%M:%S')}", ) end
card_number()
click to toggle source
TODO: let generator generate card
# File lib/fake_bsmobil/generator/movements.rb, line 94 def card_number card = full_card_number.scan(/(\d{4})/) card[2] = card[1] = 'X' * 4 card.join end
company_name()
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 100 def company_name Faker::Company.name.upcase end
currency(amount)
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 120 def currency(amount) # FIXME: this is possibly buggy implementation taken from SO value = amount.to_f.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse { value: value, currency: 'EUR' } end
full_card_number()
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 108 def full_card_number "5402#{Generator.number(12)}" end
full_name()
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 104 def full_name Faker::Name.name end
negative(value)
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 116 def negative(value) rand(value).to_f * -1 end
positive(value)
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 112 def positive(value) rand(value).to_f end
timestamp()
click to toggle source
# File lib/fake_bsmobil/generator/movements.rb, line 81 def timestamp (Faker::Date.backward.to_time + rand(24*60*60)).to_datetime end