Year end date

29 views
Skip to first unread message

Dan Sladden

unread,
Feb 22, 2021, 3:59:38 AMFeb 22
to Ledger
Is there a way of specifying the date of the financial year end so I can use --yearly (or an appropriate PERIOD_EXPRESSION) to show annual data for each year from e.g. 6 April to 5 April?

Eric S Fraga

unread,
Feb 22, 2021, 7:34:28 AMFeb 22
to ledge...@googlegroups.com
On Monday, 22 Feb 2021 at 00:59, Dan Sladden wrote:
> Is there a way of specifying the date of the financial year end so I can
> use --yearly (or an appropriate *PERIOD_EXPRESSION)* to show annual data
> for each year from e.g. 6 April to 5 April?

This would be a nice feature to have!

My solution has been to have a separate ledger file for each tax year
but that means transferring balances at the end of one year to create
the new year's file which sometimes leads to issues should anything need
to be updated in the previous year's records (missing entry, for
instance).

--
Eric S Fraga via Emacs 28.0.50 & org 9.4.4 on Debian bullseye/sid

o1bigtenor

unread,
Feb 22, 2021, 8:21:27 AMFeb 22
to Ledger
On Mon, Feb 22, 2021 at 6:34 AM Eric S Fraga <e.f...@ucl.ac.uk> wrote:
>
> On Monday, 22 Feb 2021 at 00:59, Dan Sladden wrote:
> > Is there a way of specifying the date of the financial year end so I can
> > use --yearly (or an appropriate *PERIOD_EXPRESSION)* to show annual data
> > for each year from e.g. 6 April to 5 April?
>
> This would be a nice feature to have!
>
> My solution has been to have a separate ledger file for each tax year
> but that means transferring balances at the end of one year to create
> the new year's file which sometimes leads to issues should anything need
> to be updated in the previous year's records (missing entry, for
> instance).
>

May I suggest that you are making life more difficult for yourself and
to the OP there is a simple yet, imo anyway, elegant solution.

This solution was given at least in part, to me here on the forum,
and I then modified it to fit my needs. (Can't remember the kind soul
who gave me the information originally but huge kudos to them and
this list for their helpfulness!!!)

ledger reg -f /home/memyself/ledger2014-19.dat --limit 'account =~
/9795\.[0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]/' -b 2014.01.01 -e
2014.12.31
(This is all on one line in your terminal! I tend to use 132 or even wider
terminal screens!!)

The part that is specific for the OP would be the last two 'commands'
(dunno if that's the right word - - - - sorry!).
With this you are asking for the search to be performed from the first
date of the fiscal year 2014 (the -b command) to
the last day of fiscal year 2014 (the e command).

I have 10 digit account numbers in a format like xxx.xx.xx.xx so
search will give not only all the items that
fall within the search (each item with its date) but there is also a
sum included (total of all the records!).

So for my tax records - - - - account 9795 has a specific meaning and
then I enter the total in the tax
document.

Very very simple - - - - ledger IS your record keeping friend.

(I'm working on how to use it for not only accounts receivable and
accounts payable but also for
invoicing and account aging - - - so far not in practice but have been
working on a possible technique.
Ledger seriously rocks for business use!!!!!!!!!!!)

HTH

Eric S Fraga

unread,
Feb 22, 2021, 8:32:24 AMFeb 22
to ledge...@googlegroups.com
On Monday, 22 Feb 2021 at 07:20, o1bigtenor wrote:
> May I suggest that you are making life more difficult for yourself and
> to the OP there is a simple yet, imo anyway, elegant solution.

Thank you. I do use -b and -e as well.

Kent R. Spillner

unread,
Feb 22, 2021, 9:29:56 AMFeb 22
to ledge...@googlegroups.com
In addition to what o1bigtenor suggested I also like to add a little structure to
the organization of my ledger files and make heavy use of ledger's include
directive (see: https://www.ledger-cli.org/3.0/doc/ledger3.html#Command-Directives).

For example, in my top-level directory I create subdirectories for every year, i.e.
2019/, 2020/, 2021/, etc. Also in my top-level directory I create a bunch of ledger
files that *only* contain include directives, e.g. 2021.ledger contains just the two
lines "include 2021/business.ledger" and "include 2021/personal.ledger"; these are
the files I pass to ledger on the command line. Then inside each year-based subdir
I create a bunch of files that actually record all of my financial transactions,
organized in whatever way makes the most sense (e.g. my "2021/personal.ledger" file
also just includes a bunch of files, like "include checking.ledger" and
"include mortgage.ledger").

Ok, so how would this help with different tax year end date? Currently, all of my
tax years end on December 31, but if I ever had a need to support something else I
would just add a new file in my top-level directory such as "2020-tax-year.ledger"
that just contains the lines "include 2019/whatever.ledger" and
"include 2020/whatever.ledger". And then so I don't forget to add the appropriate
--begin and --end command line arguments I would write a wrapper script in my
top-level directory such as "tax-year-report.sh".

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/87v9akqlcu.fsf%40ucl.ac.uk.


Kent R. Spillner

unread,
Feb 22, 2021, 9:40:15 AMFeb 22
to ledge...@googlegroups.com
> My solution has been to have a separate ledger file for each tax year
> but that means transferring balances at the end of one year to create
> the new year's file which sometimes leads to issues should anything need
> to be updated in the previous year's records (missing entry, for
> instance).

Exactly, but you can work around that issue by using the include directive (see:
https://www.ledger-cli.org/3.0/doc/ledger3.html#Command-Directives).

For example, I have a script that writes out my year-end balances to the next year's
directory (I create subdirectories in my top-level directory for every year) with a
filename of "<organization>-opening-balances.ledger" (e.g.
"2021/business-opening-balances.ledger" and "2021/personal-opening-balances.ledger").
Then at the top of my "2021/business.ledger" and "2021/personal.ledger" files I just
"include business-opening-balances.ledger" or "personal-opening-balances.ledger"
respectively.

That allows me to go back and automatically overwrite those files to adjust my opening
balances at any time without having to edit any subsequent transaction.


Dan Sladden

unread,
Feb 22, 2021, 12:31:20 PMFeb 22
to ledge...@googlegroups.com
I get all this and I use -b and -e extensively!

But none of this does what I want - a single list of tallied transactions for each financial year from one ledger command. Yes, I can do it by executing multiple commands with different -b and -e arguments, but that's IMHO not very elegant.

I like the output of --yearly
I don't like that it has to be 1 Jan through to 31 Dec for each year.

:)



--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.

o1bigtenor

unread,
Feb 22, 2021, 1:10:34 PMFeb 22
to Ledger
On Mon, Feb 22, 2021 at 11:31 AM Dan Sladden <d...@sladden.com> wrote:
>
> I get all this and I use -b and -e extensively!
>
> But none of this does what I want - a single list of tallied transactions for each financial year from one ledger command. Yes, I can do it by executing multiple commands with different -b and -e arguments, but that's IMHO not very elegant.
>
> I like the output of --yearly
> I don't like that it has to be 1 Jan through to 31 Dec for each year.
>

Hmmmmmmm - - - -it doesn't 'have to be' Jan 1 to Dec 31!
You pick the dates - - - - - YOU.
So you want from Oct 1 to Sep 30 - - - - your choice.

Not sure what you mean by a 'list of tallied transactions'.

The command that I included in my previous email returns a list of
all the transactions for that account number in the period specified
and includes the total. I think that's what you want.

If you are able to give an example of what you're looking for
I am positive someone from the list will be able to help you develop
the command to achieve such - - - - that has been my experience.

As for elegance - - - - I prefer getting the job done quickly, I
suppose, so I've not worried about query 'elegance'.

HTH

John Wiegley

unread,
Feb 22, 2021, 4:08:49 PMFeb 22
to Dan Sladden, ledge...@googlegroups.com
>>>>> "DS" == Dan Sladden <d...@sladden.com> writes:

DS> But none of this does what I want - a single list of tallied
DS> transactions for each financial year from one ledger command. Yes, I
DS> can do it by executing multiple commands with different -b and -e
DS> arguments, but that's IMHO not very elegant.

Have you tried --group-by 'format_date(date, "%Y")'?

John

Dan Sladden

unread,
Feb 22, 2021, 4:36:49 PMFeb 22
to John Wiegley, ledge...@googlegroups.com
Apologies - I'm not being very clear. I'm trying to total the entries for the whole financial year that ends on (in my case) 5 April.

This is the output of for example ledger broadband --yearly
'2019-01-01' - '2019-12-31'               Expenses:Utilities:Broadband            £ 350.14          £ 350.14
'2020-01-01' - '2020-12-31'               Expenses:Utilities:Broadband            £ 463.85          £ 813.99
'2021-01-01' - '2021-12-31'               Expenses:Utilities:Broadband             £ 40.34          £ 854.33


But what I want is this:
'2019-04-06' - '2020-04-05'               Expenses:Utilities:Broadband            £ 465.58          £ 465.58
'2020-04-06' - '2021-04-05'               Expenses:Utilities:Broadband            £ 388.75          £ 854.33

John, --group-by 'format_date(date, "%Y")' looks helpful as I could write a function that maps the date onto the financial year (although leap years would be a pain) but it won't aggregate the entries in the same way as --yearly I don't think.

Dan

o1bigtenor

unread,
Feb 22, 2021, 6:21:36 PMFeb 22
to Ledger
On Mon, Feb 22, 2021 at 3:36 PM Dan Sladden <d...@sladden.com> wrote:
>
> Apologies - I'm not being very clear. I'm trying to total the entries for the whole financial year that ends on (in my case) 5 April.
>
> This is the output of for example ledger broadband --yearly
> '2019-01-01' - '2019-12-31' Expenses:Utilities:Broadband £ 350.14 £ 350.14
> '2020-01-01' - '2020-12-31' Expenses:Utilities:Broadband £ 463.85 £ 813.99
> '2021-01-01' - '2021-12-31' Expenses:Utilities:Broadband £ 40.34 £ 854.33
>
> But what I want is this:
> '2019-04-06' - '2020-04-05' Expenses:Utilities:Broadband £ 465.58 £ 465.58
> '2020-04-06' - '2021-04-05' Expenses:Utilities:Broadband £ 388.75 £ 854.33
>
ledger reg -f /whereever/you/store/ledger'name'.dat --limit 'account
=~Expenses:Utilities:Broadband -b 2014.04.06 -e 2015.04.05

I modified what I sent earlier to the dating you're looking for.
What I do not know is if that phrase 'Expenses:Utilities:Broadband' is
the actual 'account name - - - - I use numbers.

You may have to experiment with the =~ part of the command.
If you run the years inline without closing each one out (I don't see
the need but ymmv) the search really doesn't care what
you beginning and ending dates are - - - - just enter them.

Now if you're entering your records so that one set ends on dec 31st
and the next starts on jan 1st
- - - - - well then things won't be so easy.

HTH
Reply all
Reply to author
Forward
0 new messages