Smile Bank to Ledger

Check-in [04aa81bd2e]
Login

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

Overview
Comment:Include balance as balance assertion on last transaction instead of as comment
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 04aa81bd2e7a389c8b0b104383fcc13758d62b16
User & Date: atomicules 2015-07-21 15:30:15
Context
2015-07-22
22:03
Mark all these transactions as cleared check-in: ad57653104 user: atomicules tags: trunk
2015-07-21
15:30
Include balance as balance assertion on last transaction instead of as comment check-in: 04aa81bd2e user: atomicules tags: trunk
09:26
Report out available balance as well check-in: dae330504e user: atomicules tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to smile.rb.

76
77
78
79
80
81
82

83
84
85
86
87
88
89
90
...
127
128
129
130
131
132
133

134
135
136
137
138
139
140
141
142
143
144
145




146
147
148
149
150
151
152
153
154
155
156
157
158

	def recent_transactions
		#requires
		page = logon_bulletin
		page = @a.click(page.link_with(:text => "current account"))
		get_transactions(page)
		doc = Nokogiri::HTML(page.body)

		@balance = doc.xpath("//td[@class='recentTransactionsAccountData']/table/tr[2]/td[2]").text.strip
		@available = doc.xpath("//td[@class='recentTransactionsAccountData']/table/tr[3]/td[2]").text.strip
		#Need to return this
		page
	end


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


	def write_ledger

		File.open("smile.dat", "w") do |file|
			#Reverse for writing out
			@transactions.reverse!
			@transactions.each do |transaction|
				file << transaction[:date].strftime("%Y/%m/%d")+"\t"+transaction[:name]+"\n"
				if transaction[:debit].include?("£")
					amount = transaction[:debit].gsub(/£/, "£-")
					type = "Expenses:"
				else
					amount = transaction[:credit]
					type = "Income:"
				end




				file << "\t"+"Assets:Smile:Current"+"\t"+amount+"\n"
				file << "\t"+type+"\n"
				file << "\n"
			end
			#Write out account balance as a comment at the end
			file << "#Balance: "+@balance+"\n"
			file << "#Available: "+@available+"\n"
		end
	end

	private :logon_start
	private :logon_passcode
	private :logon_other







>
|







 







>



|








>
>
>
>
|




<







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163

	def recent_transactions
		#requires
		page = logon_bulletin
		page = @a.click(page.link_with(:text => "current account"))
		get_transactions(page)
		doc = Nokogiri::HTML(page.body)
		#Remove any trailing plus and minus on actual balance so can use as balance assertion
		@balance = doc.xpath("//td[@class='recentTransactionsAccountData']/table/tr[2]/td[2]").text.strip.gsub(/\+|\-/, "")
		@available = doc.xpath("//td[@class='recentTransactionsAccountData']/table/tr[3]/td[2]").text.strip
		#Need to return this
		page
	end


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


	def write_ledger
		balance_assertion = ""
		File.open("smile.dat", "w") do |file|
			#Reverse for writing out
			@transactions.reverse!
			@transactions.each.with_index do |transaction, idx|
				file << transaction[:date].strftime("%Y/%m/%d")+"\t"+transaction[:name]+"\n"
				if transaction[:debit].include?("£")
					amount = transaction[:debit].gsub(/£/, "£-")
					type = "Expenses:"
				else
					amount = transaction[:credit]
					type = "Income:"
				end
				if idx == @transactions.length-1
					#Include balance assertion at the end.
					balance_assertion = "\t= "+@balance
				end
				file << "\t"+"Assets:Smile:Current"+"\t"+amount+balance_assertion+"\n"
				file << "\t"+type+"\n"
				file << "\n"
			end
			#Write out account balance as a comment at the end

			file << "#Available: "+@available+"\n"
		end
	end

	private :logon_start
	private :logon_passcode
	private :logon_other