From: Eric S Fraga <ucecesf@ucl.ac.uk>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Personal accounting with emacs, org and...?
Date: Thu, 22 Jul 2010 21:30:02 +0100 [thread overview]
Message-ID: <87mxtjw985.wl%ucecesf@ucl.ac.uk> (raw)
In-Reply-To: <878w53fnu1.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]
On Thu, 22 Jul 2010 10:06:30 -0700, "Eric Schulte" <schulte.eric@gmail.com> wrote:
>
> Eric S Fraga <ucecesf@ucl.ac.uk> writes:
>
> > On Thu, 22 Jul 2010 01:26:29 -0500, Russell Adams <RLAdams@AdamsInfoServ.Com> wrote:
> >>
> >> On Thu, Jul 22, 2010 at 01:20:58AM -0500, Marcelo de Moraes Serpa wrote:
> >> > Hey list,
> >> >
> >> > I was wondering if anyone out there manages his personal accounting
> >> > with org. I never really managed my personal finances, but I think
> >> > it's about time to know where my money comes from and where it is
> >> > going (and where the leaks are :P). I would use something like
> >> > lessaccounting.com, but I would rather integrate it into my
> >> > orgmode-based PIM. Any ideas?
> >>
> >> I use John Wiegley's Ledger (of Remember fame), which is a CLI tool
> >> that does reporting against plain text files.
> >>
> >> I do my expense reporting and business accounting in it. Very flexible
> >> and because it is text based, I can use version control and emacs.
> >
> > and, with org-babel, you can place your ledger entries in an org
> > file... I have a simple ob-ledger implementation which doesn't do
> > tangling yet (as I don't yet know how to provide this level of
> > support) but it does work for single blocks of ledger entries.
>
> Tangling does not require *any* language specific support. Since the
> integration of Babel into Org-mode any type of code block should tangle
> just fine. For example the following minimal org file tangles a code
> block of the fictional /schulte/ language to a file "eric.sh"
Yes, thanks, I figured this out on the way home (the advantage of a
long commute is time to play!) before I got your email. The tangling
works like a charm. What's even better is that ability to specify the
tangle property as an org property which only affects code blocks
within a certain heading! Fantastic.
> It does look like there is fertile ground for Babel<->Ledger
> integration.
Attached is my simple, linux only, org-babel solution and an example
org file which uses it. Note, I've still not had a chance to look at
the ob-template in Worg so I'm sure my ob-ledger file could be
improved...
Thanks again all those who have contributed to babel!
eric
[-- Attachment #2: ob-ledger.el --]
[-- Type: text/plain, Size: 2544 bytes --]
;;; ob-ledger.el --- org-babel functions for ledger evaluation
;; Copyright (c) 2009 Eric S Fraga
;; based on code by
;; Copyright (C) 2009 Eric Schulte
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
;; Version: 0.01
;;; License:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Org-Babel support for evaluating ledger entries.
;;
;; This differs from most standard languages in that
;;
;; 1) there is no such thing as a "session" in ledger
;;
;; 2) we are generally only going to return output from the leger program
;;
;; 3) we are adding the "cmdline" header argument
;;
;; 4) there are no variables
;;; Code:
;; (require 'org-babel)
;;(org-babel-add-interpreter "ledger")
;;(add-to-list 'org-babel-tangle-langs '("ledger" "ledger"))
(defvar org-babel-default-header-args:ledger
'((:results . "output") (:cmdline . "bal"))
"Default arguments to use when evaluating a ledger source block.")
(defun org-babel-execute:ledger (body params)
"Execute a block of Ledger entries with org-babel. This function is
called by `org-babel-execute-src-block'."
(message "executing Ledger source code block")
(let ((result-params (split-string (or (cdr (assoc :results params)) "")))
(cmdline (cdr (assoc :cmdline params)))
(in-file (make-temp-file "org-babel-ledger"))
(out-file (make-temp-file "org-babel-ledger-output"))
)
(with-temp-file in-file (insert body))
(message (concat "ledger -f " in-file " " cmdline))
(with-output-to-string (shell-command (concat "ledger -f " in-file " " cmdline " > " out-file)))
(with-temp-buffer (insert-file-contents out-file) (buffer-string))
))
(defun org-babel-prep-session:ledger (session params)
(error "Ledger does not support sessions"))
(provide 'ob-ledger)
;;; org-babel-ledger.el ends here
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Type: text/plain; charset=US-ASCII, Size: 3357 bytes --]
* ledger test
*** income and expenses
:PROPERTIES:
:tangle: account.ledger
:END:
The property for this heading specifies where the tangled output of
the ledger code blocks in what follows should end up.
***** income
The first set of entries relates to income, either monthly pay or
interest, all typically going into my bank account.
#+begin_src ledger
2010/01/01 * Starting balance
assets:bank:savings £1300.00
income:starting balances
2010/07/22 * Got paid
assets:bank:chequing £1000.00
income:salary
2010/07/31 * Interest on bank savings
assets:bank:savings £3.53
income:interest
2010/07/31 * Transfer savings
assets:bank:savings £250.00
assets:bank:chequing
2010/08/01 got paid again
assets:bank:chequing £1000.00
income:salary
#+end_src
***** expenses
The following entries relate to personal expenses (rent and food).
#+begin_src ledger
2010/07/23 Rent
expenses:rent £500.00
assets:bank:chequing
2010/07/24 Food
expenses:food £150.00
assets:bank:chequing
#+end_src
*** Financial summary
Assuming you have tangled the ledger entries (=C-c C-v t=), you can now
perform all kinds of calculations
***** overall summary
The overall balance of your account and expenditure with a breakdown
according to category:
#+begin_src ledger :cmdline -s bal :results value
!include /home/ucecesf/s/test/account.ledger
#+end_src
#+results:
#+begin_example
£2653.53 assets:bank
£1100.00 chequing
£1553.53 savings
£650.00 expenses
£150.00 food
£500.00 rent
£-3303.53 income
£-3.53 interest
£-2000.00 salary
£-1300.00 starting balances
#+end_example
***** monthly register
You can also generate a monthly register by executing the following:
#+begin_src ledger :cmdline -M -w reg
!include /home/ucecesf/s/test/account.ledger
#+end_src
#+results:
#+begin_example
2010/01/01 - 2010/01/31 assets:bank:savings £1300.00 £1300.00
income:starting balances £-1300.00 0
2010/07/01 - 2010/07/31 assets:bank:chequing £100.00 £100.00
assets:bank:savings £253.53 £353.53
expenses:food £150.00 £503.53
expenses:rent £500.00 £1003.53
income:interest £-3.53 £1000.00
income:salary £-1000.00 0
2010/08/01 - 2010/08/01 assets:bank:chequing £1000.00 £1000.00
income:salary £-1000.00 0
#+end_example
[-- Attachment #4: Type: text/plain, Size: 75 bytes --]
--
Eric S Fraga
GnuPG: 8F5C 279D 3907 E14A 5C29 570D C891 93D8 FFFC F67D
[-- Attachment #5: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-07-22 20:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 6:20 Personal accounting with emacs, org and...? Marcelo de Moraes Serpa
2010-07-22 6:26 ` Russell Adams
2010-07-22 6:39 ` Gour
2010-07-22 6:46 ` Russell Adams
2010-07-22 9:06 ` Eric S Fraga
2010-07-22 17:06 ` Eric Schulte
2010-07-22 20:30 ` Eric S Fraga [this message]
2010-07-22 20:43 ` Eric Schulte
2010-07-22 22:49 ` Eric S Fraga
2010-07-23 16:29 ` Eric Schulte
2010-07-24 23:01 ` Eric S Fraga
2010-07-22 13:53 ` Matt Lundin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mxtjw985.wl%ucecesf@ucl.ac.uk \
--to=ucecesf@ucl.ac.uk \
--cc=e.fraga@ucl.ac.uk \
--cc=emacs-orgmode@gnu.org \
--cc=schulte.eric@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.