Skip to content

Commit f7a188f

Browse files
committed
add readme
1 parent 58740a6 commit f7a188f

File tree

2 files changed

+177
-0
lines changed

2 files changed

+177
-0
lines changed

Diff for: README.md

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
2+
# ledger.bash
3+
4+
This is a watered down version of [the ledger cli](https://github.com/ledger/ledger) that focuses on a simple budgeting work-flow.
5+
The project started with some bash, SQLite and JavaScript utilities that I used with my ledger setup.
6+
I realized I could implement the ledger features I needed relatively quickly in AWK and customize it along the way.
7+
8+
# Examples
9+
10+
Here is a sample journal file.
11+
12+
```
13+
; Budget rules
14+
15+
= ^Income
16+
[Savings] -0.25
17+
[Unbudgeted] -0.75
18+
19+
= ^Expenses
20+
[$account] -1.0
21+
22+
; Transactions
23+
24+
2020/01/01 Salary
25+
Assets:Bank:Checking $500
26+
Income
27+
28+
2020/01/01 Adjust Budget
29+
[Expenses:Food] $100
30+
[Expenses:Fun] $50
31+
[Unbudgeted]
32+
33+
2020/01/01 Walmart
34+
Expenses:Food $50
35+
Assets:Bank:Checking
36+
37+
2020/02/01 AMC
38+
Expenses:Fun $20
39+
Assets:Bank:Checking
40+
```
41+
42+
The budget rules activate on transactions to/from accounts that match the supplied regular expression.
43+
This journal allocates 25% of earnings to a savings envelope and sets the rest aside to be budgeted manually as needed (see second transaction).
44+
In addition, an envelope is created for each expense account.
45+
46+
Check the balance of your accounts.
47+
```
48+
$ ledger.bash bal
49+
$430.00 Assets:Bank:Checking
50+
$70.00 Expenses
51+
$50.00 Food
52+
$20.00 Fun
53+
$-500.00 Income
54+
--------------------
55+
0.00
56+
```
57+
58+
Check your budget.
59+
```
60+
$ ledger.bash bal --budget
61+
$80.00 Expenses
62+
$50.00 Food
63+
$30.00 Fun
64+
$125.00 Savings
65+
$225.00 Unbudgeted
66+
--------------------
67+
430.00
68+
```
69+
70+
Filter accounts.
71+
```
72+
$ ledger.bash bal Fun
73+
$20.00 Expenses:Fun
74+
--------------------
75+
20.00
76+
```
77+
78+
Date range.
79+
```
80+
$ ledger.bash bal --start 2020/02
81+
$-20.00 Assets:Bank:Checking
82+
$20.00 Expenses:Fun
83+
--------------------
84+
0.00
85+
```
86+
87+
Monthly (or yearly) totals. The depth argument here gives us the monthly total of the Expenses parent account.
88+
```
89+
$ ledger.bash monthly --depth 1 Expenses
90+
2020/01 Expenses $50.00
91+
2020/02 Expenses $20.00
92+
```
93+
94+
Import a CSV of bank transactions.
95+
```
96+
$ ledger.bash import Checking.csv
97+
...
98+
$ cat ledger-imported.dat
99+
```
100+
101+
This command is interactive and requires [FZF](https://github.com/junegunn/fzf).
102+
It helps you assign payee and account names to each transaction and formats it.
103+
You can write a bash script that auto assigns payee and account names.
104+
105+
```bash
106+
$ cat ledger-import-helper.bash
107+
shopt -s nocasematch
108+
assign_payee_and_account() {
109+
local dt="$1"
110+
local desc="$2"
111+
local amt="$3"
112+
case "$desc" in
113+
*walmart*)
114+
payee="Walmart"
115+
account="Expenses:Food"
116+
;;
117+
*)
118+
payee="$desc"
119+
account="Expenses:Misc"
120+
esac
121+
}
122+
$ export LEDGER_IMPORT_HELPER=ledger-import-helper.bash
123+
```
124+
125+
The script should contain a function named `assign_payee_and_account` that assigns global variables `payee` and `account`.
126+
This makes importing really fast for me because most of my transactions are from the same place.
127+
128+
The CSV parsing is currently specific to my bank but the AWK script is parameterized to handle other formats.
129+
It just needs to know whether the fields are quoted and which fields hold the date, description and amount.
130+
131+
When importing a CSV, you don't need to worry about selecting a date range.
132+
Import will start after the last date in your journal file.
133+
You can also check for consistency with your bank record after importing.
134+
135+
```
136+
$ ledger.bash check Checking.csv Assets:Bank:Checking
137+
Potential problems with Assets:Bank:Checking
138+
Date Expected Actual
139+
...
140+
```
141+
142+
This command reports a difference in daily totals which has caught all problems for me so far.
143+
144+
Other commands:
145+
146+
- List transactions in CSV format
147+
- List accounts
148+
- List payees
149+
- Open SQLite database with transactions table (date, payee, account, amount).
150+

Diff for: example.ledger

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; Budget rules
2+
3+
= ^Income
4+
[Savings] -0.25
5+
[Unbudgeted] -0.75
6+
7+
= ^Expenses
8+
[$account] -1.0
9+
10+
; Transactions
11+
12+
2020/01/01 Salary
13+
Assets:Bank:Checking $500
14+
Income
15+
16+
2020/01/01 Adjust Budget
17+
[Expenses:Food] $100
18+
[Expenses:Fun] $50
19+
[Unbudgeted]
20+
21+
2020/01/01 Walmart
22+
Expenses:Food $50
23+
Assets:Bank:Checking
24+
25+
2020/02/01 AMC
26+
Expenses:Fun $20
27+
Assets:Bank:Checking

0 commit comments

Comments
 (0)