Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active October 6, 2024 01:54
Show Gist options
  • Save fabiolimace/6627177bf0d0361b5eb4a88cfcdad7e3 to your computer and use it in GitHub Desktop.
Save fabiolimace/6627177bf0d0361b5eb4a88cfcdad7e3 to your computer and use it in GitHub Desktop.
Cookie-Jar Plain Text Ledger

Cookie-Jar Plain Text Ledger

This document describes a simple plain text ledger based on ledger-cli and cookie-jar format.

The goal of this document is to describe a bookkeeping format that is simple enough to be parsed with regular Unix tools such as Awk.

Cookie-jar format:

0000/00/00                        Description
Assets:Account                           0.00
Liabilities:Account                     -0.00
\n

Header structure:

the first field all fields to the right
0000/00/00 A single line escription including spaces
  1. The very first field, e.g, Awk's $1, must be interpreted a date.
  2. All the remaining fields, e.g. Awk's $2 though $FN, must be interpreted as a single line description.

Body structure:

all fields to the left the last field
Assets:Account with spaces 0.00
Liabilities:AccountNoSpaces -0.00
  1. The last field, e.g, Awk's $NF, must be interpreted as decimal value.
  2. All the previous fields, e.g. Awk's $1 though $NF-1, must be interpreted as a single account name.

Rules:

  • A transaction is a record.
  • A record contains a header and a body.
  • The first line is the header, and the following lines are the body.
  • The header contains its date and an optional description.
  • The body contains a set of entries, each in it's corresponding line.
  • Each entry has the name of an account along with a mandatory value.
  • The records are separated by blank lines (cookie-jar format with records separated by blank lines).
  • When printing, the transaction description and the entry values may be aligned to the right.

Print example:

2004/09/29                       Circuit City
Assets:Reimbursements:Company XYZ      100.00
Liabilities:MasterCard                -100.00

2004/10/15                        Company XYZ
Assets:Checking                        100.00
Assets:Reimbursements:Company XYZ     -100.00

2004/09/29                       Circuit City
Assets:Reimbursements:Company XYZ      100.00
Liabilities:MasterCard                -100.00

2004/10/15                        Company XYZ
Assets:Checking                        100.00
Assets:Reimbursements:Company XYZ     -100.00

2004/09/29                       Circuit City
Assets:Reimbursements:Company XYZ      100.00
Liabilities:MasterCard                -100.00

2004/10/15                        Company XYZ
Assets:Checking                        100.00
Assets:Reimbursements:Company XYZ     -100.00

2004/09/29                       Circuit City
Assets:Reimbursements:Company XYZ      100.00
Liabilities:MasterCard                -100.00

2004/10/15                        Company XYZ
Assets:Checking                        100.00
Assets:Reimbursements:Company XYZ     -100.00

2004/09/29                       Circuit City
Assets:Reimbursements:Company XYZ      100.00
Liabilities:MasterCard                -100.00

2004/10/15                        Company XYZ
Assets:Checking                        100.00
Assets:Reimbursements:Company XYZ     -100.00

2004/09/29                       Circuit City
Assets:Reimbursements:Company XYZ      100.00
Liabilities:MasterCard                -100.00

2004/10/15                        Company XYZ
Assets:Checking                        100.00
Assets:Reimbursements:Company XYZ     -100.00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment