Nicely formatted management summaries (balance sheet, income statement etc) for filing

72 views
Skip to first unread message

Daryl Manning

unread,
Feb 2, 2022, 6:27:52 AMFeb 2
to Ledger
TLDR

I need some reasonably nicely formatted management summaries (balance, income, cashflow, retained) to hand to my lawyers for small business filing. What are people using for pdfs or indelible reports to interoperate with lawyers/accountants?

Longer Story
I've been using ledger for some time now and took the plunge during covid to use it to run my small-ish business. For personal use have been using a combination of it and reckon to automate entry. It's been great so far:

I'm in the position now of having to file for 2020 and 2021 and need to get some reasonably decent looking reports out of it (or export the text and then format it) to hand to the lawyers for the government filings here.

What are people using to do this? What core snippets/resources are available? My google-fu failed me searching for blog posts or code resources on this one (I'm aware of ledger-pyreports though am having it throw an error despite my ledger file being fine from ledger's perspective. Have pinged author for a pointer... but what else is there and what are people who aree needing to do this actually doing?).

thanks! (and happy year of the tiger everyone!)
Daryl.


Stanko Trček

unread,
Feb 2, 2022, 1:46:42 PMFeb 2
to Ledger
Hi, in short, for reporting I using the following workflow:
- run ledger-cli queries in Python script ->
- put ledger result in python template (mako) ->
- output from mako template to a tex file
- run pdflatex to get PDF report.

All procedure is in one Python file. Additionally, you can transform tex file with Pandoc to another format (ex. html).
Tools using beside ledger: python, mako template (or other templates) and latex. 

sreda, 2. februar 2022 ob 12:27:52 UTC+1 je oseba daryl....@gmail.com napisala:

Stanko Trček

unread,
Feb 2, 2022, 3:10:05 PMFeb 2
to Ledger
To be more specific, I put a short example on GitHub.
Link: https://github.com/stankotrcek/jnl-report 


sreda, 2. februar 2022 ob 12:27:52 UTC+1 je oseba daryl....@gmail.com napisala:
TLDR

Daryl Manning

unread,
Feb 4, 2022, 10:58:48 PMFeb 4
to Ledger
Thanks Stanko, this was actually super useful as a template. Very handy. Nice work.

(I'd also take a look at ledger-pyreports as well. The guy has done a seriously good job.)>

Daryl.

Daryl Manning

unread,
Feb 4, 2022, 11:10:56 PMFeb 4
to Ledger
Just a followup for posterity, in case someone else manages to google-fu their way to this post.

Besides Stanko's solution above which is quite configurable and might meet your needs better, I ended up using ledger-pyreport for the task (a small python flask app which pumps out 3 of the 4 management summaries - does not have a Retained earnings report for corp filings.). The author was super responsive when I could not get it going and pointed me quickly to the problem. The reports also look great.

https://yingtongli.me/blog/2020/03/31/ledger-pyreport.html

Three caveats that tripped me up getting it going - as it can be affected by the way you've recorded your ledger file:
  1. You need to have your Assets and Liabilities structured so accounts have a Current and Non-current "subcategory" ie. Assets:Current:SG Bank Account. So, had to find/replace some category names in the journal file to get pyreport to work (but irrelevant to me really and makes obvious sense when you think about it if you need management summaries. Serves me right for not paying more attention in Biz 257.).
  2. It expects a foreign currency conversion for each and every transaction not in the main report currency (for me SGD).  So,  5000 EUR @ 1.6789 SGD or similar so it can get reports out properly.
  3. remove --pedantic from the example config file so that it is not expecting all accounts to be predeclared before you actually use them.
Other than that, worked smoothly and quite happy with it. Recommend it. Good luck and happy Year of the Tiger! 🐯

ciao !
Daryl.
PS> Thanks to everyone that also responded directly to me on the post.

google juice signposting:
ledger
ledger-pyreport error
TypeError('Cannot compare Amount with non-zero number')
Error: Unknown account

Randy

unread,
Feb 19, 2022, 11:05:17 PMFeb 19
to Ledger
I wrote something along the lines of this for income statements. YMMV
--- I'm definitely not an accountant or any sort of financial
professional.

```
#!/bin/bash

# This script generates an income statement for the given year.
# This is designed to be run by apenwarr's redo.
# To use it standalone, make it executable and give it
# three arguments:
#
# - $1: (doesn't matter)
# - $2: the name of the file minus the extension (should be a year with a corresponding .journal file)
# - $3: the name of a temp file which will hold the output
#
# You'll have to make changes to suit your own needs.

name="Your name here"

year=$(basename $2)

redo-ifchange $year.journal

# Change these commands to suit your needs ########################

cmd="ledger -f $year.journal -HX $ -p $year bal"
income=$($cmd ^Income --account "tag('country')" --invert)
expenses=$($cmd ^Expenses)
total=$($cmd ^Income ^Expenses --invert | tail -n 2 | sed -e '1s/-/=/g' -e '2s/$/  Net Income/')


# Go to the end of the year if year is past
if test "$(date +%Y)" -le "$year"; then
    todate=$(date +%D)
else
    todate=$(date -d $year-12-31 +%D)
fi

intro="This document is the income statement for $name for the calendar
year of $year to $todate. Amounts in CNY have been converted to USD at their
historical prices according to the time of transaction."

printf "Income statement for %d to %s\n" $year $todate  >> $3
( printf "%39s\n" | tr " "  = )                         >> $3
printf "\n%s\n" "$intro" "$income" "$expenses" "$total" >> $3

unix2dos $3
mv $3 $(dirname $3)/$(basename $3 .tmp)
```

For example, with the following journal file:

```
; 2022.journal
2022-01-01 Employer
        Assets:Bank           $2,000.00
        Income:Employer      $-2,000.00
2022-01-02 Paycheck Party!
        Expenses:Beer           $200.00
        Expenses:Food           $100.00
        Assets:Bank            $-300.00
2022-01-03 Savings
        Assets:Savings        $1,000.00
        Assets:Bank          $-1,000.00
```

Running `./incomestmt.sh '' 2022 2022.income.txt.tmp`, I get the following:

```
Income statement for 2022 to 02/20/22
=======================================

This document is the income statement for Your name here for the calendar
year of 2022 to 02/20/22. Amounts in CNY have been converted to USD at their
historical prices according to the time of transaction.

           $2,000.00  Income:Employer

             $300.00  Expenses
             $200.00    Beer
             $100.00    Food
--------------------
             $300.00

====================
           $1,700.00  Net Income
```

Hope this helps someone!
2022.journal
incomestmt.sh
2022.income.txt
Reply all
Reply to author
Forward
0 new messages