hledger icon indicating copy to clipboard operation
hledger copied to clipboard

Add a way to setup a periodic transaction that happens on the X day every N months

Open vascoferreira25 opened this issue 4 years ago • 7 comments

There are periodic transactions that happen every few months but also at a specific day. This feature could be used like this: ~ every 3 months on 23rd day. The expected result would be:

; Starting from May
2021-05-23
2021-08-23
2021-11-23
; ...

vascoferreira25 avatar Apr 29 '21 21:04 vascoferreira25

I'd also like to add "every N years from yyyy-mm-dd" as a request. I have a few software subscriptions that I pay for more than one year at a time that would align with this type of entry.

tonytx05 avatar Jan 03 '22 04:01 tonytx05

We were discussing this feature a few days ago, and the only real sticking point is figuring out the grammar for this. Options are:

  • every exact month from …
  • every month' from …
  • every unaligned month from …
  • whatever else you can think of

Xitian9 avatar Jan 03 '22 08:01 Xitian9

We were discussing this feature a few days ago, and the only real sticking point is figuring out the grammar for this. Options are:

  • every exact month from …
  • every month' from …
  • every unaligned month from …
  • whatever else you can think of

Why does it need a specific syntax? It already recognizes you entered a date that didn't align with the beginning of a year, so why not check for this new syntax at that point instead of immediately generating the error message? Only afterwards, if the periodic expression is not formatted correctly, would you output an error message.

tonytx05 avatar Jan 03 '22 23:01 tonytx05

The same syntax would be used for generating report periods, for example, where it doesn't give an error, but rather automatically adjusts the begin and end dates to align with the month/week/quarter/year boundaries.

Xitian9 avatar Jan 04 '22 08:01 Xitian9

I believe it throws an error in periodic transactions because realigning silently would be unwanted. if we introduce the new functionality we could have it not align by default, and only require the special modifier in other uses.

Xitian9 avatar Jan 04 '22 08:01 Xitian9

The user is specifying the date they want to align to. I don't understand why an additional modifier is needed to say "no really, I entered this different date and I actually meant to".

tonytx05 avatar Jan 08 '22 03:01 tonytx05

Yes, I agree. It's an internal implementation issue: the same code is used for both periodic transactions and for calculating report spans. In the latter case, it is documented that it should realign this way, and that was the case for which this code was first written; the current periodic transaction implementation behaves as it does because it was a byproduct of this, and effort was being saved. So it's perfectly possible to do this by default for periodic transactions, but not without rewriting the code. I've done this, but we now have the option to allow it for report spans as well, and we're discussing the proper modifier to allow it there.

The refactorings in #1799 make implementing this much simpler.

Xitian9 avatar Jan 08 '22 09:01 Xitian9