Smile Bank to Ledger

Check-in [ce95ff0dde]
Login

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

Overview
Comment:Last tweaks I'd made. Commit for reference

I'd forgotten to commit these. Committing for reference since none of this
works anymore. Only option is to use a webbrowser and download the csv. Will be
changing this into a CSV parser. Maybe. Might even just do that in Vim.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | old-smile-site
Files: files | file ages | folders
SHA1: ce95ff0dde6a73b8020bbdda1ea9280f0cc2cf91
User & Date: atomicules 2016-09-04 14:15:22
Context
2016-10-02
12:30
Convert to csv parsing only

Really I don't need all that class stuff in there anymore, but I thought I
would retain and re-use what I could. Now it simply parses the csv file that
Smile provide for download and converts that to Ledger format. Sob-sob - I
loved being able to logon on the command line and download transactions. check-in: 4ca78e73c4 user: atomicules tags: trunk

2016-09-04
14:15
Last tweaks I'd made. Commit for reference

I'd forgotten to commit these. Committing for reference since none of this
works anymore. Only option is to use a webbrowser and download the csv. Will be
changing this into a CSV parser. Maybe. Might even just do that in Vim. check-in: ce95ff0dde user: atomicules tags: old-smile-site, trunk

2016-01-06
13:27
Fix for negative balances

Sob. Sob. Not that I ever want to see them though.

I'd inadvertently assumed I'd only ever see a positive balance. Need to regexp
to get the negative that Smile put at the end of the balance and stick that in
the right balance, but only if a negative - it seems Ledger doesn't understand
a plus sign in front of numbers. check-in: e176864222 user: atomicules tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to smile.rb.

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122


123
124
125
126
127
128
129
130

131
132
133
134
135
136
137
			page = @a.click(page.link_with(:text => "previous statement page"))
		end
	end


	def get_transactions(page)
		doc = Nokogiri::HTML(page.body)
		#Look for summaryTable
		rows = doc.xpath("//table[@class='summaryTable']//tr")
		#Skip first row (table headers, ths)
		rows = rows[1..-1]
		transactions = []
		rows.each do |row|
			#Skip last row, maybe
			unless row.elements.length == 1


				#Might as well parse date here
				date = Date.parse(row.elements[0].text.strip)
				name = row.elements[1].text.strip
				credit = row.elements[2].text.strip
				debit = row.elements[3].text.strip
				unless name.include?("BROUGHT FORWARD")
					transactions << { :date => date, :name => name, :credit => credit, :debit => debit}
				end

			end
		end	
		#Sort in order of newest date first so can add on
		@transactions += transactions.sort { | t1, t2 | t2[:date] <=> t1[:date] }
	end









|
|





|
>
>








>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
			page = @a.click(page.link_with(:text => "previous statement page"))
		end
	end


	def get_transactions(page)
		doc = Nokogiri::HTML(page.body)
		#Look for summaryTable, sometimes can be two, get the last
		rows = doc.xpath("//table[@class='summaryTable'][position()=last()]//tr")
		#Skip first row (table headers, ths)
		rows = rows[1..-1]
		transactions = []
		rows.each do |row|
			#Skip last row, maybe
			#Also, sometimes bugs or invalid markup and so even though last row does have just one td doesn't get reported that way
			#So use begin/rescue
			begin
				#Might as well parse date here
				date = Date.parse(row.elements[0].text.strip)
				name = row.elements[1].text.strip
				credit = row.elements[2].text.strip
				debit = row.elements[3].text.strip
				unless name.include?("BROUGHT FORWARD")
					transactions << { :date => date, :name => name, :credit => credit, :debit => debit}
				end
			rescue
			end
		end	
		#Sort in order of newest date first so can add on
		@transactions += transactions.sort { | t1, t2 | t2[:date] <=> t1[:date] }
	end