Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated buxfer update code to reflect the name changes I made yesterday

  • Loading branch information...
commit b260491aa8bf3badd7e1b018bd8376df47cc4a3d 1 parent f63ffcd
Eric Mill konklone authored
Showing with 15 additions and 15 deletions.
  1. +2 −2 updater/buxfer.yml.example
  2. +13 −13 updater/updater.rb
4 updater/buxfer.yml.example
View
@@ -17,6 +17,6 @@
# Remember to put the negative sign on a debt
:manual:
- :local_id:
- :balance:
+ :amount:
- :local_id:
- :balance:
+ :amount:
26 updater/updater.rb
View
@@ -24,21 +24,21 @@ def update_accounts!
map = maps.find {|m| m[:remote_id] == remote['id']}
if map
account = user.accounts.find map[:local_id]
- balance = (remote['balance'] * 100).to_i # convert to pennies
- balance *= -1 if account.debts?
+ amount = (remote['balance'] * 100).to_i # convert to pennies
+ amount *= -1 if account.debts?
- worth += balance
- update_account! account, balance
+ worth += amount
+ update_account! account, amount
end
end
# the manual accounts that Buxfer doesn't support
manual.each do |map|
account = user.accounts.find map[:local_id]
- balance = map[:balance]
+ amount = map[:amount]
- worth += balance
- update_account! account, map[:balance]
+ worth += amount
+ update_account! account, amount
end
# the net worth of it all
@@ -47,11 +47,11 @@ def update_accounts!
end
# idempotent - will overwrite balance if one exists for today
- def update_account!(account, balance)
- day = account.days.find_or_initialize_by_date_of Time.now.to_date
- day.user_id = user.id
- day.balance = balance
- day.save!
- puts "Updated #{account.name} with balance of #{balance}, for #{day.date_of}."
+ def update_account!(account, amount)
+ balance = account.balances.find_or_initialize_by_date_of Time.now.to_date
+ balance.user_id = user.id
+ balance.amount = amount
+ balance.save!
+ puts "Updated #{account.name} with balance of #{amount}, for #{balance.date_of}."
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.