rodger 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/lib/rodger.rb +123 -0
- data/lib/rodger/version.rb +3 -0
- data/rodger.gemspec +27 -0
- data/spec/demo.ledger.txt +579 -0
- data/spec/lib/rodger_spec.rb +333 -0
- data/spec/rodger_spec.rb +333 -0
- data/spec/spec.dat +8 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f37dadd46ae840fa1bac37ffaed7a232daa5d8f3
|
4
|
+
data.tar.gz: 42c957b10e2230165a5425170e93fc498887e893
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87aea5981751d8be2518e80fec5ee9884c1a1d7e52617039aba6429dfaafdddaa85d842d3bee7652857dff3bd825ec2ae6356ef9f6a9d46586fd80bb0feb84ca
|
7
|
+
data.tar.gz: 9d8659b282ac9f650954b8a4a55ff727098cb7c1a9e184087a8c002e14994e80441ddbf5def350aa763742b1d94dc0e2648e463a2d6d59c2d16f8043c8586071
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format nested
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 svs
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Rodger
|
2
|
+
|
3
|
+
Rodger is a Ruby interface to [John Wiegley's ledger-cli program](http://www.ledger-cli.org/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rodger'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rodger
|
18
|
+
|
19
|
+
### It is important to have the ledger-cli binary on your system.
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
|
25
|
+
@r = Rodger.new("accounts.cli")
|
26
|
+
@r.accounts # A hash with the accounts in it
|
27
|
+
@r.balance["Liabilities:Credit-Card:VISA"] # => The balance of a particular account
|
28
|
+
```
|
29
|
+
|
30
|
+
Check the specs for more usage examples
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rodger.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
require "rodger/version"
|
3
|
+
|
4
|
+
class AccountTree < Hash
|
5
|
+
# AccountTree is just a hash, but we make a separate class of it
|
6
|
+
# _ to not pollute the Hash class with our Hashie extensions
|
7
|
+
# - incase we want to funk it up later
|
8
|
+
# - to give us some type information
|
9
|
+
|
10
|
+
include Hashie::Extensions::MergeInitializer
|
11
|
+
|
12
|
+
|
13
|
+
# deep merge merges two AccountTrees such that their sub-account-trees are merged as well
|
14
|
+
# frankly, I can not now work out why this code works but the specs pass and so....
|
15
|
+
def deep_merge (h)
|
16
|
+
self.merge(h) do |k, old, new|
|
17
|
+
begin
|
18
|
+
AccountTree.new(old).deep_merge(AccountTree.new(new))
|
19
|
+
rescue
|
20
|
+
new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# returns true if an account has no sub accounts
|
26
|
+
def leaf?
|
27
|
+
(keys - [:name, :balance]).empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class Rodger
|
33
|
+
|
34
|
+
# This class provides a Ruby API to ledger
|
35
|
+
|
36
|
+
# WARNING - Currently only supports single currency
|
37
|
+
|
38
|
+
[:filename, :report_type, :current, :begin, :end, :period, :period_sort, :cleared, :dc, :uncleared,
|
39
|
+
:real, :actual, :related, :budget, :add_budget, :unbudgeted, :forecast, :limit, :amount, :total, :ledger].each do |a|
|
40
|
+
attr_accessor a
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initialize with the name of the filename and an optional path to the ledger binary
|
44
|
+
#
|
45
|
+
# options is a hash like
|
46
|
+
# :file => path to the ledger file
|
47
|
+
# :bin => path to the ledger binary. Defaults to 'ledger' so not required if ledger is in your path
|
48
|
+
def initialize(options = {})
|
49
|
+
@filename = options[:file]
|
50
|
+
@ledger = options[:bin] || 'ledger'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Public: Builds a AccountTree of the accounts as reported by ledger. It populates each account with the canonical name and balance of the account
|
54
|
+
# returns a Hash like {"Assets" => {:name => "Assets", :balance => <balance>, "Fixed Assets" => {:name => "Assets:FixedAssets", :bal...}}}
|
55
|
+
def accounts
|
56
|
+
ahash = (cmd "accounts | sort").split("\n")
|
57
|
+
ahash.reduce(AccountTree.new) do |s, h|
|
58
|
+
a = recurse_accounts(h.split(":")) # recursion is awsm!
|
59
|
+
s.deep_merge(a)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Public: Returns a hash of all the account names and their balances. Is the "flat" version of the accounts tree above
|
64
|
+
# however, it does not include any accounts which do not have any journal entries in them.
|
65
|
+
def balances
|
66
|
+
return @balances_hash if @balances_hash
|
67
|
+
ledger_balances = cmd 'bal --balance-format "%A | %(display_total)\n"'
|
68
|
+
@balances_hash = Hash[*(ledger_balances.split("\n")).map{|line| parse_account_line(line)}.flatten]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Public: Returns the account balance for a given account on a given date
|
72
|
+
# Need to give the full name of the account, not a regexp to match against
|
73
|
+
def balance(account)
|
74
|
+
return balances[account] || infer_balance(account) # need to infer the balance if the account is not in ledger's output
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# Builds the command using the provided switches and any extra arguments used here
|
80
|
+
def cmd(extra_args)
|
81
|
+
`#{@ledger} -f #{@filename} #{extra_args}`
|
82
|
+
end
|
83
|
+
|
84
|
+
# given an array like [Assets][FixedAssets][Furniture], returns a Hash like
|
85
|
+
# {"Assets" => {:name => "Assets", :balance => <balance>, "FixedAssets" => {...}...}...}
|
86
|
+
# by querying the given ledger for balances, etc.
|
87
|
+
def recurse_accounts(accounts_array, prenom = "")
|
88
|
+
result = AccountTree.new
|
89
|
+
prenom = prenom.empty? ? accounts_array[0] : "#{prenom}:#{accounts_array[0]}"
|
90
|
+
if accounts_array.class == Array
|
91
|
+
if accounts_array.size == 1
|
92
|
+
result[accounts_array[0]] = AccountTree.new(:name => prenom, :balance => balance(prenom))
|
93
|
+
else
|
94
|
+
r = recurse_accounts(accounts_array[1..-1], prenom)
|
95
|
+
result[accounts_array[0]] = r.merge(:name => prenom, :balance => balance(prenom))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
result
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
#Private: takes a line from ledger balance output and returns the account, amount and currency
|
103
|
+
def parse_account_line(line)
|
104
|
+
account = line.split("|")[0].strip rescue nil
|
105
|
+
amount = line.scan(/\-{0,1}\d+[\.\d+]*/)[0].to_f rescue nil
|
106
|
+
currency = line.scan(/[A-Z]{3,7}/)[-1] rescue nil
|
107
|
+
[account,{:amount => amount, :currency => currency}]
|
108
|
+
end
|
109
|
+
|
110
|
+
# If the given account is not found in the balance report, we have to infer the balance from the subaccounts
|
111
|
+
# Please refer to the specs for more information
|
112
|
+
#
|
113
|
+
# account is an account name
|
114
|
+
def infer_balance(account)
|
115
|
+
sub_accounts = balances.keys.compact.map{|k| k.match(/#{account}:[^:]*/)}.compact
|
116
|
+
relevant_accounts = sub_accounts.map(&:to_s).uniq
|
117
|
+
relevant_account_balances = relevant_accounts.map{|a| balance(a)}
|
118
|
+
balance = relevant_account_balances.reduce({:amount => 0, :currency => nil}){|s,h| {:amount => s[:amount] + h[:amount], :currency => h[:currency]}}
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
end
|
data/rodger.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rodger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rodger"
|
8
|
+
spec.version = Rodger::VERSION
|
9
|
+
spec.authors = ["svs"]
|
10
|
+
spec.email = ["svs@svs.io"]
|
11
|
+
spec.description = %q{Read ledger-cli files with ease in Ruby}
|
12
|
+
spec.summary = %q{Rodger is a ruby API for getting info out of files that can be parsed by ledger-cli}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "hashie"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,579 @@
|
|
1
|
+
;;; -*- mode: ledger; coding: utf-8; -*-
|
2
|
+
;;;
|
3
|
+
;;; This is an example/demo file, with some example accounts and
|
4
|
+
;;; some example transactions. A real-life Ledger file has a lot
|
5
|
+
;;; more transactions in it, and possibly a very different set
|
6
|
+
;;; of accounts; feel free to define your own and to change
|
7
|
+
;;; everything in here if you use this as a template. You can be
|
8
|
+
;;; creative, because all the account categories and commodities
|
9
|
+
;;; are entirely generic. (More comments are sprinkled below.)
|
10
|
+
;;;
|
11
|
+
;;; The order in which the transactions are declared does not
|
12
|
+
;;; matter at all... personally I like to organize transactions
|
13
|
+
;;; in chronological order, within sections that are
|
14
|
+
;;; more-or-less by account. I normally pretty much keep them in
|
15
|
+
;;; the order that the converted OFX file presents them. Here
|
16
|
+
;;; however, I've ordered the transactions for better clarity of
|
17
|
+
;;; presentation, since this is a file with sample transactions.
|
18
|
+
|
19
|
+
|
20
|
+
;;;;; Initialization
|
21
|
+
|
22
|
+
|
23
|
+
;;; Declaration of Accounts.
|
24
|
+
|
25
|
+
;;; Here you can declare a list of valid accounts, and
|
26
|
+
;;; optionally, a constraint on which kind of commodity they are
|
27
|
+
;;; allowed to hold (helps you track down mistakes).
|
28
|
+
;;;
|
29
|
+
;;; Note that
|
30
|
+
;;;
|
31
|
+
;;; - the system supports any currencies, and works with
|
32
|
+
;;; multiple commodities in the same Ledger.
|
33
|
+
;;;
|
34
|
+
;;; - No distinction is made between currency commodities (e.g.
|
35
|
+
;;; USD, EUR, USD) and investment commodities (e.g. GOOG,
|
36
|
+
;;; AAPL, MSFT).
|
37
|
+
;;;
|
38
|
+
;;; - The Assets, Liabilities, Equity, Income, Expenses
|
39
|
+
;;; categories are not special; they are simply a convention;
|
40
|
+
;;; be creative if you like. There are really only two kinds
|
41
|
+
;;; of accounts: debit accounts and credit accounts, and the
|
42
|
+
;;; type is only used for reporting (maybe).
|
43
|
+
|
44
|
+
@defaccount De Assets:Current:Cash
|
45
|
+
@defaccount De Assets:Current:BestBank:Checking USD
|
46
|
+
@defaccount De Assets:Current:BestBank:Savings USD
|
47
|
+
;@defaccount De Assets:Fixed:Home USD
|
48
|
+
@defaccount De Assets:Investments:UTrade:Account USD
|
49
|
+
@defaccount De Assets:Investments:UTrade:Account:AAPL AAPL
|
50
|
+
@defaccount De Assets:Investments:UTrade:Account:EWJ EWJ
|
51
|
+
;@defaccount De Assets:Loans
|
52
|
+
@defaccount De Assets:AccountsReceivable
|
53
|
+
|
54
|
+
;@defaccount Cr Liabilities:AccountsPayable
|
55
|
+
@defaccount Cr Liabilities:BestBank:Mortgage:Loan USD
|
56
|
+
@defaccount Cr Liabilities:Credit-Card:VISA USD
|
57
|
+
@defaccount Cr Liabilities:Condo-Management USD
|
58
|
+
|
59
|
+
@defaccount Cr Equity:Opening-Balances
|
60
|
+
|
61
|
+
@defaccount Cr Income:Investments:Interest:Checking
|
62
|
+
@defaccount Cr Income:Investments:Interest:Savings
|
63
|
+
@defaccount Cr Income:Investments:Dividends
|
64
|
+
@defaccount Cr Income:Investments:Capital-Gains
|
65
|
+
@defaccount Cr Income:Salary:AcmeCo
|
66
|
+
|
67
|
+
@defaccount De Expenses:Financial:Fees
|
68
|
+
@defaccount De Expenses:Financial:Commissions
|
69
|
+
@defaccount De Expenses:Insurance:Life
|
70
|
+
@defaccount De Expenses:Food:Restaurant
|
71
|
+
@defaccount De Expenses:Food:Grocery
|
72
|
+
@defaccount De Expenses:Food:Alcool
|
73
|
+
@defaccount De Expenses:Communications:Phone
|
74
|
+
@defaccount De Expenses:Communications:Mail
|
75
|
+
;@defaccount De Expenses:Transportation:Parking
|
76
|
+
@defaccount De Expenses:Transportation:Taxi
|
77
|
+
;@defaccount De Expenses:Transportation:Trains
|
78
|
+
;@defaccount De Expenses:Transportation:PublicTrans
|
79
|
+
;@defaccount De Expenses:Taxes:US-State-California USD
|
80
|
+
@defaccount De Expenses:Taxes:US-Federal USD
|
81
|
+
@defaccount De Expenses:Govt-Services USD
|
82
|
+
@defaccount De Expenses:Clothes
|
83
|
+
@defaccount De Expenses:Car:Gas
|
84
|
+
@defaccount De Expenses:Sports
|
85
|
+
@defaccount De Expenses:Sports:Gear
|
86
|
+
@defaccount De Expenses:Fun:Movie
|
87
|
+
;@defaccount De Expenses:Fun:Museum
|
88
|
+
@defaccount De Expenses:Books
|
89
|
+
;@defaccount De Expenses:Travel:Flights
|
90
|
+
;@defaccount De Expenses:Travel:Accomodation
|
91
|
+
;@defaccount De Expenses:Toys:Photography
|
92
|
+
;@defaccount De Expenses:Toys:Computer
|
93
|
+
;@defaccount De Expenses:Office-Supplies
|
94
|
+
@defaccount De Expenses:Medical
|
95
|
+
@defaccount De Expenses:Charity
|
96
|
+
;@defaccount De Expenses:Misc
|
97
|
+
;@defaccount De Expenses:Home:Repair
|
98
|
+
;@defaccount De Expenses:Home:Maintenance
|
99
|
+
;@defaccount De Expenses:Home:Taxes:Municipal
|
100
|
+
;@defaccount De Expenses:Home:Taxes:School
|
101
|
+
;@defaccount De Expenses:Home:Insurance
|
102
|
+
;@defaccount De Expenses:Home:Monthly
|
103
|
+
;@defaccount De Expenses:Home:Monthly:Internet
|
104
|
+
@defaccount De Expenses:Home:Monthly:Condo-Fees
|
105
|
+
;@defaccount De Expenses:Home:Monthly:Electricity
|
106
|
+
@defaccount De Expenses:Home:Monthly:Loan-Interest
|
107
|
+
;@defaccount De Expenses:Home:Monthly:Water
|
108
|
+
;@defaccount De Expenses:Home:Acquisition:Furniture
|
109
|
+
;@defaccount De Expenses:Home:Acquisition:Renovations
|
110
|
+
;@defaccount De Expenses:Home:Acquisition:Legal
|
111
|
+
;@defaccount De Expenses:Home:Acquisition:Inspection
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
;;; You can provide mappings from the account numbers ("account
|
116
|
+
;;; ids") that are normally found in OFX files that the
|
117
|
+
;;; banks/brokers provide, mapping to account names in this
|
118
|
+
;;; Ledger file. This way, a script that converts the OFX into
|
119
|
+
;;; Ledger-compatible syntax is able to automatically figure out
|
120
|
+
;;; the right account names.
|
121
|
+
|
122
|
+
;;; Account number mappings.
|
123
|
+
@var ofx accid 123456789012 Assets:Current:BestBank:Checking
|
124
|
+
@var ofx accid 123456789012 Assets:Current:BestBank:Savings
|
125
|
+
@var ofx accid 1234567890 Liabilities:BestBank:Mortgage:Loan
|
126
|
+
@var ofx accid 1234567890123456 Liabilities:Credit-Card:VISA
|
127
|
+
@var ofx accid 1234567890 Assets:Investments:UTrade:Account
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
;;;;; Assets:Current:BestBank:Checking
|
137
|
+
|
138
|
+
;; This entry tells the software to automatically insert an
|
139
|
+
;; entry at this date, of the amount required to fulfill the
|
140
|
+
;; next @check directive (chronologically) in the account (for
|
141
|
+
;; all commodities present). If the required amount is 0, no
|
142
|
+
;; entry is added.
|
143
|
+
@pad 2007-12-31 Assets:Current:BestBank:Checking Equity:Opening-Balances
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
;; A check deposit, e.g. depositing a government check.
|
148
|
+
2008-01-05 * GST CANADA | Deposit from govt for consumer tax rebate
|
149
|
+
Assets:Current:BestBank:Checking 77.76 USD
|
150
|
+
Expenses:Taxes:US-Federal
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
;; This is how salary direct deposit entries might show up
|
155
|
+
;; within the checking account section. Note how the salaries
|
156
|
+
;; are negative amounts... that's because Income is a credit
|
157
|
+
;; account category, and the numbers there are negative (you can
|
158
|
+
;; interpret this as the "amount of work-dollars that you took
|
159
|
+
;; from society and placed into your account").
|
160
|
+
|
161
|
+
2008-01-10 * ACME | Salary paid from employer
|
162
|
+
Assets:Current:BestBank:Checking 2000.00 USD
|
163
|
+
Income:Salary:AcmeCo -2000 USD
|
164
|
+
|
165
|
+
2008-01-25 * ACME | Salary paid from employer
|
166
|
+
Assets:Current:BestBank:Checking 2000.00 USD
|
167
|
+
Income:Salary:AcmeCo
|
168
|
+
|
169
|
+
2008-02-10 * ACME | Salary paid from employer
|
170
|
+
Assets:Current:BestBank:Checking 2000.00 USD
|
171
|
+
Income:Salary:AcmeCo
|
172
|
+
|
173
|
+
2008-02-25 * ACME | Salary paid from employer
|
174
|
+
Assets:Current:BestBank:Checking 2000.00 USD
|
175
|
+
Income:Salary:AcmeCo
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
;; Withdrawal from another bank's ATM machine (with fees).
|
180
|
+
2008-01-12 * ATM withdrawal - 00044242
|
181
|
+
Assets:Current:BestBank:Checking -301.50 USD
|
182
|
+
Expenses:Financial:Fees 1.50 USD
|
183
|
+
Assets:Current:Cash
|
184
|
+
|
185
|
+
;; ATM withdrawal (without fees).
|
186
|
+
2008-01-30 * ATM withdrawal
|
187
|
+
Assets:Current:BestBank:Checking -800.00 USD
|
188
|
+
Assets:Current:Cash
|
189
|
+
|
190
|
+
2008-02-10 * ATM withdrawal
|
191
|
+
Assets:Current:BestBank:Checking -500.00 USD
|
192
|
+
Assets:Current:Cash
|
193
|
+
|
194
|
+
2008-02-24 * ATM withdrawal
|
195
|
+
Assets:Current:BestBank:Checking -500.00 USD
|
196
|
+
Assets:Current:Cash
|
197
|
+
|
198
|
+
|
199
|
+
;; Automated withdrawal for Life insurance payments.
|
200
|
+
2008-01-02 * LIFE INSURANCE -- LONDON LIFE
|
201
|
+
Assets:Current:BestBank:Checking -42.69 USD
|
202
|
+
Expenses:Insurance:Life
|
203
|
+
|
204
|
+
2008-02-02 * LIFE INSURANCE -- LONDON LIFE
|
205
|
+
Assets:Current:BestBank:Checking -42.69 USD
|
206
|
+
Expenses:Insurance:Life
|
207
|
+
|
208
|
+
|
209
|
+
;; A purchase from a store using the bank's debit card.
|
210
|
+
2008-01-17 * Interac Purchase - 1341 - ACCES SPORTS S
|
211
|
+
Assets:Current:BestBank:Checking -89.00 USD
|
212
|
+
Expenses:Sports:Gear
|
213
|
+
|
214
|
+
|
215
|
+
;; A monthly fee that the bank takes for its deposit banking services.
|
216
|
+
2008-01-10 * MONTHLY FEE
|
217
|
+
Assets:Current:BestBank:Checking -4.00 USD
|
218
|
+
Expenses:Financial:Fees
|
219
|
+
|
220
|
+
;; A typical bank's return on checking accounts.
|
221
|
+
2008-01-12 * Deposit interest
|
222
|
+
Assets:Current:BestBank:Checking 0.02 USD
|
223
|
+
Income:Investments:Interest:Checking
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
;; An example of using the A/R account: I bought an electronic
|
228
|
+
;; toy for a friend, and I wanted to track the amount that he
|
229
|
+
;; should pay back to me. Instead of placing it in expenses, I
|
230
|
+
;; made it a receivable, which was cancelled later on where he
|
231
|
+
;; paid me back.
|
232
|
+
|
233
|
+
2008-03-26 * Bought an iPhone to Gilbert (had to use ATM)
|
234
|
+
Assets:AccountsReceivable 431.92 USD
|
235
|
+
Expenses:Financial:Fees 3.00 USD
|
236
|
+
Assets:Current:Cash -434.92 USD
|
237
|
+
|
238
|
+
;; Notice that the amount pay back was for an approximate
|
239
|
+
;; amount, so the overflow I placed in the cash account.
|
240
|
+
2008-04-02 * Gilbert paid back for iPhone
|
241
|
+
Assets:Current:Cash 440.00 CAD
|
242
|
+
Assets:AccountsReceivable -431.92 USD
|
243
|
+
Assets:Current:Cash
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
;;;;; Assets:Current:BestBank:Savings
|
253
|
+
|
254
|
+
@pad 2007-12-31 Assets:Current:BestBank:Savings Equity:Opening-Balances
|
255
|
+
|
256
|
+
|
257
|
+
;; Interest paid on balance in savings account.
|
258
|
+
2008-01-03 * DEPOSIT INTEREST
|
259
|
+
Assets:Current:BestBank:Savings 95.69 USD
|
260
|
+
Income:Investments:Interest:Savings
|
261
|
+
|
262
|
+
|
263
|
+
;; An entry that indicates a bank transfer from a checking account to a savings account.
|
264
|
+
;; There is a choice to locate this entry with the savings or with the checking, it's up to you.
|
265
|
+
2008-01-29 * Transfer from checking to savings account
|
266
|
+
Assets:Current:BestBank:Savings 2000.00 USD
|
267
|
+
Assets:Current:BestBank:Checking
|
268
|
+
|
269
|
+
2008-02-03 * DEPOSIT INTEREST
|
270
|
+
Assets:Current:BestBank:Savings 102.34 USD
|
271
|
+
Income:Investments:Interest:Savings
|
272
|
+
|
273
|
+
2008-02-03 * Transferring money to brokerage account for better investment.
|
274
|
+
Assets:Current:BestBank:Savings -10000.00 USD
|
275
|
+
Assets:Investments:UTrade:Account
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
;; Automated mortgage payments from the savings account.
|
282
|
+
2008-01-12 * MORTGAGE PAYMENT
|
283
|
+
Assets:Current:BestBank:Savings -464.46 USD
|
284
|
+
Liabilities:BestBank:Mortgage:Loan 171.01 USD
|
285
|
+
Expenses:Home:Monthly:Loan-Interest
|
286
|
+
|
287
|
+
2008-01-27 * MORTGAGE PAYMENT
|
288
|
+
Assets:Current:BestBank:Savings -464.46 USD
|
289
|
+
Liabilities:BestBank:Mortgage:Loan 171.01 USD
|
290
|
+
Expenses:Home:Monthly:Loan-Interest
|
291
|
+
|
292
|
+
2008-02-12 * MORTGAGE PAYMENT
|
293
|
+
Assets:Current:BestBank:Savings -464.46 USD
|
294
|
+
Liabilities:BestBank:Mortgage:Loan 171.01 USD
|
295
|
+
Expenses:Home:Monthly:Loan-Interest
|
296
|
+
|
297
|
+
2008-02-27 * MORTGAGE PAYMENT
|
298
|
+
Assets:Current:BestBank:Savings -464.46 USD
|
299
|
+
Liabilities:BestBank:Mortgage:Loan 171.01 USD
|
300
|
+
Expenses:Home:Monthly:Loan-Interest
|
301
|
+
|
302
|
+
2008-03-12 * MORTGAGE PAYMENT
|
303
|
+
Assets:Current:BestBank:Savings -464.46 USD
|
304
|
+
Liabilities:BestBank:Mortgage:Loan 171.01 USD
|
305
|
+
Expenses:Home:Monthly:Loan-Interest
|
306
|
+
|
307
|
+
2008-03-27 * MORTGAGE PAYMENT
|
308
|
+
Assets:Current:BestBank:Savings -464.46 USD
|
309
|
+
Liabilities:BestBank:Mortgage:Loan 171.01 USD
|
310
|
+
Expenses:Home:Monthly:Loan-Interest
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
;;;;; Liabilities:Credit-Card:VISA
|
315
|
+
|
316
|
+
@pad 2008-01-01 Liabilities:Credit-Card:VISA Equity:Opening-Balances
|
317
|
+
|
318
|
+
;; Paying back my credit card.
|
319
|
+
2008-01-22 * Online Banking payment - 5051 - VISA
|
320
|
+
Assets:Current:BestBank:Checking -791.34 USD
|
321
|
+
Liabilities:Credit-Card:VISA
|
322
|
+
|
323
|
+
|
324
|
+
;; Expenses at restaurants on credit card.
|
325
|
+
2008-01-15 * Cafe Imagination |
|
326
|
+
Liabilities:Credit-Card:VISA
|
327
|
+
Expenses:Food:Restaurant 47.00 USD
|
328
|
+
|
329
|
+
2008-01-19 * Soupe Bol |
|
330
|
+
Liabilities:Credit-Card:VISA -21.00 USD
|
331
|
+
Expenses:Food:Restaurant
|
332
|
+
|
333
|
+
2008-01-27 * Scola Pasta |
|
334
|
+
Liabilities:Credit-Card:VISA
|
335
|
+
Expenses:Food:Restaurant 51.17 USD
|
336
|
+
|
337
|
+
|
338
|
+
;; Cell phone bill via credit crad.
|
339
|
+
2008-01-19 * FIDO |
|
340
|
+
Liabilities:Credit-Card:VISA
|
341
|
+
Expenses:Communications:Phone 121.96 USD
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
;;;;; Assets:Investments:UTrade:Account
|
350
|
+
|
351
|
+
@pad 2007-12-31 Assets:Investments:UTrade:Account Equity:Opening-Balances
|
352
|
+
|
353
|
+
|
354
|
+
;; Some example trades.
|
355
|
+
;;
|
356
|
+
;; - Notice how I like to create a special account to contain
|
357
|
+
;; each kind of commodity. This choice is an arbitrary one: I
|
358
|
+
;; could keep all the stocks in the one investing account
|
359
|
+
;; (which would then contain many different kinds of
|
360
|
+
;; commodities) but doing it this way I can more easily track
|
361
|
+
;; the book value of the remaining shares that I have. I think
|
362
|
+
;; there may be a better way to do this.
|
363
|
+
;;
|
364
|
+
;; - Usually I enter the final amounts from the trade
|
365
|
+
;; confirmation slips that get emailed to me, because the
|
366
|
+
;; information there is more precise and detailed than what I
|
367
|
+
;; seem to get from the online brokerage interface. YMMV.
|
368
|
+
;;
|
369
|
+
;; - I still don't have a good generic way to deal with the
|
370
|
+
;; capital gains automatically, so I enter them by hand for
|
371
|
+
;; now. The challenge is to find a generic way to account
|
372
|
+
;; for capital gains while accounting for commissions and
|
373
|
+
;; trade fees the correct way (they should get removed from the
|
374
|
+
;; capital gains at both ends of a trade).
|
375
|
+
|
376
|
+
2008-01-08 * Buy some Apple Computer
|
377
|
+
Assets:Investments:UTrade:Account:AAPL 185.40 USD
|
378
|
+
Assets:Investments:UTrade:Account
|
379
|
+
Expenses:Financial:Commissions 9.95 USD
|
380
|
+
|
381
|
+
;; A divident payment.
|
382
|
+
2008-02-02 * DIVIDEND from AAPL position
|
383
|
+
Assets:Investments:UTrade:Account 0.68 USD
|
384
|
+
Income:Investments:Dividends
|
385
|
+
|
386
|
+
|
387
|
+
;; This position is kept long, so it gets reflected below in the check.
|
388
|
+
2008-02-10 * Buy some japanese ETF from iShares
|
389
|
+
Assets:Investments:UTrade:Account:EWJ 13.34 USD
|
390
|
+
Assets:Investments:UTrade:Account
|
391
|
+
Expenses:Financial:Commissions 9.95 USD
|
392
|
+
|
393
|
+
|
394
|
+
;; Run checks against statement summary of positions that gets
|
395
|
+
;; mailed periodically.
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
;;;;; Expenses:Insurance:Life
|
404
|
+
|
405
|
+
;; Estimate of value of life insurance policy, to account for
|
406
|
+
;; total net worth.
|
407
|
+
2008-01-01 * Life insurance policy resale value
|
408
|
+
Expenses:Insurance:Life 4407.06 USD
|
409
|
+
Equity:Opening-Balances
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
;;;;; Assets:Fixed:Home
|
418
|
+
|
419
|
+
;; You could use this account in order to reevaluate your home.
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
;;;;; Expenses:Home:Monthly:Condo-Fees
|
428
|
+
|
429
|
+
@pad 2008-01-01 Liabilities:Condo-Management Equity:Opening-Balances
|
430
|
+
|
431
|
+
2008-01-01 * Propri-Manage |
|
432
|
+
Expenses:Home:Monthly:Condo-Fees 212.61 USD
|
433
|
+
Liabilities:Condo-Management
|
434
|
+
|
435
|
+
2008-01-14 * (998) Propri-Manage | cheque sent by snail mail
|
436
|
+
Liabilities:Condo-Management 800.00 USD
|
437
|
+
Assets:Current:BestBank:Checking
|
438
|
+
|
439
|
+
2008-02-01 * Propri-Manage |
|
440
|
+
Expenses:Home:Monthly:Condo-Fees 212.61 USD
|
441
|
+
Liabilities:Condo-Management
|
442
|
+
|
443
|
+
2008-03-01 * Propri-Manage |
|
444
|
+
Expenses:Home:Monthly:Condo-Fees 212.61 USD
|
445
|
+
Liabilities:Condo-Management
|
446
|
+
|
447
|
+
2008-03-10 * Propri-Manage | special billing, spring works
|
448
|
+
Expenses:Home:Monthly:Condo-Fees 61.25 USD
|
449
|
+
Liabilities:Condo-Management
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
;;;;; Assets:Current:Cash
|
459
|
+
;;;;; Expenses:*
|
460
|
+
|
461
|
+
@pad 2007-12-31 Assets:Current:Cash Equity:Opening-Balances
|
462
|
+
|
463
|
+
|
464
|
+
;; Because I don't track individual cash expenses very tightly,
|
465
|
+
;; I still need to distribute the cash that disappeared into
|
466
|
+
;; appropriate expense categories. What I like to do is
|
467
|
+
;; guesstimate that about 80% of it goes into restaurants, and
|
468
|
+
;; 20% into wine bars. What frequency and categories you choose
|
469
|
+
;; to use is highly dependent on your lifestyle...
|
470
|
+
|
471
|
+
2008-01-02 * Distribution of cash expenses
|
472
|
+
Expenses:Food:Restaurant 300.00 USD
|
473
|
+
Expenses:Food:Alcool 100.00 USD
|
474
|
+
Assets:Current:Cash
|
475
|
+
|
476
|
+
2008-01-16 * Distribution of cash expenses
|
477
|
+
Expenses:Food:Restaurant 300.00 USD
|
478
|
+
Expenses:Food:Alcool 100.00 USD
|
479
|
+
Assets:Current:Cash
|
480
|
+
|
481
|
+
2008-02-02 * Distribution of cash expenses
|
482
|
+
Expenses:Food:Restaurant 300.00 USD
|
483
|
+
Expenses:Food:Alcool 100.00 USD
|
484
|
+
Assets:Current:Cash
|
485
|
+
|
486
|
+
2008-02-16 * Distribution of cash expenses
|
487
|
+
Expenses:Food:Restaurant 300.00 USD
|
488
|
+
Expenses:Food:Alcool 100.00 USD
|
489
|
+
Assets:Current:Cash
|
490
|
+
|
491
|
+
2008-03-02 * Distribution of cash expenses
|
492
|
+
Expenses:Food:Restaurant 300.00 USD
|
493
|
+
Expenses:Food:Alcool 100.00 USD
|
494
|
+
Assets:Current:Cash
|
495
|
+
|
496
|
+
2008-03-16 * Distribution of cash expenses
|
497
|
+
Expenses:Food:Restaurant 300.00 USD
|
498
|
+
Expenses:Food:Alcool 100.00 USD
|
499
|
+
Assets:Current:Cash
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
;;
|
504
|
+
;; Some common cash expenses.
|
505
|
+
;;
|
506
|
+
|
507
|
+
2008-02-18 * DMV | Renewal of driver's license.
|
508
|
+
Expenses:Govt-Services 110.00 USD
|
509
|
+
Assets:Current:Cash
|
510
|
+
|
511
|
+
2008-01-21 * WHOLE FOODS |
|
512
|
+
Expenses:Food:Grocery 54.03 USD
|
513
|
+
Assets:Current:Cash
|
514
|
+
|
515
|
+
2008-01-21 * USPS | sent package to mom
|
516
|
+
Expenses:Communications:Mail 4.43 USD
|
517
|
+
Assets:Current:Cash
|
518
|
+
|
519
|
+
2008-02-04 * taxi home from meeting
|
520
|
+
Expenses:Transportation:Taxi 12.00 USD
|
521
|
+
Assets:Current:Cash
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
;; Short weekend trip to Skii Mountain.
|
526
|
+
;;
|
527
|
+
;; You can use the @begintag and @endtag directives to mark all
|
528
|
+
;; transactions between them with a specific tag. Later on you
|
529
|
+
;; can filter the postings to a tag by using a cmdline. This
|
530
|
+
;; allows you to find out what expenses were incurred during a
|
531
|
+
;; specific trip.
|
532
|
+
|
533
|
+
@begintag ski-trip
|
534
|
+
|
535
|
+
2008-01-27 * SUNONO | fill'er up
|
536
|
+
Expenses:Car:Gas 40 USD
|
537
|
+
Assets:Current:Cash
|
538
|
+
|
539
|
+
2008-01-27 * SKII | Lift tickets
|
540
|
+
Expenses:Sports 120 USD
|
541
|
+
Assets:Current:Cash
|
542
|
+
|
543
|
+
2008-01-27 * Dinner at chalet
|
544
|
+
Expenses:Food:Restaurant 35.33 USD
|
545
|
+
Assets:Current:Cash
|
546
|
+
|
547
|
+
2008-01-28 * breakfast
|
548
|
+
Expenses:Food:Restaurant 17.23 USD
|
549
|
+
Assets:Current:Cash
|
550
|
+
|
551
|
+
2008-01-28 * a new hat, it was cold
|
552
|
+
Expenses:Clothes 40.02 USD
|
553
|
+
Assets:Current:Cash
|
554
|
+
|
555
|
+
@endtag ski-trip
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
2008-03-03 * ALDO | new shoes
|
561
|
+
Expenses:Clothes 121.20 USD
|
562
|
+
Assets:Current:Cash
|
563
|
+
|
564
|
+
2008-02-24 * AMC | movies with girlfriend
|
565
|
+
Expenses:Fun:Movie 24 USD
|
566
|
+
Assets:Current:Cash
|
567
|
+
|
568
|
+
2008-03-06 * Barnes & Noble | books on accounting
|
569
|
+
Expenses:Books 74.43 USD
|
570
|
+
Assets:Current:Cash -74.43 USD
|
571
|
+
|
572
|
+
2008-02-03 * ITHURTS MEDICAL CENT | x-ray for broken bones
|
573
|
+
Expenses:Medical 312.00 USD
|
574
|
+
Assets:Current:Cash
|
575
|
+
|
576
|
+
2008-03-02 * ZEN CENTER | Donation to Zen center
|
577
|
+
Expenses:Charity 50 USD
|
578
|
+
Assets:Current:Cash
|
579
|
+
|