Hi https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html Points out how to use ledger within org mode. Is there any simpler solution? Regards Uwe Brauer
On Monday, 4 Jan 2021 at 09:54, Uwe Brauer wrote:
> Points out how to use ledger within org mode.
> Is there any simpler solution?
How do you wish it to be simpler? What is it you wish to do?
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-166-g291993
[-- Attachment #1: Type: text/plain, Size: 683 bytes --] Uwe Brauer <oub@mat.ucm.es> writes: > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html > > Points out how to use ledger within org mode. > > Is there any simpler solution? Do you mean simpler accounting in org-mode, or do you mean simpler ledger-integration? You can always tangle your ledger-data and use a ledger commandline client. Also Emacs has direct support for ledger. Here’s a setup via use-package: (use-package ledger-mode :ensure t :defer 20 :config (org-babel-do-load-languages 'org-babel-load-languages '((ledger . t)))) Best wishes, Arne -- Unpolitisch sein heißt politisch sein ohne es zu merken [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 1125 bytes --]
On 04/01/2021 09:54, Uwe Brauer wrote:
> Hi
>
> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html
>
> Points out how to use ledger within org mode.
>
> Is there any simpler solution?
As other pointed out, you are not describing what you want to
accomplish, thus is impossible to suggest anything concrete. However, I
would like to suggest to look at Beancount and beancount-mode as
alternatives to Ledger as plain text accounting tools.
Cheers,
Dan
[-- Attachment #1: Type: text/plain, Size: 916 bytes --] >>> "AB" == Arne Babenhauserheide <arne_bab@web.de> writes: > Uwe Brauer <oub@mat.ucm.es> writes: >> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html >> >> Points out how to use ledger within org mode. >> >> Is there any simpler solution? > Do you mean simpler accounting in org-mode, This is what I meant. > or do you mean simpler ledger-integration? The example in this link is ok, also the output (the result of the ledger operation) is not very nicely formatted. > You can always tangle your ledger-data and use a ledger commandline > client. Also Emacs has direct support for ledger. Here’s a setup via > use-package: > (use-package ledger-mode :ensure t :defer 20 > :config > (org-babel-do-load-languages > 'org-babel-load-languages > '((ledger . t)))) > Best wishes, > Arne [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
On 1/4/21 3:54 AM, Uwe Brauer wrote: > > Hi > > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html > > Points out how to use ledger within org mode. > > Is there any simpler solution? > > Regards > > Uwe Brauer > > If "simpler" means just making entries into your ledger.dat file using orgmode you may wish to refer to Sacha Chua's capture template for that very purpose. She posted it a few years ago. https://sachachua.com/blog/2010/11/emacs-recording-ledger-entries-with-org-capture-templates/ Charlie Millar
On Monday, 4 Jan 2021 at 13:43, Uwe Brauer wrote:
> The example in this link is ok, also the output (the result of the
> ledger operation) is not very nicely formatted.
ledger does allow you to control, in detail, how the output should be
formatted. The default output is suitable for a console display but you
can modify this through appropriate arguments to the ledger command line
via babel. For instance, I have this line in my org file for generating
a balance of my assets:
,#+call: year2020[:cmdline -V --format "%-20A %14T\n" bal --flat assets ]()
where year2020 is a ledger src block which covers my 2020-21 tax year.
You will need to look at the ledger documentation, which is intensive,
for how to specify the format string. Ledger does come with an Emacs
info file: (ledger3) Format Strings
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-166-g291993
[-- Attachment #1: Type: text/plain, Size: 1421 bytes --] >>> "ESF" == Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Monday, 4 Jan 2021 at 13:43, Uwe Brauer wrote: >> The example in this link is ok, also the output (the result of the >> ledger operation) is not very nicely formatted. > ledger does allow you to control, in detail, how the output should be > formatted. The default output is suitable for a console display but you > can modify this through appropriate arguments to the ledger command line > via babel. For instance, I have this line in my org file for generating > a balance of my assets: > ,#+call: year2020[:cmdline -V --format "%-20A %14T\n" bal --flat assets ]() I am not sure I understand this (I admit I never used ledger, I used for some time gnucash) Do you mean this? #+call: allinone[:cmdline -V --format "%-20A %14T\n" bal --flat assets ]() #+name: allinone #+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/23 Rent expenses:rent 250.00 assets:bank:chequing 2010/07/24 Food expenses:food 150.00 assets:bank:chequing 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 [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
[-- Attachment #1: Type: text/plain, Size: 741 bytes --] >>> "DN" == Daniele Nicolodi <daniele@grinta.net> writes: > On 04/01/2021 09:54, Uwe Brauer wrote: >> Hi >> >> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html >> >> Points out how to use ledger within org mode. >> >> Is there any simpler solution? > As other pointed out, you are not describing what you want to > accomplish, thus is impossible to suggest anything concrete. However, I > would like to suggest to look at Beancount and beancount-mode as > alternatives to Ledger as plain text accounting tools. Thanks, it seems that beancount is not in Ubuntu, and beancount-mode is not available as a emacs package. Do you have any pointers? Thanks [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
i don't know if this is the best, but for some reason i had it so that ledger goes into a block [used to be example or so, now is ledger], and then post-process it with a shell source block. perhaps this will make more sense [in the distant past it made more sense to me]. when i process it, i call the source block, which means to run the shell, which calls the ledger command on the data i keep in org. for some reason it outputs each line to the minibuffer, which is a bit slow. but it is not a big deal. and i am not sure about searches. On 1/4/21, Uwe Brauer <oub@mat.ucm.es> wrote: >>>> "DN" == Daniele Nicolodi <daniele@grinta.net> writes: > > > On 04/01/2021 09:54, Uwe Brauer wrote: > >> Hi > >> > >> > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html > >> > >> Points out how to use ledger within org mode. > >> > >> Is there any simpler solution? > > > As other pointed out, you are not describing what you want to > > accomplish, thus is impossible to suggest anything concrete. However, > I > > would like to suggest to look at Beancount and beancount-mode as > > alternatives to Ledger as plain text accounting tools. > > Thanks, it seems that beancount is not in Ubuntu, and beancount-mode is > not available as a emacs package. > > Do you have any pointers? > > Thanks > -- The Kafka Pandemic Please learn what misopathy is. https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html
On 04/01/2021 21:04, Uwe Brauer wrote: >>>> "DN" == Daniele Nicolodi <daniele@grinta.net> writes: > > > On 04/01/2021 09:54, Uwe Brauer wrote: > >> Hi > >> > >> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html > >> > >> Points out how to use ledger within org mode. > >> > >> Is there any simpler solution? > > > As other pointed out, you are not describing what you want to > > accomplish, thus is impossible to suggest anything concrete. However, I > > would like to suggest to look at Beancount and beancount-mode as > > alternatives to Ledger as plain text accounting tools. > > Thanks, it seems that beancount is not in Ubuntu, and beancount-mode is > not available as a emacs package. > > Do you have any pointers? https://beancount.github.io/ is the project home page. You can find the documentation here: https://beancount.github.io/docs/ I haven't submitted beancount-mode to any Emacs package repository yet, there is still some work I would like to do before doing it. You can find it here: https://github.com/beancount/beancount-mode with some minimal documentation. Beancount is distributed as a Python package, thus it should be easily installable on any system providing Python 3.6 or later. Cheers, Dan
[-- Attachment #1: Type: text/plain, Size: 743 bytes --] > On 04/01/2021 21:04, Uwe Brauer wrote: > https://beancount.github.io/ > is the project home page. You can find the documentation here: > https://beancount.github.io/docs/ > I haven't submitted beancount-mode to any Emacs package repository yet, > there is still some work I would like to do before doing it. You can > find it here: > https://github.com/beancount/beancount-mode > with some minimal documentation. > Beancount is distributed as a Python package, thus it should be easily > installable on any system providing Python 3.6 or later. Thanks, I am still on Ubuntu 16.04 running 3.5 and call install beancount, I once tried upgrading python and it caused a lot of other problems, most likely I have to upgrade Ubuntu, sigh [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
[-- Attachment #1: Type: text/plain, Size: 2875 bytes --] > On Monday, 4 Jan 2021 at 21:01, Uwe Brauer wrote: > Yes. > Sorry I was brief: I cut and pasted something from one of my files while > in a rush! > Basically, you could do: > #+begin_src ledger :cmdline -V --format "%-20A %14T\n" bal --flat assets > 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 > #+end_src > and you would get, as output, > #+results: > : assets:bank:chequing 1000 > : assets:bank:savings 1300 > : 2300 Thanks. I figured out that I have to read a bit accounting again (I don't want to use gnucash again, I prefer an org solution). I think ledger is a reasonable solution (I cannot install currently beancount) > I'm not saying that this is much prettier than the default but simply > that you have total control over the formatting of the output so you may > be able to achieve what you wish. Yeah, your solution does not work for the example I had in mind but I realize now what I miss: the output should be an org table #+name: test #+begin_src ledger 2010/01/01 * Starting balance assets:bank:savings 0 income:starting balances 2010/07/23 ChristmasTree expenses:Brother:ChristmasTree 40.00 income:Brother:Card 2010/07/24 Jacket expenses:BigBrother:Jacket 150.00 income:BigBrother:Card 2010/07/24 Schuhe expenses:BigBrother:Shoes 20 income:BigBrother:Card 2010/07/23 BigBrother expenses:Brother:BigBrother 130 income:Brother:Card #+end_src #+RESULTS: test #+begin_example 340 expenses 170 BigBrother 150 Jacket 20 Shoes 170 Brother 130 BigBrother 40 ChristmasTree -340 income -170 BigBrother:Card -170 Brother:Card -------------------- 0 #+end_example But I rather prefer to have | 340 | expenses | | | | 170 | | BigBrother | | | 150 | | | Jacket | | 20 | | | Shoes | | 170 | | Brother | | | 130 | | | BigBrother | | 40 | | | ChristmasTree | | -340 | income | | | | -170 | | BigBrother:Card | | | -170 | | Brother:Card | | | | | | | |------+----------+-----------------+---------------| | 0 | | | | Any idea how to achieve this? [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
[-- Attachment #1: Type: text/plain, Size: 813 bytes --] >>> "CM" == Charles Millar <millarc@verizon.net> writes: > On 1/4/21 3:54 AM, Uwe Brauer wrote: >> Hi >> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html >> Points out how to use ledger within org mode. >> Is there any simpler solution? >> Regards >> Uwe Brauer >> > If "simpler" means just making entries into your ledger.dat file using > orgmode you may wish to refer to Sacha Chua's capture template for > that very purpose. She posted it a few years ago. > https://sachachua.com/blog/2010/11/emacs-recording-ledger-entries-with-org-capture-templates/ Thanks, that looks nice, but I finally think that the example in https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-ledger.html Is fine. The only think I am missing is the output in an org table form [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
>>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes: >> On Monday, 4 Jan 2021 at 21:01, Uwe Brauer wrote: >> Yes. >> Sorry I was brief: I cut and pasted something from one of my files while >> in a rush! >> Basically, you could do: >> #+begin_src ledger :cmdline -V --format "%-20A %14T\n" bal --flat assets >> 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 >> #+end_src >> and you would get, as output, > But I rather prefer to have > | 340 | expenses | | | > | 170 | | BigBrother | | > | 150 | | | Jacket | > | 20 | | | Shoes | > | 170 | | Brother | | > | 130 | | | BigBrother | > | 40 | | | ChristmasTree | > | -340 | income | | | > | -170 | | BigBrother:Card | | > | -170 | | Brother:Card | | > | | | | | > |------+----------+-----------------+---------------| > | 0 | | | | > Any idea how to achieve this? Well 10 years ago Eric Schulte posted this https://lists.gnu.org/archive/html/emacs-orgmode/2010-08/msg00502.html #+name: test #+begin_src ledger 2010/01/01 * Starting balance assets:bank:savings 0 income:starting balances 2010/07/23 ChristmasTree expenses:Brother:ChristmasTree 40.00 income:Brother:Card 2010/07/24 Jacket expenses:BigBrother:Jacket 150.00 income:BigBrother:Card 2010/07/24 Schuhe expenses:BigBrother:Shoes 20 income:BigBrother:Card 2010/07/23 BigBrother expenses:Brother:BigBrother 130 income:Brother:Card #+end_src #+begin_src emacs-lisp :var ledger=test (with-temp-buffer (insert ledger) (message ledger) (org-table-convert-region (point-min) (point-max) 2) (org-table-to-lisp)) #+end_src #+RESULTS: | 340 | expenses | | 170 | BigBrother | | 150 | Jacket | | 20 | Shoes | | 170 | Brother | | 130 | BigBrother | | 40 | ChristmasTree | | -340 | income | | -170 | BigBrother:Card | | -170 | Brother:Card | | -------------------- | | | 0 | | It is not precisely what I want, but not bad either. If somebody can come up with a better solution.......
On Tuesday, 5 Jan 2021 at 16:35, Uwe Brauer wrote:
> Yeah, your solution does not work for the example I had in mind
> but I realize now what I miss: the output should be an org table
If the ledger formatting options cannot help you (they are potentially
quite powerful), all I can suggest is a post-processing script
(e.g. with sed or awk or equivalent) that massages the output from
ledger into a form you like.
Hope you get something working to your satisfaction. Ledger is an
excellent text based accounting tool.
--
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-166-g291993
On Tuesday, 5 Jan 2021 at 17:02, Uwe Brauer wrote: > Well 10 years ago Eric Schulte posted this > https://lists.gnu.org/archive/html/emacs-orgmode/2010-08/msg00502.html Yes, this is what I meant about post-processing (in this case using elisp). > It is not precisely what I want, but not bad either. If somebody can > come up with a better solution....... Maybe append this to the ledger src block begin line: :cmdline bal --flat This will at least remove duplication of data. -- : Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-166-g291993
Also, ledger can format output as Elisp sexp (with emacs command). That should be easier to parse. Best, Ihor
[-- Attachment #1: Type: text/plain, Size: 638 bytes --] >>> "ESF" == Eric S Fraga <e.fraga@ucl.ac.uk> writes: > On Tuesday, 5 Jan 2021 at 17:02, Uwe Brauer wrote: >> Well 10 years ago Eric Schulte posted this >> https://lists.gnu.org/archive/html/emacs-orgmode/2010-08/msg00502.html > Yes, this is what I meant about post-processing (in this case using > elisp). >> It is not precisely what I want, but not bad either. If somebody can >> come up with a better solution....... > Maybe append this to the ledger src block begin line: > :cmdline bal --flat Thanks but then the output does not have any indent, and I find indentation helpful. [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]