Add money: statement-driven personal finance tracker

A data directory holds one folder per account. Statements dropped into
those folders are parsed into a rebuildable SQLite index, categorised by
ordered glob rules in rules.toml, and browsed or hand-tagged in a Bubble
Tea TUI. Movements between the user's own accounts are marked as
transfers by the same rules and excluded from spending totals.

Manual tags and transfer marks are stored separately from the rule-derived
ones and always win, so editing rules.toml and re-running retag never
destroys hand edits.

Parsers are pluggable. Three are ported from the Python extractors they
replace -- nlb and traderepublic read PDFs via pdftotext -layout, revolut
reads the CSV export -- alongside a configurable-column CSV parser and a
cmd parser that shells out to an external script.

Both ports fix two latent bugs in the originals: the sign character class
rejected the typographic minus U+2212 that some PDF fonts emit, and NLB's
hardcoded continuation indent broke when pdftotext compressed runs of
spaces, so the threshold is now measured from the description column.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-09 00:37:20 +02:00
co-authored by Claude Opus 5
commit b0026c5a79
30 changed files with 5048 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
// Package glob implements the tiny wildcard language used by rules.toml.
//
// Only '*' (any run of characters, including none) and '?' (exactly one
// character) are special; everything else matches literally. Unlike path.Match
// there is no separator handling, because we match statement descriptions, not
// paths. Matching is case-insensitive.
package glob
import "strings"
// Match reports whether s matches pattern.
func Match(pattern, s string) bool {
return match([]rune(strings.ToUpper(pattern)), []rune(strings.ToUpper(s)))
}
// match is the classic two-pointer wildcard algorithm: linear time, no
// backtracking blowup on patterns like "*a*a*a*".
func match(p, s []rune) bool {
var (
pi, si int
star = -1 // index in p of the last '*' seen
starMatch int // index in s that '*' was assumed to match up to
hasStar bool
)
for si < len(s) {
switch {
case pi < len(p) && (p[pi] == '?' || p[pi] == s[si]):
pi++
si++
case pi < len(p) && p[pi] == '*':
star, hasStar = pi, true
starMatch = si
pi++
case hasStar:
// Backtrack: let the last '*' swallow one more character.
starMatch++
pi, si = star+1, starMatch
default:
return false
}
}
for pi < len(p) && p[pi] == '*' {
pi++
}
return pi == len(p)
}