-
Notifications
You must be signed in to change notification settings - Fork 1
/
start_import.rb
executable file
·57 lines (47 loc) · 1.48 KB
/
start_import.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib')
require 'ib_estonia'
require 'exchange_rate_fetcher'
require 'isin_fetcher'
unless ARGV[0]
puts "Usage: ./start ib-2016.xml ib-2017.xml ..."
exit 1
end
exchange_rate_fetcher = ExchangeRateFetcher.new
isin_fetcher = IsinFetcher.new
symbols = ARGV.reduce([]) do |acc, path|
puts ">> Importing #{path} for symbols"
data = File.read(path)
acc + IbEstonia::Symbols::Importer.import(data, isin_fetcher)
end
trades = ARGV.reduce([]) do |acc, path|
puts ">> Importing #{path} for trades"
data = File.read(path)
acc + IbEstonia::Trades::Importer.import(data, symbols, exchange_rate_fetcher)
end
dividends = ARGV.reduce([]) do |acc, path|
puts ">> Importing #{path} for dividends"
data = File.read(path)
acc + IbEstonia::Dividends::Importer.import(data, symbols)
end
dividends_report = IbEstonia::Dividends::TaxReport.new(dividends, exchange_rate_fetcher)
puts
puts <<~EOS
################################
# TABEL 8.1 - Palk ja muu tulu #
################################
EOS
dividends_report.print(:without_tax)
puts
puts <<~EOS
##########################################
# TABEL 8.2 - Väärtpaberite võõrandamine #
##########################################
EOS
IbEstonia::Trades::TaxReport.new(trades).print
puts
puts <<~EOS
#######################################################
# TABEL 8.8 Välisriigis saadud, Eestis maksuvaba tulu #
#######################################################
EOS
dividends_report.print(:with_tax)