Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | 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 |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e176864222a3cf5a1d44ab1ba7b99bc2 |
User & Date: | atomicules 2016-01-06 13:27:07 |
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 | |
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 | |
2015-10-19
| ||
21:33 | Ensure all extraneous spaces are removed check-in: cf683f4151 user: atomicules tags: trunk | |
Changes to smile.rb.
︙ | ︙ | |||
80 81 82 83 84 85 86 | def recent_transactions #requires page = logon_bulletin page = @a.click(page.link_with(:text => "current account")) get_transactions(page) doc = Nokogiri::HTML(page.body) | | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | def recent_transactions #requires page = logon_bulletin page = @a.click(page.link_with(:text => "current account")) get_transactions(page) doc = Nokogiri::HTML(page.body) #Any trailiing minus needs to be moved to before the number, but any trailing plus needs to be removed, don't think this can be done in one gsub. @balance = doc.xpath("//td[@class='recentTransactionsAccountData']/table/tr[2]/td[2]").text.strip.gsub(/(£)(\d+\.\d+)(\-)/, "\\1\\3\\2").gsub(/\+/, "") @available = doc.xpath("//td[@class='recentTransactionsAccountData']/table/tr[3]/td[2]").text.strip #Need to return this page end def previous_statements |
︙ | ︙ | |||
139 140 141 142 143 144 145 | 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*\t"+transaction[:name]+"\n" if transaction[:debit].include?("£") | > | | > | 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 | 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*\t"+transaction[:name]+"\n" if transaction[:debit].include?("£") #Quote all commodities because having ledger utf-8 trouble amount = transaction[:debit].gsub(/£/, "\"£\"-") type = "Expenses:" else amount = transaction[:credit].gsub(/£/, "\"£\"") type = "Income:" end if idx == @transactions.length-1 #Include balance assertion at the end. balance_assertion = "\t= "+@balance balance_assertion = balance_assertion.gsub(/£/, "\"£\"") 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" |
︙ | ︙ |