;;; -*- mode: org; mode: beancount; coding: utf-8; -*-
#+STARTUP: showall
;;;
;;; This is a basic 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.

* Options

option "title" "Beancount Example Ledger"
option "operating_currency" "USD"
option "operating_currency" "CAD"


* 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. FB, AMZN,
;;;   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:Fixed:Home                           USD
1970-01-01 open Assets:UTrade:Account                                USD
1970-01-01 open Assets:UTrade:Account:AAPL                           AAPL
1970-01-01 open Assets:UTrade:Account:EWJ                            EWJ
;defaccount De Assets:Loans
1970-01-01 open Assets:AccountsReceivable

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

1970-01-01 open Equity:Opening-Balances

1970-01-01 open Income:Interest:Checking
1970-01-01 open Income:Interest:Savings
1970-01-01 open Income:Dividends
1970-01-01 open Income:Capital-Gains
1970-01-01 open Income:Salary:AcmeCo

1970-01-01 open Expenses:Financial:Fees
1970-01-01 open Expenses:Financial:Commissions
1970-01-01 open Expenses:Insurance:Life
1970-01-01 open Expenses:Food:Restaurant
1970-01-01 open Expenses:Food:Grocery
1970-01-01 open Expenses:Food:Alcool
1970-01-01 open Expenses:Communications:Phone
1970-01-01 open Expenses:Communications:Mail
;defaccount De Expenses:Transportation:Parking
1970-01-01 open Expenses:Transportation:Taxi
;defaccount De Expenses:Transportation:Trains
;defaccount De Expenses:Transportation:PublicTrans
;defaccount De Expenses:Taxes:US-State-California        USD
1970-01-01 open Expenses:Taxes:US-Federal                                        USD
1970-01-01 open Expenses:Govt-Services                                           USD
1970-01-01 open Expenses:Clothes
1970-01-01 open Expenses:Car:Gas
1970-01-01 open Expenses:Sports
1970-01-01 open Expenses:Sports:Gear
1970-01-01 open Expenses:Fun:Movie
;defaccount De Expenses:Fun:Museum
1970-01-01 open 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
1970-01-01 open Expenses:Medical
1970-01-01 open 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
1970-01-01 open Expenses:Home:Monthly:Condo-Fees
;defaccount De Expenses:Home:Monthly:Electricity
1970-01-01 open 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.
;;accid "123456789012" Assets:BestBank:Checking
;;accid "123456789012" Assets:BestBank:Savings
;;accid "1234567890" Liabilities:BestBank:Mortgage:Loan
;;accid "1234567890123456" Liabilities:Credit-Card:VISA
;;accid "1234567890" Assets:UTrade:Account








* Assets:BestBank:Checking

1970-01-01 open Assets:BestBank:Checking                                 USD

;; 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.
2007-12-31 pad Assets: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.
2008-01-01 balance Assets: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: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:BestBank:Checking        2000.00 USD
  Income:Salary:AcmeCo                    -2000 USD

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

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

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



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

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

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

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


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

2008-02-02 * "LIFE INSURANCE -- LONDON LIFE"
  Assets: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: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:BestBank:Checking                   -4.00 USD
  Expenses:Financial:Fees


;; A typical bank's return on checking accounts.
2008-01-12 * "Deposit interest"
  Assets:BestBank:Checking                0.02 USD
  Income: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: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:Cash                            440.00 CAD
  Assets:AccountsReceivable                     -431.92 USD
  Assets: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.
2008-02-01 balance Assets:BestBank:Checking   661.49 USD






* Assets:BestBank:Savings

1970-01-01 open Assets:BestBank:Savings                                  USD
2007-12-31 pad  Assets:BestBank:Savings   Equity:Opening-Balances

2008-01-01 balance Assets:BestBank:Savings    12000 USD

;; Interest paid on balance in savings account.
2008-01-03 * "DEPOSIT INTEREST"
  Assets:BestBank:Savings                    95.69 USD
  Income: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:BestBank:Savings       2000.00 USD
  Assets:BestBank:Checking

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

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


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



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

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

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

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

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

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



* Liabilities:Credit-Card:VISA

2007-12-31 pad Liabilities:Credit-Card:VISA  Equity:Opening-Balances
2008-01-01 balance Liabilities:Credit-Card:VISA  -791.34 USD

;; Paying back my credit card.
2008-01-22 * "Online Banking payment - 5051 - VISA"
  Assets: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:UTrade:Account

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

2008-01-01 balance  Assets: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).
;;
;; - Note that the "185.40 USD" cost amount below refers to the
;;   price PER UNIT of AAPL. If you wanted to provided a cost for
;;   the full amount, you could use two brackets, e.g. {{185.40 USD}}.

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

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

;; Because of my skirt-length statistic computation.
2008-02-28 * "Sell off my Apple"
  Assets:UTrade:Account:AAPL        -30 AAPL {185.40 USD} @ 193.02 USD
  Assets:UTrade:Account         5780.65 USD
  Expenses:Financial:Commissions               9.95 USD
  Income:Capital-Gains

;; 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: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:UTrade:Account:EWJ                     100 EWJ {13.34 USD}
  Assets:UTrade:Account
  Expenses:Financial:Commissions                        9.95 USD


;; Run checks against statement summary of positions that gets
;; mailed periodically.
2008-03-01 balance  Assets:UTrade:Account          40138.45 USD
2008-03-01 balance  Assets:UTrade:Account:AAPL     0 AAPL
2008-03-01 balance  Assets: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

2007-12-31 pad Liabilities:Condo-Management      Equity:Opening-Balances

2008-01-01 balance 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: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

2008-04-01 balance Liabilities:Condo-Management     59.81 USD







* Assets:Cash
* Expenses:*

1970-01-01 open Assets:Cash

2007-12-30 pad  Assets:Cash  Equity:Opening-Balances


;; Amount in wallet at a given time.
2007-12-31 balance  Assets:Cash                          200 CAD
2007-12-31 balance  Assets: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:Cash

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

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

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

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

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



;;
;; Some common cash expenses.
;;

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

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

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

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



;; Short weekend trip to Skii Mountain.
;;
;; You can use the pushtag and poptag 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.

pushtag #ski-trip

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

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

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

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

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

poptag #ski-trip




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

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

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

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


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




2008-03-01 balance  Assets:Cash                          200.00 CAD
2008-03-01 balance  Assets:Cash                          30.96 USD

2008-03-15 price USD  1.0934 CAD

2013-07-03 event "location" "New York City"
