Smile Bank to Ledger

Check-in [b65738a784]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add basics of getting previous statements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b65738a784a4d14c10944f9c4b94777c90a098e8
User & Date: atomicules 2015-07-02 20:54:34
Context
2015-07-04
11:21
Build it into a proper script I'm not entirely sure whether a class structure is appropriate for this. At the very least because I'm only ever creating one of them, but also because although it's nice having the separate methods for each stage of the logon process, etc, they don't really make sense, and cna't be used, as standalone methods. I'm also not sure about the use of instance variables. Splitting things out into methods almost requires them as passing arguments would be a bit clumsy, but then it is almost like using global variables. So, all in all, I've attempted to make it more Ruby-ish, but I think I've failed. - I'd got credits and debits the wrong way round - Adds in dealing with memorable date logon details check-in: 5454406454 user: atomicules tags: trunk
2015-07-02
20:54
Add basics of getting previous statements check-in: b65738a784 user: atomicules tags: trunk
2015-07-01
20:26
Check for Bulletin Board sumbit check-in: 3b0a9cbf4e user: atomicules tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to smile.rb.

50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71



72
73




74
75
76
77
78
79
80
#array of hashes?
transactions = []
#Skip first row (ths)
rows = rows[1..-1]
rows.each do |row|
	#Skip last row, maybe
	unless row.elements.length == 1

		date = row.elements[0].text
		name = row.elements[1].text
		credit = row.elements[2].text
		debit = row.elements[3].text
		transactions << { :date => date, :name => name, :credit => credit, :debit => debit}
	end
end	

#TODO: Need to figure out a way to get input for number of previous pages required. Well, a good way, perhaps limit by a date?
puts "Enter date back to fetch transactions to"
#Assume ISO thingy format
date_limit = gets.strip #.convert_to_date

#Previous statements
page = a.click(page.link_with(:text => "previous statements"))




#TODO: Then need to click the top most page and go back through each page.





#Write transactions out 
#TODO: Might need to sort by date

File.open("smile.dat", "w") do |file|
	transactions.each do |transaction|
		file << Date.parse(transaction[:date]).strftime("%Y/%m/%d")+"\t"+transaction[:name]+"\n"







>










|




>
>
>

<
>
>
>
>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85
86
87
#array of hashes?
transactions = []
#Skip first row (ths)
rows = rows[1..-1]
rows.each do |row|
	#Skip last row, maybe
	unless row.elements.length == 1
		#TODO: Need to skip BROUGHT FORWARD as well for previous item pages
		date = row.elements[0].text
		name = row.elements[1].text
		credit = row.elements[2].text
		debit = row.elements[3].text
		transactions << { :date => date, :name => name, :credit => credit, :debit => debit}
	end
end	

#TODO: Need to figure out a way to get input for number of previous pages required. Well, a good way, perhaps limit by a date?
puts "Enter date back to fetch transactions to"
#Assume ISO thingy format?
date_limit = gets.strip #.convert_to_date

#Previous statements
page = a.click(page.link_with(:text => "previous statements"))
#Get first page of previous statements
page = a.click(page.links_with(:href => %r{getDomestic} )[0])
#TODO: get transactions in the same way


#then click back
#TODO: This needs to be in a loop
page = a.click(page.link_with(:text => "previous statement page"))
#Need someway of stopping if I call the above in a loop. So probably check dates.

#Write transactions out 
#TODO: Might need to sort by date

File.open("smile.dat", "w") do |file|
	transactions.each do |transaction|
		file << Date.parse(transaction[:date]).strftime("%Y/%m/%d")+"\t"+transaction[:name]+"\n"