Building a command line tool for automating entry of recurring transactions

139 views
Skip to first unread message

Gavin Hughes

unread,
Aug 31, 2018, 3:17:59 PM8/31/18
to Ledger
I'm starting work on ledger-recur shown below (and prettier in this gist).  I see this topic gets discussed occasionally. Does anything like this already exist?  Is this useful to anyone else?  Any suggestions from improvement before I start work on it?

- Gavin
---

#+Title:Ledger Recur

Ledger Recur provides automated entry of recurring transactions into ledger files.

The command `recur journal.ledger recurring.rcr` enters all recurring transactions specified in the file `recurring.rcr` into the file `journal.ledger`.

A recur file is parsed before transactions are entered into a ledger file. If erorrs are found, they are reported and no transactions are entered.

* Recur file syntax

** Transactions

#+BEGIN_SRC
Payee
    /recurrence/ /[end_date]/
    /last_applied_date/
    [Remaining lines applied verbatim]
#+END_SRC

*** Example

#+BEGIN_SRC
    Dropbox
      1M22 E2018/12/31
      2018/08/30
      ; d: Pro subscription
      ; :recur:
      software  $10
#+END_SRC

** Recurrence syntax

| Interval              | Interpreted as                               |
|-----------------------+----------------------------------------------|
| 1W1,3,5               | Every week on Mon, Wed, Fri.                 |
| 2W5                   | Every two weeks on Fri.                      |
| 1M22                  | Every 1 month on the 22nd.                   |
| 1M1,15                | Every 1 month on the 1st and 15th.           |
| 1Mw7                  | Every 1 month on the first Sun.              |
| 1Y01/08               | Every 1 year on Jan-08.                      |
| /interval/ E2018/01/08 | The recur terminates on 2018/01/08.          |

* Command line syntax

recur /ledger_file/ /recur_file/

If a recur file is not supplied, recur will look for a file with the same name as the ledger file but with an added extension of `.rcr`.

Example,

#+BEGIN_SRC
recur main.ldg
#+END_SRC

expands to

#+BEGIN_SRC
recur main.ldg main.ldg.rcr
#+END_SRC

** Options

| -d | --dry-run | Simulate but do not enter transaction. Reports errors and warnings. |

Ledger Recur provides automated entry of recurring transactions into ledger files.

The command `recur journal.ledger recurring.rcr` enters all recurring transactions specified in the file `recurring.rcr` into the file `journal.ledger`.

A recur file is parsed before transactions are entered into a ledger file. If erorrs are found, they are reported and no transactions are entered.

* Recur file syntax

** Transactions

  Payee
    Recurrence /end_date/
    Last_applied_date
    [Remaining lines applied verbatim]

*** Example

    Dropbox
      1M22 E2018/12/31
      2018/08/30
      ; d: Pro subscription
      ; :recur:
      software  $10

* Recurrence syntax

| Impl | Example               | Interpreted as                               |
|------+-----------------------+----------------------------------------------|
|      | 1W1,3,5               | Every week on Mon, Wed, Fri.                 |
|      | 2W5                   | Every two weeks on Fri.                      |
|      | 1M22                  | Every 1 month on the 22nd.                   |
|      | 1M1,15                | Every 1 month on the 1st and 15th.           |
|      | 1Mw7                  | Every 1 month on the first Sun.              |
|      | 1Y01/08               | Every 1 year on Jan-08                       |
|      | /interval/E2018/01/08 | Every 1 year on Jan-08, ending on 18-Jan-08. |
|      |                       |                                              |

* Command line syntax

recur /ledger_file/ /recur_file/

  Example:  recur dauin.rcr main.ldg

If a recur file is not supplied, recur will look for a file with the same name as the ledger file with the addition of ".rcr".

  Example,  recur main.ldg   expands to   recur main.ldg main.ldg.rcr.

** Options

| -d | --dry-run | Simulate but do not enter transaction. Reports errors and warnings. |

Craig Earls

unread,
Aug 31, 2018, 3:56:08 PM8/31/18
to ledge...@googlegroups.com
I have something very similar built into ledger-mode

--

---
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.
For more options, visit https://groups.google.com/d/optout.
--
Craig, Corona De Tucson, AZ
missile_flyout
enderw88.wordpress.com

Gavin Hughes

unread,
Aug 31, 2018, 6:53:06 PM8/31/18
to Ledger
Just tried it.  Looks great.

Can I customize to look for the scheduler file in alternate locations?  I keep books for multiple organizations, each will have a separate scheduler file.

Craig Earls

unread,
Aug 31, 2018, 6:59:50 PM8/31/18
to ledge...@googlegroups.com
 Anything is possible with Emacs 

Scott Carpenter

unread,
Sep 2, 2018, 6:32:04 AM9/2/18
to Ledger
The first thing I wrote when I switched to ledgerbil was a scheduler for recurring transactions:


Ledgerbil can be tied to my own ledger usage in many ways, but the scheduler is one of the things that should be usable by any ledger user. :-)

Gavin Hughes

unread,
Sep 6, 2018, 4:48:46 AM9/6/18
to Ledger
This looks good.  I'll give it a try this weekend.  Thanks!

--

---
You received this message because you are subscribed to a topic in the Google Groups "Ledger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ledger-cli/AS31YrxiTj4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ledger-cli+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages