Parser Demo — Plain Text Accounting Formats

full.beancount

Beancount OK

; Full beancount example — all directive and entry types
option "title" "Full Example Ledger"
option "operating_currency" "GBP"
plugin "beancount.plugins.auto_accounts"
include "other.beancount"
; Commodity declarations
2024-01-01 commodity GBP
  name: "British Pound"
2024-01-01 commodity USD
2024-01-01 commodity EUR
; Account lifecycle
2024-01-01 open Assets:Bank:Current GBP
2024-01-01 open Assets:Bank:Savings GBP,USD
2024-01-01 open Expenses:Food GBP
2024-01-01 open Expenses:Rent GBP
2024-01-01 open Income:Salary GBP
2024-01-01 open Liabilities:CreditCard GBP
2024-01-01 open Equity:Opening-Balances
2024-12-31 close Liabilities:CreditCard
; Transactions
2024-01-15 * "Opening balance"
  Assets:Bank:Current   5000.00 GBP
  Equity:Opening-Balances
2024-02-01 * "Landlord" "Monthly rent"
  Expenses:Rent   1200.00 GBP
  Assets:Bank:Current
; Balance assertion
2024-02-01 balance Assets:Bank:Current 3800.00 GBP
; Pad directive
2024-03-01 pad Assets:Bank:Current Equity:Opening-Balances
; Note directive
2024-03-15 note Assets:Bank:Current "Switched to premium account"
; Document directive
2024-04-01 document Assets:Bank:Current "/documents/statement-2024-04.pdf"
; Event directive
2024-05-01 event "location" "London"
; Price directive
2024-06-01 price USD 0.79 GBP
2024-06-01 price EUR 0.86 GBP
; Query directive
2024-07-01 query "monthly-expenses" "
  SELECT account, sum(position) WHERE account ~ 'Expenses'
"
; Custom directive
2024-08-01 custom "budget" Expenses:Food
; Tags
pushtag #project-alpha
2024-09-01 * "Tagged transaction"
  Expenses:Food   25.00 GBP
  Assets:Bank:Current
poptag #project-alpha
; Metadata
pushmeta reviewer: "alice"
2024-10-01 * "Reviewed transaction"
  Expenses:Food   30.00 GBP
  Assets:Bank:Current
popmeta reviewer:
; Transaction with all the trimmings
2024-11-01 * "Complex Corp" "Full-featured transaction" #work ^invoice-42
  category: "consulting"
  Expenses:Food   100.00 GBP
    receipt: "receipt-42.pdf"
  Assets:Bank:Current  -100.00 GBP
2024-12-01 * "Year-end transaction"
  Expenses:Food   50.00 GBP
  Assets:Bank:Current

Goluca OK

; DROPPED: option
; DROPPED: option
; DROPPED: plugin
; DROPPED: include
; DROPPED: commodity
; DROPPED: commodity
; DROPPED: commodity
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: close
2024-01-15 *
  Equity:Opening-Balances -> Assets:Bank:Current "Opening balance" 5000.00 GBP
2024-02-01 *
  Assets:Bank:Current -> Expenses:Rent "Landlord — Monthly rent" 1200.00 GBP
; DROPPED: balance
; DROPPED: pad
; DROPPED: note
; DROPPED: document
; DROPPED: event
; DROPPED: price
; DROPPED: price
; DROPPED: query
; DROPPED: custom
; DROPPED: pushtag
2024-09-01 *
  Assets:Bank:Current -> Expenses:Food "Tagged transaction" 25.00 GBP
; DROPPED: poptag
; DROPPED: pushmeta
2024-10-01 *
  Assets:Bank:Current -> Expenses:Food "Reviewed transaction" 30.00 GBP
; DROPPED: popmeta
2024-11-01 *
  Assets:Bank:Current -> Expenses:Food "Complex Corp — Full-featured transaction" 100.00 GBP
2024-12-01 *
  Assets:Bank:Current -> Expenses:Food "Year-end transaction" 50.00 GBP

Flow Diagram

Opening-Balances -5000.00 GBP Current 3595.00 GBP Food 205.00 GBP Rent 1200.00 GBP Opening balance 5000.00 GBP Landlord — Monthly rent 1200.00 GBP Tagged transaction 25.00 GBP Reviewed transaction 30.00 GBP Complex Corp — Full-featured transaction 100.00 GBP Year-end transaction 50.00 GBP Equity Asset Expense
AST (beancount)
(file
  (comment)
  (option
    (string)
    (string)
  )
  (option
    (string)
    (string)
  )
  (plugin
    (string)
  )
  (include
    (string)
  )
  (comment)
  (commodity
    (date)
    (currency)
    (key_value
      (key)
      (value
        (string)
      )
    )
  )
  (commodity
    (date)
    (currency)
  )
  (commodity
    (date)
    (currency)
  )
  (comment)
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
  )
  (close
    (date)
    (account)
  )
  (comment)
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (transaction
    (date)
    (txn)
    (payee)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (comment)
  (balance
    (date)
    (account)
    (amount_tolerance
      (number)
      (currency)
    )
  )
  (comment)
  (pad
    (date)
    (account)
    (account)
  )
  (comment)
  (note
    (date)
    (account)
    (string)
  )
  (comment)
  (document
    (date)
    (account)
    (filename
      (string)
    )
  )
  (comment)
  (event
    (date)
    (string)
    (string)
  )
  (comment)
  (price
    (date)
    (currency)
    (amount
      (number)
      (currency)
    )
  )
  (price
    (date)
    (currency)
    (amount
      (number)
      (currency)
    )
  )
  (comment)
  (query
    (date)
    (string)
    (string)
  )
  (comment)
  (custom
    (date)
    (string)
    (custom_value
      (account)
    )
  )
  (comment)
  (pushtag
    (tag)
  )
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (poptag
    (tag)
  )
  (comment)
  (pushmeta
    (key_value
      (key)
      (value
        (string)
      )
    )
  )
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (popmeta
    (key)
  )
  (comment)
  (transaction
    (date)
    (txn)
    (payee)
    (narration)
    (tags_links
      (tag)
      (link)
    )
    (key_value
      (key)
      (value
        (string)
      )
    )
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (key_value
      (key)
      (value
        (string)
      )
    )
    (posting
      (account)
      (incomplete_amount
        (unary_number_expr
          (minus)
          (number)
        )
        (currency)
      )
    )
  )
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
)

simple.beancount

Beancount OK

; Simple beancount example
option "title" "Simple Ledger"
option "operating_currency" "GBP"
2024-01-01 open Assets:Bank:Current GBP
2024-01-01 open Expenses:Groceries GBP
2024-01-01 open Income:Salary GBP
2024-01-01 open Equity:Opening-Balances
2024-01-01 * "Opening balance"
  Assets:Bank:Current   1000.00 GBP
  Equity:Opening-Balances
2024-01-15 * "Tesco" "Weekly groceries"
  Expenses:Groceries   45.50 GBP
  Assets:Bank:Current

Goluca OK

; DROPPED: option
; DROPPED: option
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
2024-01-01 *
  Equity:Opening-Balances -> Assets:Bank:Current "Opening balance" 1000.00 GBP
2024-01-15 *
  Assets:Bank:Current -> Expenses:Groceries "Tesco — Weekly groceries" 45.50 GBP

Flow Diagram

Opening-Balances -1000.00 GBP Current 954.50 GBP Groceries 45.50 GBP Opening balance 1000.00 GBP Tesco — Weekly groceries 45.50 GBP Equity Asset Expense
AST (beancount)
(file
  (comment)
  (option
    (string)
    (string)
  )
  (option
    (string)
    (string)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
  )
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (transaction
    (date)
    (txn)
    (payee)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
)

transactions.beancount

Beancount OK

; Transaction variations
option "title" "Transaction Examples"
2024-01-01 open Assets:Bank:Current GBP
2024-01-01 open Assets:Bank:Savings GBP,USD
2024-01-01 open Expenses:Food GBP
2024-01-01 open Expenses:Travel GBP,USD
2024-01-01 open Income:Salary GBP
2024-01-01 open Equity:Opening-Balances
; Simple transaction with payee and narration
2024-02-01 * "Sainsburys" "Lunch supplies"
  Expenses:Food   12.30 GBP
  Assets:Bank:Current
; Transaction with tags and links
2024-02-05 * "Flight to Paris" #travel ^trip-2024
  Expenses:Travel   250.00 GBP
  Assets:Bank:Current
; Transaction with metadata
2024-02-10 * "Monthly salary"
  invoice: "2024-02-001"
  Assets:Bank:Current   3500.00 GBP
  Income:Salary
; Transaction with cost spec
2024-02-15 * "Buy USD"
  Assets:Bank:Savings   500.00 USD {0.79 GBP}
  Assets:Bank:Current  -395.00 GBP
; Transaction with price annotation
2024-02-20 * "Convert GBP to USD"
  Assets:Bank:Savings   100.00 USD @ 0.79 GBP
  Assets:Bank:Current
; Flagged transaction (!)
2024-02-25 ! "Pending refund"
  Assets:Bank:Current   50.00 GBP
  Expenses:Travel
; Transaction with arithmetic
2024-02-28 * "Split bill"
  Expenses:Food   (90.00 / 3) GBP
  Assets:Bank:Current

Goluca ERRORS

; DROPPED: option
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
; DROPPED: open
2024-02-01 *
  Assets:Bank:Current -> Expenses:Food "Sainsburys — Lunch supplies" 12.30 GBP
2024-02-05 *
  Assets:Bank:Current -> Expenses:Travel "Flight to Paris" 250.00 GBP
2024-02-10 *
  Income:Salary -> Assets:Bank:Current "Monthly salary" 3500.00 GBP
2024-02-15 *
  Assets:Bank:Current -> Assets:Bank:Savings "Buy USD" 500.00 USD
2024-02-20 *
  Assets:Bank:Current -> Assets:Bank:Savings "Convert GBP to USD" 100.00 USD
2024-02-25 !
  Expenses:Travel -> Assets:Bank:Current "Pending refund" 50.00 GBP
2024-02-28 *
  Assets:Bank:Current -> Expenses:Food "Split bill"  GBP

Flow Diagram

AST (beancount)
(file
  (comment)
  (option
    (string)
    (string)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
    (currency)
  )
  (open
    (date)
    (account)
    (currency)
  )
  (open
    (date)
    (account)
  )
  (comment)
  (transaction
    (date)
    (txn)
    (payee)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (comment)
  (transaction
    (date)
    (txn)
    (narration)
    (tags_links
      (tag)
      (link)
    )
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (comment)
  (transaction
    (date)
    (txn)
    (narration)
    (key_value
      (key)
      (value
        (string)
      )
    )
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (comment)
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
      (cost_spec
        (cost_comp
          (compound_amount
            (number)
            (currency)
          )
        )
      )
    )
    (posting
      (account)
      (incomplete_amount
        (unary_number_expr
          (minus)
          (number)
        )
        (currency)
      )
    )
  )
  (comment)
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
      (at)
      (price_annotation
        (incomplete_amount
          (number)
          (currency)
        )
      )
    )
    (posting
      (account)
    )
  )
  (comment)
  (transaction
    (date)
    (txn
      (flag)
    )
    (narration)
    (posting
      (account)
      (incomplete_amount
        (number)
        (currency)
      )
    )
    (posting
      (account)
    )
  )
  (comment)
  (transaction
    (date)
    (txn)
    (narration)
    (posting
      (account)
      (incomplete_amount
        (binary_number_expr
          (number)
          (slash)
          (number)
        )
        (currency)
      )
    )
    (posting
      (account)
    )
  )
)