class Tordist::Generator
Public Class Methods
new(clearing_id)
click to toggle source
# File lib/tordist/generator.rb, line 3 def initialize(clearing_id) @clearing_id = clearing_id end
Public Instance Methods
body()
click to toggle source
# File lib/tordist/generator.rb, line 17 def body body_string = "" @transactions.each do |transaction| @transaction = transaction body_string = body_string + "#{type}#{symbol}#{@transaction.broker_alias_code.rjust(7,'0')}#{client_digit}#{quantity}#{price}#{@transaction.side}#{liquidation_portfolio}#{nil_user}#{client}#{client_digit}#{liquidation_type}#{bvmf}#{increase_percentage}#{deadline}#{order_number}#{broker}\r\n" end return body_string end
generate(transactions)
click to toggle source
# File lib/tordist/generator.rb, line 7 def generate(transactions) @transactions = transactions tordist_string = header tordist_string = tordist_string + body end
header()
click to toggle source
# File lib/tordist/generator.rb, line 13 def header "H#{header_date}#{@clearing_id.rjust(5,'0')}#{file_name}#{distribution_type}".ljust(92," ") +"\r\n" end
Protected Instance Methods
broker()
click to toggle source
# File lib/tordist/generator.rb, line 100 def broker @transaction.broker.rjust(5,'0') end
bvmf()
click to toggle source
# File lib/tordist/generator.rb, line 84 def bvmf '1 ' end
client()
click to toggle source
# File lib/tordist/generator.rb, line 72 def client ''.rjust(9,'0') end
client_digit()
click to toggle source
# File lib/tordist/generator.rb, line 55 def client_digit "0" end
deadline()
click to toggle source
# File lib/tordist/generator.rb, line 92 def deadline ''.rjust(4,'0') end
distribution_type()
click to toggle source
# File lib/tordist/generator.rb, line 32 def distribution_type # 05 – TIPO DA DISTRIBUIÇÃO # “P” – PERCENTUAL, “M” – PREÇO MÉDIO POR LOTE, “D” – PREÇO DIGITADO, “O” – PREÇO MÉDIO POR ORDEM, “R” – PREÇO DIGITADO POR ORDEM. 'M' end
file_name()
click to toggle source
# File lib/tordist/generator.rb, line 28 def file_name 'TORDIST' end
header_date()
click to toggle source
# File lib/tordist/generator.rb, line 38 def header_date @transactions.first.date.strftime("%d/%m/%Y") end
increase_percentage()
click to toggle source
# File lib/tordist/generator.rb, line 88 def increase_percentage '+'.ljust(12,'0') end
liquidation_portfolio()
click to toggle source
# File lib/tordist/generator.rb, line 64 def liquidation_portfolio "216" end
liquidation_type()
click to toggle source
# File lib/tordist/generator.rb, line 80 def liquidation_type "C" end
nil_user()
click to toggle source
# File lib/tordist/generator.rb, line 68 def nil_user ''.rjust(5,"0") end
order_number()
click to toggle source
# File lib/tordist/generator.rb, line 96 def order_number ''.rjust(9,'0') end
price()
click to toggle source
# File lib/tordist/generator.rb, line 59 def price # SOMENTE PARA TIPO DE DISTRIBUIÇÃO "D" ''.rjust(11,'0') end
quantity()
click to toggle source
# File lib/tordist/generator.rb, line 46 def quantity @transaction.quantity.abs.to_i.to_s.rjust(12, '0') end
symbol()
click to toggle source
# File lib/tordist/generator.rb, line 42 def symbol @transaction.symbol.ljust(12, ' ') end
type()
click to toggle source
# File lib/tordist/generator.rb, line 50 def type # FIXO “B” "B" end