;;; -*- mode: ledger; coding: utf-8; -*-
;;;
;;; This is an example/demo file, with some example accounts and
;;; some example transactions. A real-life Ledger file has a lot
;;; more transactions in it, and possibly a very different set
;;; of accounts; feel free to define your own and to change
;;; everything in here if you use this as a template. You can be
;;; creative, because all the account categories and commodities
;;; are entirely generic. (More comments are sprinkled below.)
;;;
;;; The order in which the transactions are declared does not
;;; matter at all... personally I like to organize transactions
;;; in chronological order, within sections that are
;;; more-or-less by account. I normally pretty much keep them in
;;; the order that the converted OFX file presents them. Here
;;; however, I've ordered the transactions for better clarity of
;;; presentation, since this is a file with sample transactions.


;;;;; Initialization


;;; Declaration of Accounts.

;;; Here you can declare a list of valid accounts, and
;;; optionally, a constraint on which kind of commodity they are
;;; allowed to hold (helps you track down mistakes).
;;;
;;; Note that
;;;
;;; - the system supports any currencies, and works with
;;;   multiple commodities in the same Ledger.
;;;
;;; - No distinction is made between currency commodities (e.g.
;;;   USD, EUR, USD) and investment commodities (e.g. GOOG,
;;;   AAPL, MSFT).
;;;
;;; - The Assets, Liabilities, Equity, Income, Expenses
;;;   categories are not special; they are simply a convention;
;;;   be creative if you like. There are really only two kinds
;;;   of accounts: debit accounts and credit accounts, and the
;;;   type is only used for reporting (maybe).

@defaccount De Assets:Current:Cash
@defaccount De Assets:Current:BestBank:Checking            USD
@defaccount De Assets:Current:BestBank:Savings             USD
;@defaccount De Assets:Fixed:Home                           USD
@defaccount De Assets:Investments:UTrade:Account           USD
@defaccount De Assets:Investments:UTrade:Account:AAPL      AAPL
@defaccount De Assets:Investments:UTrade:Account:EWJ       EWJ
;@defaccount De Assets:Loans
@defaccount De Assets:AccountsReceivable

;@defaccount Cr Liabilities:AccountsPayable
@defaccount Cr Liabilities:BestBank:Mortgage:Loan          USD
@defaccount Cr Liabilities:Credit-Card:VISA                USD
@defaccount Cr Liabilities:Condo-Management                USD

@defaccount Cr Equity:Opening-Balances

@defaccount Cr Income:Investments:Interest:Checking
@defaccount Cr Income:Investments:Interest:Savings
@defaccount Cr Income:Investments:Dividends
@defaccount Cr Income:Investments:Capital-Gains
@defaccount Cr Income:Salary:AcmeCo

@defaccount De Expenses:Financial:Fees
@defaccount De Expenses:Financial:Commissions
@defaccount De Expenses:Insurance:Life
@defaccount De Expenses:Food:Restaurant
@defaccount De Expenses:Food:Grocery
@defaccount De Expenses:Food:Alcool
@defaccount De Expenses:Communications:Phone
@defaccount De Expenses:Communications:Mail
;@defaccount De Expenses:Transportation:Parking
@defaccount De Expenses:Transportation:Taxi
;@defaccount De Expenses:Transportation:Trains
;@defaccount De Expenses:Transportation:PublicTrans
;@defaccount De Expenses:Taxes:US-State-California        USD
@defaccount De Expenses:Taxes:US-Federal                 USD
@defaccount De Expenses:Govt-Services                    USD
@defaccount De Expenses:Clothes
@defaccount De Expenses:Car:Gas
@defaccount De Expenses:Sports
@defaccount De Expenses:Sports:Gear
@defaccount De Expenses:Fun:Movie
;@defaccount De Expenses:Fun:Museum
@defaccount De Expenses:Books
;@defaccount De Expenses:Travel:Flights
;@defaccount De Expenses:Travel:Accomodation
;@defaccount De Expenses:Toys:Photography
;@defaccount De Expenses:Toys:Computer
;@defaccount De Expenses:Office-Supplies
@defaccount De Expenses:Medical
@defaccount De Expenses:Charity
;@defaccount De Expenses:Misc
;@defaccount De Expenses:Home:Repair
;@defaccount De Expenses:Home:Maintenance
;@defaccount De Expenses:Home:Taxes:Municipal
;@defaccount De Expenses:Home:Taxes:School
;@defaccount De Expenses:Home:Insurance
;@defaccount De Expenses:Home:Monthly
;@defaccount De Expenses:Home:Monthly:Internet
@defaccount De Expenses:Home:Monthly:Condo-Fees
;@defaccount De Expenses:Home:Monthly:Electricity
@defaccount De Expenses:Home:Monthly:Loan-Interest
;@defaccount De Expenses:Home:Monthly:Water
;@defaccount De Expenses:Home:Acquisition:Furniture
;@defaccount De Expenses:Home:Acquisition:Renovations
;@defaccount De Expenses:Home:Acquisition:Legal
;@defaccount De Expenses:Home:Acquisition:Inspection



;;; You can provide mappings from the account numbers ("account
;;; ids") that are normally found in OFX files that the
;;; banks/brokers provide, mapping to account names in this
;;; Ledger file. This way, a script that converts the OFX into
;;; Ledger-compatible syntax is able to automatically figure out
;;; the right account names.

;;; Account number mappings.
@var ofx accid  123456789012       Assets:Current:BestBank:Checking
@var ofx accid  123456789012       Assets:Current:BestBank:Savings
@var ofx accid  1234567890         Liabilities:BestBank:Mortgage:Loan
@var ofx accid  1234567890123456   Liabilities:Credit-Card:VISA
@var ofx accid  1234567890         Assets:Investments:UTrade:Account








;;;;; Assets:Current:BestBank:Checking

;; This entry tells the software to automatically insert an
;; entry at this date, of the amount required to fulfill the
;; next @check directive (chronologically) in the account (for
;; all commodities present). If the required amount is 0, no
;; entry is added.
@pad 2007-12-31 Assets:Current:BestBank:Checking   Equity:Opening-Balances

;; This directive tells the software to assert that at the given
;; date, in the given account, a specific amount of the given
;; commodity was present.
@check 2008-01-01 Assets:Current:BestBank:Checking  1412.24 USD


;; A check deposit, e.g. depositing a government check.
2008-01-05 * GST CANADA | Deposit from govt for consumer tax rebate
  Assets:Current:BestBank:Checking       77.76 USD
  Expenses:Taxes:US-Federal



;; This is how salary direct deposit entries might show up
;; within the checking account section. Note how the salaries
;; are negative amounts... that's because Income is a credit
;; account category, and the numbers there are negative (you can
;; interpret this as the "amount of work-dollars that you took
;; from society and placed into your account").

2008-01-10 * ACME | Salary paid from employer
  Assets:Current:BestBank:Checking        2000.00 USD
  Income:Salary:AcmeCo                    -2000 USD

2008-01-25 * ACME | Salary paid from employer
  Assets:Current:BestBank:Checking        2000.00 USD
  Income:Salary:AcmeCo

2008-02-10 * ACME | Salary paid from employer
  Assets:Current:BestBank:Checking        2000.00 USD
  Income:Salary:AcmeCo

2008-02-25 * ACME | Salary paid from employer
  Assets:Current:BestBank:Checking        2000.00 USD
  Income:Salary:AcmeCo



;; Withdrawal from another bank's ATM machine (with fees).
2008-01-12 * ATM withdrawal - 00044242
  Assets:Current:BestBank:Checking    -301.50 USD
  Expenses:Financial:Fees              1.50 USD
  Assets:Current:Cash

;; ATM withdrawal (without fees).
2008-01-30 * ATM withdrawal
  Assets:Current:BestBank:Checking    -800.00 USD
  Assets:Current:Cash

2008-02-10 * ATM withdrawal
  Assets:Current:BestBank:Checking    -500.00 USD
  Assets:Current:Cash

2008-02-24 * ATM withdrawal
  Assets:Current:BestBank:Checking    -500.00 USD
  Assets:Current:Cash


;; Automated withdrawal for Life insurance payments.
2008-01-02 * LIFE INSURANCE -- LONDON LIFE
  Assets:Current:BestBank:Checking         -42.69 USD
  Expenses:Insurance:Life

2008-02-02 * LIFE INSURANCE -- LONDON LIFE
  Assets:Current:BestBank:Checking         -42.69 USD
  Expenses:Insurance:Life


;; A purchase from a store using the bank's debit card.
2008-01-17 * Interac Purchase - 1341 - ACCES SPORTS S
  Assets:Current:BestBank:Checking      -89.00 USD
  Expenses:Sports:Gear


;; A monthly fee that the bank takes for its deposit banking services.
2008-01-10 * MONTHLY FEE
  Assets:Current:BestBank:Checking                   -4.00 USD
  Expenses:Financial:Fees

;; A typical bank's return on checking accounts.
2008-01-12 * Deposit interest
  Assets:Current:BestBank:Checking                0.02 USD
  Income:Investments:Interest:Checking



;; An example of using the A/R account: I bought an electronic
;; toy for a friend, and I wanted to track the amount that he
;; should pay back to me. Instead of placing it in expenses, I
;; made it a receivable, which was cancelled later on where he
;; paid me back.

2008-03-26 * Bought an iPhone to Gilbert (had to use ATM)
  Assets:AccountsReceivable                      431.92 USD
  Expenses:Financial:Fees                          3.00 USD
  Assets:Current:Cash                           -434.92 USD

;; Notice that the amount pay back was for an approximate
;; amount, so the overflow I placed in the cash account.
2008-04-02 * Gilbert paid back for iPhone
  Assets:Current:Cash                            440.00 CAD
  Assets:AccountsReceivable                     -431.92 USD
  Assets:Current:Cash



;; At the end of the month, I take my statements, look at the
;; bottom and enter the amount that the bank says was there at
;; that date. It should corroborate with the data in my Ledger.
@check 2008-02-01 Assets:Current:BestBank:Checking   661.49 USD






;;;;; Assets:Current:BestBank:Savings

@pad 2007-12-31 Assets:Current:BestBank:Savings   Equity:Opening-Balances

@check 2008-01-01 Assets:Current:BestBank:Savings    12000 USD

;; Interest paid on balance in savings account.
2008-01-03 * DEPOSIT INTEREST
  Assets:Current:BestBank:Savings                    95.69 USD
  Income:Investments:Interest:Savings


;; An entry that indicates a bank transfer from a checking account to a savings account.
;; There is a choice to locate this entry with the savings or with the checking, it's up to you.
2008-01-29 * Transfer from checking to savings account
  Assets:Current:BestBank:Savings       2000.00 USD
  Assets:Current:BestBank:Checking

2008-02-03 * DEPOSIT INTEREST
  Assets:Current:BestBank:Savings                    102.34 USD
  Income:Investments:Interest:Savings

2008-02-03 * Transferring money to brokerage account for better investment.
  Assets:Current:BestBank:Savings       -10000.00 USD
  Assets:Investments:UTrade:Account


;; A monthly check using the amount on the stament.
@check 2008-03-01 Assets:Current:BestBank:Savings    2340.19 USD



;; Automated mortgage payments from the savings account.
2008-01-12 * MORTGAGE PAYMENT
  Assets:Current:BestBank:Savings                                             -464.46 USD
  Liabilities:BestBank:Mortgage:Loan                                           171.01 USD
  Expenses:Home:Monthly:Loan-Interest

2008-01-27 * MORTGAGE PAYMENT
  Assets:Current:BestBank:Savings                                             -464.46 USD
  Liabilities:BestBank:Mortgage:Loan                                           171.01 USD
  Expenses:Home:Monthly:Loan-Interest

2008-02-12 * MORTGAGE PAYMENT
  Assets:Current:BestBank:Savings                                             -464.46 USD
  Liabilities:BestBank:Mortgage:Loan                                           171.01 USD
  Expenses:Home:Monthly:Loan-Interest

2008-02-27 * MORTGAGE PAYMENT
  Assets:Current:BestBank:Savings                                             -464.46 USD
  Liabilities:BestBank:Mortgage:Loan                                           171.01 USD
  Expenses:Home:Monthly:Loan-Interest

2008-03-12 * MORTGAGE PAYMENT
  Assets:Current:BestBank:Savings                                             -464.46 USD
  Liabilities:BestBank:Mortgage:Loan                                           171.01 USD
  Expenses:Home:Monthly:Loan-Interest

2008-03-27 * MORTGAGE PAYMENT
  Assets:Current:BestBank:Savings                                             -464.46 USD
  Liabilities:BestBank:Mortgage:Loan                                           171.01 USD
  Expenses:Home:Monthly:Loan-Interest



;;;;; Liabilities:Credit-Card:VISA

@pad 2008-01-01 Liabilities:Credit-Card:VISA  Equity:Opening-Balances
@check 2008-01-01 Liabilities:Credit-Card:VISA  -791.34 USD

;; Paying back my credit card.
2008-01-22 * Online Banking payment - 5051 - VISA
  Assets:Current:BestBank:Checking     -791.34 USD
  Liabilities:Credit-Card:VISA


;; Expenses at restaurants on credit card.
2008-01-15 * Cafe Imagination |
  Liabilities:Credit-Card:VISA
  Expenses:Food:Restaurant              47.00 USD

2008-01-19 * Soupe Bol |
  Liabilities:Credit-Card:VISA          -21.00 USD
  Expenses:Food:Restaurant

2008-01-27 * Scola Pasta |
  Liabilities:Credit-Card:VISA
  Expenses:Food:Restaurant              51.17 USD


;; Cell phone bill via credit crad.
2008-01-19 * FIDO |
  Liabilities:Credit-Card:VISA
  Expenses:Communications:Phone         121.96 USD







;;;;; Assets:Investments:UTrade:Account

@pad 2007-12-31 Assets:Investments:UTrade:Account  Equity:Opening-Balances

@check 2008-01-01  Assets:Investments:UTrade:Account  31273.02 USD

;; Some example trades.
;;
;; - Notice how I like to create a special account to contain
;;   each kind of commodity. This choice is an arbitrary one: I
;;   could keep all the stocks in the one investing account
;;   (which would then contain many different kinds of
;;   commodities) but doing it this way I can more easily track
;;   the book value of the remaining shares that I have. I think
;;   there may be a better way to do this.
;;
;; - Usually I enter the final amounts from the trade
;;   confirmation slips that get emailed to me, because the
;;   information there is more precise and detailed than what I
;;   seem to get from the online brokerage interface. YMMV.
;;
;; - I still don't have a good generic way to deal with the
;;   capital gains automatically, so I enter them by hand for
;;   now. The challenge is to find a generic way to account
;;   for capital gains while accounting for commissions and
;;   trade fees the correct way (they should get removed from the
;;   capital gains at both ends of a trade).

2008-01-08 * Buy some Apple Computer
  Assets:Investments:UTrade:Account:AAPL                     30 AAPL @ 185.40 USD
  Assets:Investments:UTrade:Account
  Expenses:Financial:Commissions                        9.95 USD

;; A divident payment.
2008-02-02 * DIVIDEND from AAPL position
  Assets:Investments:UTrade:Account    0.68 USD
  Income:Investments:Dividends

;; Because of my skirt-length statistic computation.
2008-02-28 * Sell off my Apple
  Assets:Investments:UTrade:Account:AAPL        -30 AAPL @ 193.02 USD
  Assets:Investments:UTrade:Account         5780.65 USD
  Expenses:Financial:Commissions               9.95 USD
  (Income:Investments:Capital-Gains)           BOOK AAPL
;; The line that says "BOOK AAPL" means to insert the amount that
;; corresponds to the gains/losses for the commodity "AAPL" within
;; the account for the posting in this transaction that includes AAPL
;; (Assets:Investments:UTrade:Account:AAPL, found automatically).
;; The inventory booking is done in FIFO order.
;;
;; The capital gain will show up as a negative number...
;; that's because Income is a credit account, like a salary.

;; This position is kept long, so it gets reflected below in the check.
2008-02-10 * Buy some japanese ETF from iShares
  Assets:Investments:UTrade:Account:EWJ                     100 EWJ @ 13.34 USD
  Assets:Investments:UTrade:Account
  Expenses:Financial:Commissions                        9.95 USD


;; Run checks against statement summary of positions that gets
;; mailed periodically.
@check 2008-03-01  Assets:Investments:UTrade:Account          40138.45 USD
@check 2008-03-01  Assets:Investments:UTrade:Account:AAPL     0 AAPL
@check 2008-03-01  Assets:Investments:UTrade:Account:EWJ      100 EWJ







;;;;; Expenses:Insurance:Life

;; Estimate of value of life insurance policy, to account for
;; total net worth.
2008-01-01 * Life insurance policy resale value
  Expenses:Insurance:Life     4407.06 USD
  Equity:Opening-Balances







;;;;; Assets:Fixed:Home

;; You could use this account in order to reevaluate your home.







;;;;; Expenses:Home:Monthly:Condo-Fees

@pad 2008-01-01 Liabilities:Condo-Management      Equity:Opening-Balances

@check 2008-01-01 Liabilities:Condo-Management      -41.11 USD

2008-01-01 * Propri-Manage |
  Expenses:Home:Monthly:Condo-Fees        212.61 USD
  Liabilities:Condo-Management

2008-01-14 * (998) Propri-Manage | cheque sent by snail mail
  Liabilities:Condo-Management         800.00 USD
  Assets:Current:BestBank:Checking

2008-02-01 * Propri-Manage |
  Expenses:Home:Monthly:Condo-Fees        212.61 USD
  Liabilities:Condo-Management

2008-03-01 * Propri-Manage |
  Expenses:Home:Monthly:Condo-Fees        212.61 USD
  Liabilities:Condo-Management

2008-03-10 * Propri-Manage | special billing, spring works
  Expenses:Home:Monthly:Condo-Fees     61.25 USD
  Liabilities:Condo-Management

@check 2008-04-01 Liabilities:Condo-Management     59.81 USD







;;;;; Assets:Current:Cash
;;;;; Expenses:*

@pad 2007-12-31  Assets:Current:Cash  Equity:Opening-Balances

;; Amount in wallet at a given time.
@check 2007-12-31  Assets:Current:Cash                          200 CAD
@check 2007-12-31  Assets:Current:Cash                          300 USD

;; Because I don't track individual cash expenses very tightly,
;; I still need to distribute the cash that disappeared into
;; appropriate expense categories. What I like to do is
;; guesstimate that about 80% of it goes into restaurants, and
;; 20% into wine bars. What frequency and categories you choose
;; to use is highly dependent on your lifestyle...

2008-01-02 * Distribution of cash expenses
  Expenses:Food:Restaurant   300.00 USD
  Expenses:Food:Alcool       100.00 USD
  Assets:Current:Cash

2008-01-16 * Distribution of cash expenses
  Expenses:Food:Restaurant   300.00 USD
  Expenses:Food:Alcool       100.00 USD
  Assets:Current:Cash

2008-02-02 * Distribution of cash expenses
  Expenses:Food:Restaurant   300.00 USD
  Expenses:Food:Alcool       100.00 USD
  Assets:Current:Cash

2008-02-16 * Distribution of cash expenses
  Expenses:Food:Restaurant   300.00 USD
  Expenses:Food:Alcool       100.00 USD
  Assets:Current:Cash

2008-03-02 * Distribution of cash expenses
  Expenses:Food:Restaurant   300.00 USD
  Expenses:Food:Alcool       100.00 USD
  Assets:Current:Cash

2008-03-16 * Distribution of cash expenses
  Expenses:Food:Restaurant   300.00 USD
  Expenses:Food:Alcool       100.00 USD
  Assets:Current:Cash



;;
;; Some common cash expenses.
;;

2008-02-18 * DMV | Renewal of driver's license.
  Expenses:Govt-Services     110.00 USD
  Assets:Current:Cash

2008-01-21 * WHOLE FOODS |
  Expenses:Food:Grocery    54.03 USD
  Assets:Current:Cash

2008-01-21 * USPS | sent package to mom
  Expenses:Communications:Mail      4.43 USD
  Assets:Current:Cash

2008-02-04 * taxi home from meeting
  Expenses:Transportation:Taxi  12.00 USD
  Assets:Current:Cash



;; Short weekend trip to Skii Mountain.
;;
;; You can use the @begintag and @endtag directives to mark all
;; transactions between them with a specific tag. Later on you
;; can filter the postings to a tag by using a cmdline. This
;; allows you to find out what expenses were incurred during a
;; specific trip.

@begintag ski-trip

2008-01-27 * SUNONO | fill'er up
  Expenses:Car:Gas            40 USD
  Assets:Current:Cash

2008-01-27 * SKII | Lift tickets
  Expenses:Sports        120 USD
  Assets:Current:Cash

2008-01-27 * Dinner at chalet
  Expenses:Food:Restaurant      35.33 USD
  Assets:Current:Cash

2008-01-28 * breakfast
  Expenses:Food:Restaurant      17.23 USD
  Assets:Current:Cash

2008-01-28 * a new hat, it was cold
  Expenses:Clothes              40.02 USD
  Assets:Current:Cash

@endtag ski-trip




2008-03-03 * ALDO | new shoes
  Expenses:Clothes              121.20 USD
  Assets:Current:Cash

2008-02-24 * AMC | movies with girlfriend
  Expenses:Fun:Movie           24 USD
  Assets:Current:Cash

2008-03-06 * Barnes & Noble | books on accounting
  Expenses:Books            74.43 USD
  Assets:Current:Cash      -74.43 USD

2008-02-03 * ITHURTS MEDICAL CENT | x-ray for broken bones
  Expenses:Medical           312.00 USD
  Assets:Current:Cash

2008-03-02 * ZEN CENTER | Donation to Zen center
  Expenses:Charity        50 USD
  Assets:Current:Cash




@check 2008-03-01  Assets:Current:Cash                          200 CAD
@check 2008-03-01  Assets:Current:Cash                          30.96 USD






