bcaparser 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README +1 -0
- data/bin/bcaparser +196 -0
- data/lib/bcaparser/account.rb +39 -0
- data/lib/bcaparser/parser.rb +190 -0
- data/lib/bcaparser/regex_check.rb +25 -0
- data/lib/bcaparser/time_keeper.rb +135 -0
- data/lib/bcaparser/transaction.rb +11 -0
- data/spec/regex_check_spec.rb +17 -0
- data/spec/time_keeper_spec.rb +70 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c8df37de62bff5b8d655f8790f349e82d5780de
|
4
|
+
data.tar.gz: 288a2e19dbe323f9e711b30c2e133f1aaa44dfdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf2ca29a47d881aecd6d5eec6e51376d6d6407f8032da801130867198250ed62d8010fb4c379302ac397e9e85238904db3f7146258814c93502a9cd188415fc3
|
7
|
+
data.tar.gz: 35e3e7973a59f9ee77950270b1e1b5022efdc100820f0208e548940d7d6c91e01de27d3617a415c7383c6579cc536b3e28d9cf69d51bb792e992f372b98fbafb
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Alfian Losari
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PU
|
18
|
+
RPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gem ini berfungsi untuk automatisasi dalam mengambil informasi saldo dan mutasi rekening Bank BCA anda secara mudah, cepat, dan efisien. Dengan menggunakan command line anda dapat dengan mudah melakukan automatisasi untuk pengambilan data berupa informasi saldo, mutasi transaksi harian, mutasi transaksi bulanan. Data kemudia dapat ditampilkan maupun disimpan ke dalam bentuk CSV maupun Excel. Gem ini tidak mengambil data anda sama sekali, karena gem ini pada dasarnya bekerja dengan melakukan automatisasi pada browser anda untuk melakukan hal-hal yang biasa anda lakukan dengan mengklik pada browser untuk melakukan transaksi. Dibutuhkan browser Firefox terinstall pada sistem anda untuk menggunakan gem ini.
|
data/bin/bcaparser
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative '../lib/bcaparser/parser'
|
3
|
+
require_relative '../lib/bcaparser/regex_check'
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
PESAN_RESCUE = "Ada Error, kemungkinan ada kesalahan pada parameter yang anda masukkan"
|
7
|
+
|
8
|
+
class Main < Thor
|
9
|
+
desc "cek_saldo", "cek_saldo username password"
|
10
|
+
def cek_saldo(*parameters)
|
11
|
+
parser = BcaParser::Parser.new(parameters[0], parameters[1])
|
12
|
+
parser.login
|
13
|
+
parser.check_balance
|
14
|
+
parser.logout
|
15
|
+
parser.close
|
16
|
+
rescue
|
17
|
+
puts PESAN_RESCUE
|
18
|
+
parser.close
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "cek_mutasi_harian", "cek_mutasi_harian username password"
|
22
|
+
def cek_mutasi_harian(*parameters)
|
23
|
+
start_day, start_month, end_day, end_month, output, print_format, filename = nil
|
24
|
+
loop do
|
25
|
+
say "\nMasukkan rentang tanggal pengecekan, maksimal 31 hari yang lalu"
|
26
|
+
say "format: day/month"
|
27
|
+
tanggal_awal = ask("\nMasukkan tanggal awal: ")
|
28
|
+
tanggal_awal.chomp!
|
29
|
+
if !BcaParser::RegexCheck.checkUserDate(tanggal_awal)
|
30
|
+
say "Format yang anda masukkan salah"
|
31
|
+
next
|
32
|
+
end
|
33
|
+
|
34
|
+
start_day, start_month = tanggal_awal.split("/")
|
35
|
+
if !BcaParser::TimeKeeper.checkDayMonth(start_day, start_month)
|
36
|
+
say "Bulan dan tanggal anda salah"
|
37
|
+
next
|
38
|
+
end
|
39
|
+
|
40
|
+
tanggal_akhir = ask("Masukkan tanggal akhir: ")
|
41
|
+
tanggal_akhir.chomp!
|
42
|
+
|
43
|
+
if !BcaParser::RegexCheck.checkUserDate(tanggal_akhir)
|
44
|
+
say "Format yang anda masukkan salah"
|
45
|
+
next
|
46
|
+
end
|
47
|
+
|
48
|
+
end_day, end_month = tanggal_akhir.split("/")
|
49
|
+
if !BcaParser::TimeKeeper.checkDayMonth(end_day, end_month)
|
50
|
+
say "Bulan dan tanggal anda salah"
|
51
|
+
next
|
52
|
+
end
|
53
|
+
|
54
|
+
if !BcaParser::TimeKeeper.checkDateForBalance(start_day, start_month, end_day, end_month)
|
55
|
+
say "Tanggal awal lebih besar dari tanggal akhir, tanggal melebihi hari ini, rentang tanggal tidak berada dalam 31 hari"
|
56
|
+
next
|
57
|
+
end
|
58
|
+
break
|
59
|
+
end
|
60
|
+
|
61
|
+
say "\nVerfikasi tanggal sukses"
|
62
|
+
say "Pengecekan mutasi harian dari tanggal #{start_day}/#{start_month}-#{end_day}/#{end_month}"
|
63
|
+
|
64
|
+
|
65
|
+
parser = BcaParser::Parser.new(parameters[0], parameters[1])
|
66
|
+
parser.login
|
67
|
+
parser.check_daily_transaction(start_day, start_month, end_day, end_month)
|
68
|
+
|
69
|
+
loop do
|
70
|
+
say "\nOpsi Tampilan Data"
|
71
|
+
say "Ketik 1 Untuk Tampilkan Info Pada Layar"
|
72
|
+
say "Ketik 2 Untuk save ke dalam file"
|
73
|
+
output = ask "Masukkan Pilihan anda: "
|
74
|
+
|
75
|
+
if !BcaParser::RegexCheck.checkUserOutputDisplay(output)
|
76
|
+
say "Masukkan 1 atau 2 sebagai pilihan"
|
77
|
+
next
|
78
|
+
end
|
79
|
+
break
|
80
|
+
end
|
81
|
+
|
82
|
+
case output
|
83
|
+
when "1"
|
84
|
+
parser.displayDataInScreen
|
85
|
+
when "2"
|
86
|
+
loop do
|
87
|
+
say "\nPilih Format File"
|
88
|
+
say "1.CSV"
|
89
|
+
say "2.Excel"
|
90
|
+
print_format = ask "Masukkan pilihan 1 atau 2:"
|
91
|
+
|
92
|
+
if !BcaParser::RegexCheck.checkUserOutputDisplay(print_format)
|
93
|
+
say "Masukkan 1 atau 2 sebagai pilihan"
|
94
|
+
next
|
95
|
+
end
|
96
|
+
|
97
|
+
filename = ask "Masukkan nama file: "
|
98
|
+
break
|
99
|
+
end
|
100
|
+
|
101
|
+
case print_format
|
102
|
+
when "1"
|
103
|
+
parser.saveDataToCSV(filename)
|
104
|
+
when "2"
|
105
|
+
parser.saveDataToSpreadsheet(filename)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
parser.logout
|
110
|
+
parser.close
|
111
|
+
rescue
|
112
|
+
puts PESAN_RESCUE
|
113
|
+
parser.logout
|
114
|
+
parser.close
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "cek_mutasi_bulanan", "cek_mutasi_bulanan username password"
|
118
|
+
def cek_mutasi_bulanan(*parameters)
|
119
|
+
|
120
|
+
month, output, print_format, filename = nil
|
121
|
+
months = BcaParser::TimeKeeper.twoPreviousMonths
|
122
|
+
|
123
|
+
loop do
|
124
|
+
say "\nPilih 2 bulan di bawah ini"
|
125
|
+
say "#{months[0]}"
|
126
|
+
say "#{months[1]}"
|
127
|
+
month = ask("\nMasukkan bulan: ")
|
128
|
+
month.chomp!
|
129
|
+
|
130
|
+
if !BcaParser::RegexCheck.checkUserMonth(month)
|
131
|
+
say "Format yang anda masukkan salah"
|
132
|
+
next
|
133
|
+
end
|
134
|
+
|
135
|
+
if !BcaParser::TimeKeeper.checkMonthForBalance(month)
|
136
|
+
say "Masukan bulan berupa satu bulan lalu atau 2 bulan lalu"
|
137
|
+
next
|
138
|
+
end
|
139
|
+
break
|
140
|
+
end
|
141
|
+
|
142
|
+
parser = BcaParser::Parser.new(parameters[0], parameters[1])
|
143
|
+
parser.login
|
144
|
+
parser.check_monthly_transaction(month)
|
145
|
+
|
146
|
+
loop do
|
147
|
+
say "\nOpsi Tampilan Data"
|
148
|
+
say "Ketik 1 Untuk Tampilkan Info Pada Layar"
|
149
|
+
say "Ketik 2 Untuk save ke dalam file"
|
150
|
+
output = ask "Masukkan Pilihan anda: "
|
151
|
+
|
152
|
+
if !BcaParser::RegexCheck.checkUserOutputDisplay(output)
|
153
|
+
say "Masukkan 1 atau 2 sebagai pilihan"
|
154
|
+
next
|
155
|
+
end
|
156
|
+
break
|
157
|
+
end
|
158
|
+
|
159
|
+
case output
|
160
|
+
when "1"
|
161
|
+
parser.displayDataInScreen
|
162
|
+
when "2"
|
163
|
+
loop do
|
164
|
+
say "\nPilih Format File"
|
165
|
+
say "1.CSV"
|
166
|
+
say "2.Excel"
|
167
|
+
print_format = ask "Masukkan pilihan 1 atau 2:"
|
168
|
+
|
169
|
+
if !BcaParser::RegexCheck.checkUserOutputDisplay(print_format)
|
170
|
+
say "Masukkan 1 atau 2 sebagai pilihan"
|
171
|
+
next
|
172
|
+
end
|
173
|
+
|
174
|
+
filename = ask "Masukkan nama file: "
|
175
|
+
break
|
176
|
+
end
|
177
|
+
|
178
|
+
case print_format
|
179
|
+
when "1"
|
180
|
+
parser.saveDataToCSV(filename)
|
181
|
+
when "2"
|
182
|
+
parser.saveDataToSpreadsheet(filename)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
parser.logout
|
187
|
+
parser.close
|
188
|
+
rescue
|
189
|
+
puts PESAN_RESCUE
|
190
|
+
parser.logout
|
191
|
+
parser.close
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
Main.start
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'transaction'
|
2
|
+
|
3
|
+
module BcaParser
|
4
|
+
class Account
|
5
|
+
attr_reader :name, :id, :balance, :transactions
|
6
|
+
|
7
|
+
def initialize(name, id=0, balance=0)
|
8
|
+
@name = name
|
9
|
+
@id = id
|
10
|
+
@balance = {}
|
11
|
+
@transactions = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_transaction(transaction)
|
15
|
+
@transactions << transaction
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_balance
|
19
|
+
puts "\nInformasi Saldo"
|
20
|
+
puts "#{Time.now}"
|
21
|
+
puts "------------------"
|
22
|
+
puts "Nomor Rekening: #{balance[:account_number]}"
|
23
|
+
puts "Total Saldo: #{balance[:total]}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_transactions
|
27
|
+
puts "\nTransaksi Mutasi Harian".center(120)
|
28
|
+
@transactions.each do |transaction|
|
29
|
+
next if transaction[:date].nil?
|
30
|
+
puts "\nTransaksi"
|
31
|
+
puts "Tanggal: #{transaction[:date]}"
|
32
|
+
puts "Info: #{transaction[:info]}"
|
33
|
+
puts "Jumlah: #{transaction[:amount]}"
|
34
|
+
puts "Jenis Mutasi: #{transaction[:type]}"
|
35
|
+
puts "Saldo: #{transaction[:balance]}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'watir'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'csv'
|
4
|
+
require 'spreadsheet'
|
5
|
+
require_relative 'time_keeper'
|
6
|
+
require_relative 'account'
|
7
|
+
require_relative 'transaction'
|
8
|
+
|
9
|
+
|
10
|
+
module BcaParser
|
11
|
+
class Parser
|
12
|
+
attr_accessor :account_number, :start_date, :end_date, :start_month, :end_month, :transaction_check_type, :month
|
13
|
+
attr_reader :success
|
14
|
+
|
15
|
+
def initialize(username, password, file_to_open='')
|
16
|
+
@username = String(username)
|
17
|
+
@password = String(password)
|
18
|
+
@browser = Watir::Browser.start "https://ibank.klikbca.com"
|
19
|
+
@browser.window.resize_to(100, 90)
|
20
|
+
end
|
21
|
+
|
22
|
+
def login
|
23
|
+
info
|
24
|
+
@browser.text_field(:id, "user_id").set(@username)
|
25
|
+
@browser.text_field(:id, "pswd").set(@password)
|
26
|
+
@browser.button(:value,"LOGIN").click
|
27
|
+
@browser.button(:value,"LOGIN").click
|
28
|
+
@logged_in = @browser.browser.frame(:name, "atm") != nil
|
29
|
+
if logged?
|
30
|
+
@atm = @browser.frame(:name, "atm")
|
31
|
+
@header = @browser.frame(:name, "header")
|
32
|
+
page_html = get_html_nokogiri(@atm.html)
|
33
|
+
text = page_html.xpath("/html/body/table[4]/tbody/tr[3]/td/center/b/font").inner_text.split(',')
|
34
|
+
name = text[0]
|
35
|
+
@account = Account.new(name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def transaction_success?
|
40
|
+
@success
|
41
|
+
end
|
42
|
+
|
43
|
+
def logout
|
44
|
+
if logged?
|
45
|
+
@header.link(:text, "[ LOGOUT ]").click
|
46
|
+
puts "\nLogout Success"
|
47
|
+
@logged_in = false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def logged?
|
52
|
+
@logged_in
|
53
|
+
end
|
54
|
+
|
55
|
+
def enter_informasi_rekening
|
56
|
+
@browser.frame(:name, "menu").link(:text, "Informasi Rekening").click
|
57
|
+
end
|
58
|
+
|
59
|
+
def enter_informasi_saldo
|
60
|
+
enter_informasi_rekening
|
61
|
+
@browser.frame(:name, "menu").link(:text, "Informasi Saldo").click
|
62
|
+
end
|
63
|
+
|
64
|
+
def enter_mutasi_rekening
|
65
|
+
enter_informasi_rekening
|
66
|
+
@browser.frame(:name, "menu").link(:text, "Mutasi Rekening").click
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_html_nokogiri(page_to_parse_html)
|
70
|
+
Nokogiri::HTML.parse(page_to_parse_html)
|
71
|
+
end
|
72
|
+
|
73
|
+
def date_correct?(start_date, start_month, end_date, end_month)
|
74
|
+
start_day = TimeKeeper.makeDateFromString(start_date, start_month, Time.new.year)
|
75
|
+
end_day = TimeKeeper.makeDateFromString(end_date, end_month, Time.new.year)
|
76
|
+
TimeKeeper.compareDate(start_day, end_day)
|
77
|
+
end
|
78
|
+
|
79
|
+
def save_balance_to_sql
|
80
|
+
balance = check_balance
|
81
|
+
puts @account.name
|
82
|
+
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def get_transaction_list_table(page_html)
|
88
|
+
if page_html.at_xpath('/html/body/table[3]/tbody/tr[3]/td/table/tbody/tr[5]/td[1]')
|
89
|
+
@success = true
|
90
|
+
acc = 1
|
91
|
+
table_row = page_html.at_xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]")
|
92
|
+
while table_row != nil
|
93
|
+
transactionInfo = []
|
94
|
+
transaction = {}
|
95
|
+
if acc == 1
|
96
|
+
transactionInfo << page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[1]/div/font/b").inner_text
|
97
|
+
transactionInfo << page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[2]/div/font/b").inner_text
|
98
|
+
transactionInfo << page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[3]/div/font/b").inner_text
|
99
|
+
transactionInfo << page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[4]/div/font/b").inner_text
|
100
|
+
transactionInfo << page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[5]/div/font/b").inner_text
|
101
|
+
else
|
102
|
+
transaction[:date] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[1]/div/font").inner_text
|
103
|
+
transaction[:info] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[2]/div/font").inner_text
|
104
|
+
transaction[:amount] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[4]/div/font").inner_text
|
105
|
+
transaction[:type] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[5]/div/font").inner_text
|
106
|
+
transaction[:balance] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]/td[6]/div/font").inner_text
|
107
|
+
end
|
108
|
+
@account.add_transaction(transaction)
|
109
|
+
acc += 1
|
110
|
+
table_row = page_html.at_xpath("/html/body/table[3]/tbody/tr[2]/td/table/tbody/tr[#{acc}]")
|
111
|
+
end
|
112
|
+
else
|
113
|
+
@success = false
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def check_balance
|
119
|
+
enter_informasi_saldo
|
120
|
+
page_html = get_html_nokogiri(@atm.html)
|
121
|
+
@account.balance[:account_number] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td[1]/div/font").inner_text
|
122
|
+
@account.balance[:total] = page_html.xpath("/html/body/table[3]/tbody/tr[2]/td[4]/div/font").inner_text
|
123
|
+
@account.print_balance
|
124
|
+
end
|
125
|
+
|
126
|
+
def check_daily_transaction(start_date, start_month, end_date, end_month)
|
127
|
+
enter_mutasi_rekening
|
128
|
+
@atm.select_list(:id, "startDt").select("#{start_date}")
|
129
|
+
@atm.select_list(:id, "startMt").select("#{TimeKeeper.getIndonesianMonth(start_month)}")
|
130
|
+
@atm.select_list(:id, "endDt").select("#{end_date}")
|
131
|
+
@atm.select_list(:id, "endMt").select("#{TimeKeeper.getIndonesianMonth(end_month)}")
|
132
|
+
@atm.button(:value,"Lihat Mutasi Rekening").click
|
133
|
+
page_html = get_html_nokogiri(@atm.html)
|
134
|
+
get_transaction_list_table(page_html)
|
135
|
+
end
|
136
|
+
|
137
|
+
def check_monthly_transaction(month)
|
138
|
+
enter_mutasi_rekening
|
139
|
+
@atm.radio(:value, "2").set
|
140
|
+
@atm.select_list(:id, "x").select("#{TimeKeeper.getIndonesianMonth(month)}")
|
141
|
+
@atm.button(:value,"Lihat Mutasi Rekening").click
|
142
|
+
page_html = get_html_nokogiri(@atm.html)
|
143
|
+
get_transaction_list_table(page_html)
|
144
|
+
end
|
145
|
+
|
146
|
+
def info
|
147
|
+
puts "\nGetting data..."
|
148
|
+
puts "Watir is automating the browser..."
|
149
|
+
puts "Nokogiri is parsing..."
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def close
|
154
|
+
puts "Closing the browser"
|
155
|
+
@browser.close
|
156
|
+
end
|
157
|
+
|
158
|
+
def displayDataInScreen
|
159
|
+
@account.print_transactions
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
def saveDataToCSV(filename)
|
164
|
+
CSV.open(File.join(File.dirname(__FILE__), "#{filename}.csv"), "w") do |csv|
|
165
|
+
csv << ["Tanggal", "Informasi", "Jumlah", "Jenis Mutasi", "Saldo"]
|
166
|
+
@account.transactions.each do |transaction|
|
167
|
+
next if transaction[:date].nil?
|
168
|
+
csv << [transaction[:date], transaction[:info], transaction[:amount], transaction[:type], transaction[:balance]]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
puts "#{filename}.csv has been saved"
|
172
|
+
end
|
173
|
+
|
174
|
+
def saveDataToSpreadsheet(filename)
|
175
|
+
book = Spreadsheet::Workbook.new
|
176
|
+
sheet1 = book.create_worksheet
|
177
|
+
sheet1.row(0).replace ["Tanggal", "Informasi", "Jumlah", "Tipe", "Saldo"]
|
178
|
+
count = 1
|
179
|
+
@account.transactions.each do |transaction|
|
180
|
+
next if transaction[:date].nil?
|
181
|
+
sheet1.row(count).replace [transaction[:date], transaction[:info], transaction[:amount], transaction[:type], transaction[:balance]]
|
182
|
+
count += 1
|
183
|
+
end
|
184
|
+
book.write(File.join(File.dirname(__FILE__), "#{filename}.xls"))
|
185
|
+
puts "#{filename}.xls has been saved"
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module BcaParser
|
2
|
+
module RegexCheck
|
3
|
+
|
4
|
+
MONTHDAYREG = /\b[0-9]{1,2}\/[0-9]{1,2}\b/
|
5
|
+
OUTPUTREG = /\b[1-2]{1}\b/
|
6
|
+
MONTHREG = /\b[0-9]{1,2}\b/
|
7
|
+
|
8
|
+
def self.checkUserDate(date)
|
9
|
+
date =~ MONTHDAYREG ? true : false
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.checkUserOutputDisplay(output)
|
13
|
+
output =~ OUTPUTREG ? true : false
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.checkUserMonth(month)
|
17
|
+
month =~ MONTHREG ? true : false
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module BcaParser
|
4
|
+
module TimeKeeper
|
5
|
+
|
6
|
+
DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
7
|
+
MONTHS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
8
|
+
MAX_DAYS = 2678400
|
9
|
+
|
10
|
+
def self.twoPreviousMonths
|
11
|
+
month = Time.new.month
|
12
|
+
[month - 2, month - 1]
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
def self.checkMonthForBalance(month)
|
18
|
+
month = month.to_i
|
19
|
+
now_month = Time.now.month
|
20
|
+
|
21
|
+
if month >= now_month or month < now_month - 2
|
22
|
+
false
|
23
|
+
else
|
24
|
+
true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
def self.checkDateForBalance(start_date, start_month, end_date, end_month)
|
31
|
+
start_day = TimeKeeper.makeDateFromString(start_date, start_month, Time.now.year)
|
32
|
+
end_day = TimeKeeper.makeDateFromString(end_date, end_month, Time.now.year)
|
33
|
+
if !compareDate(start_day, end_day)
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
|
37
|
+
if !nowAndPast?(start_day, end_day)
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
41
|
+
if !inRangeMaxDays?(start_day, end_day)
|
42
|
+
return false
|
43
|
+
else
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.nowAndPast?(start_day, end_day)
|
49
|
+
now = Time.now
|
50
|
+
if start_day <= now && end_day <= now
|
51
|
+
return true
|
52
|
+
else
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.inRangeMaxDays?(start_day, end_day)
|
58
|
+
if end_day - start_day <= MAX_DAYS
|
59
|
+
return true
|
60
|
+
else
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.checkLeapYear(year)
|
66
|
+
year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) ? true : false
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.makeDateFromString(day, month, year)
|
70
|
+
date = Time.new(year.to_i, month.to_i, day.to_i)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.compareDate(date1, date2)
|
74
|
+
date2 >= date1 ? true : false
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.getIndonesianMonth(month)
|
78
|
+
month = month.to_i
|
79
|
+
case month
|
80
|
+
when 1
|
81
|
+
'Januari'
|
82
|
+
when 2
|
83
|
+
'Februari'
|
84
|
+
when 3
|
85
|
+
'Maret'
|
86
|
+
when 4
|
87
|
+
'April'
|
88
|
+
when 5
|
89
|
+
'Mei'
|
90
|
+
when 6
|
91
|
+
'Juni'
|
92
|
+
when 7
|
93
|
+
'Juli'
|
94
|
+
when 8
|
95
|
+
'Agustus'
|
96
|
+
when 9
|
97
|
+
'September'
|
98
|
+
when 10
|
99
|
+
'Oktober'
|
100
|
+
when 11
|
101
|
+
'November'
|
102
|
+
when 12
|
103
|
+
'Desember'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.checkDayMonth(day, month, year=nil)
|
108
|
+
day = day.to_i
|
109
|
+
month = month.to_i
|
110
|
+
|
111
|
+
if !MONTHS.include?(month)
|
112
|
+
return false
|
113
|
+
end
|
114
|
+
year ||= Time.now.year
|
115
|
+
if checkLeapYear(year)
|
116
|
+
if month == 2
|
117
|
+
total_days = 29
|
118
|
+
end
|
119
|
+
else
|
120
|
+
total_days = DAYS[month-1]
|
121
|
+
end
|
122
|
+
|
123
|
+
if day > 0 and day <= total_days
|
124
|
+
return true
|
125
|
+
else
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bcaparser/regex_check'
|
2
|
+
|
3
|
+
module BcaParser
|
4
|
+
describe "Regex check" do
|
5
|
+
|
6
|
+
it "successfuly check the date month regex" do
|
7
|
+
datemonth = "05/92"
|
8
|
+
expect(RegexCheck.checkUserDate(datemonth)).to eq(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "is an invalid date" do
|
12
|
+
datemonth = "xx/xx"
|
13
|
+
expect(RegexCheck.checkUserDate(datemonth)).to eq(false)
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'bcaparser/time_keeper'
|
2
|
+
|
3
|
+
module BcaParser
|
4
|
+
describe "TimeKeeper" do
|
5
|
+
|
6
|
+
it "successfuly check if a year is a leap year" do
|
7
|
+
year = 2000
|
8
|
+
expect(TimeKeeper.checkLeapYear(year)).to eq(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "is invalid leap year if it is divisible by 4 and 100 but not 400" do
|
12
|
+
year = 2100
|
13
|
+
expect(TimeKeeper.checkLeapYear(year)).to eq(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "is valid leap year if it is divisible by 4, but not divisible by 100 and 400" do
|
17
|
+
year = 2004
|
18
|
+
expect(TimeKeeper.checkLeapYear(year)).to eq(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "is a invalid month" do
|
22
|
+
month = 18
|
23
|
+
day = 1
|
24
|
+
expect(TimeKeeper.checkDayMonth(day, month)).to eq(false)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "is a valid month" do
|
28
|
+
month = 12
|
29
|
+
day = 1
|
30
|
+
expect(TimeKeeper.checkDayMonth(day, month)).to eq(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "is a valid date" do
|
34
|
+
month = 5
|
35
|
+
day = 31
|
36
|
+
expect(TimeKeeper.checkDayMonth(day, month)).to eq(true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "is an invalid date" do
|
40
|
+
month = 2
|
41
|
+
day = 29
|
42
|
+
year = 2014
|
43
|
+
|
44
|
+
expect(TimeKeeper.checkDayMonth(day, month, year)).to eq(false)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "valid if end date is bigger than start date" do
|
48
|
+
start_day = Time.new(2014, 1, 1)
|
49
|
+
end_day = Time.new(2014, 1, 25)
|
50
|
+
expect(TimeKeeper.compareDate(start_day, end_day)).to eq(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "is valid if it is in the range of 31 days between start and end date" do
|
54
|
+
start_day = "1"
|
55
|
+
start_month = "1"
|
56
|
+
end_day = "25"
|
57
|
+
end_month = "1"
|
58
|
+
expect(TimeKeeper.checkDateForBalance(start_day, start_month, end_day, end_month)).to eq(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "is invalid if it is outside the range of 31 days between start and end date" do
|
62
|
+
start_day = "1"
|
63
|
+
start_month = "2"
|
64
|
+
end_day = "25"
|
65
|
+
end_month = "5"
|
66
|
+
expect(TimeKeeper.checkDateForBalance(start_day, start_month, end_day, end_month)).to eq(false)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bcaparser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alfian Losari
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: watir
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: spreadsheet
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.19'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.19'
|
83
|
+
description: Gem ini berfungsi untuk automatisasi dalam mengambil informasi saldo
|
84
|
+
dan mutasi rekening Bank BCA anda secara mudah, cepat, dan efisien. Dengan menggunakan
|
85
|
+
command line anda dapat dengan mudah melakukan automatisasi untuk pengambilan data
|
86
|
+
berupa informasi saldo, mutasi transaksi harian, mutasi transaksi bulanan. Data
|
87
|
+
kemudia dapat ditampilkan maupun disimpan ke dalam bentuk CSV maupun Excel. Gem
|
88
|
+
ini tidak mengambil data anda sama sekali, karena gem ini pada dasarnya bekerja
|
89
|
+
dengan melakukan automatisasi pada browser anda untuk melakukan hal-hal yang biasa
|
90
|
+
anda lakukan dengan mengklik pada browser untuk melakukan transaksi. Dibutuhkan
|
91
|
+
browser Firefox terinstall pada sistem anda untuk menggunakan gem ini.
|
92
|
+
email: alfianlosari@gmail.com
|
93
|
+
executables:
|
94
|
+
- bcaparser
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- LICENSE
|
99
|
+
- README
|
100
|
+
- bin/bcaparser
|
101
|
+
- lib/bcaparser/account.rb
|
102
|
+
- lib/bcaparser/parser.rb
|
103
|
+
- lib/bcaparser/regex_check.rb
|
104
|
+
- lib/bcaparser/time_keeper.rb
|
105
|
+
- lib/bcaparser/transaction.rb
|
106
|
+
- spec/regex_check_spec.rb
|
107
|
+
- spec/time_keeper_spec.rb
|
108
|
+
homepage: https://www.linkedin.com/pub/alfian-lo/48/579/943
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '2.0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.2.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Parsing BCA Balance and Transactions
|
132
|
+
test_files:
|
133
|
+
- spec/regex_check_spec.rb
|
134
|
+
- spec/time_keeper_spec.rb
|