Remove the transfer flag

A transfer was a second verdict carried alongside the tag: a boolean set by
transfer = true in a rule or by x in the TUI, kept in its own pair of rule_
and manual_ columns, whose one real effect was to hold the row out of the
report. The rest of it was display -- a T column in the transaction list, in
the rules screen and in money ls.

Money moved between your own accounts is now tagged like anything else and
counts like anything else. The leg leaving checking is an outflow and the leg
arriving in savings is an inflow, so a report over the whole data root roughly
nets out while one scoped to a single account or month does not. That is the
price of one verdict per transaction instead of two.

A rule now needs a tag, and one that set only transfer = true is refused by
number on load. A leftover transfer key beside a tag is ignored, as unknown
TOML keys always were, and an index built by an older binary drops both
columns when it is opened.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 23:07:47 +02:00
co-authored by Claude Opus 5
parent 16c2585637
commit 5ca6cff87b
13 changed files with 114 additions and 277 deletions
+7 -11
View File
@@ -26,10 +26,9 @@ const (
// Rule is one entry in rules.toml. Rules are evaluated in file order and the
// first one whose Match (and optional Account) matches wins.
type Rule struct {
Match string `toml:"match"`
Tag string `toml:"tag"`
Transfer bool `toml:"transfer"`
Account string `toml:"account"` // optional: restrict to one account slug
Match string `toml:"match"`
Tag string `toml:"tag"`
Account string `toml:"account"` // optional: restrict to one account slug
// Type matches the bank's own classification, e.g. Revolut's CARD_PAYMENT.
// Optional; when set, it must match as well as Match.
Type string `toml:"type"`
@@ -60,8 +59,8 @@ func LoadRules(root string) (*Rules, error) {
if rule.Match == "" && rule.Type == "" {
return nil, fmt.Errorf("%s: rule %d has no match or type pattern", path, i+1)
}
if rule.Tag == "" && !rule.Transfer {
return nil, fmt.Errorf("%s: rule %d (%q) sets neither tag nor transfer", path, i+1, rule.Match)
if rule.Tag == "" {
return nil, fmt.Errorf("%s: rule %d (%q) sets no tag", path, i+1, rule.Match)
}
}
return &r, nil
@@ -77,8 +76,8 @@ func AppendRule(root string, r Rule) error {
if r.Match == "" && r.Type == "" {
return fmt.Errorf("a rule needs a match or type pattern")
}
if r.Tag == "" && !r.Transfer {
return fmt.Errorf("a rule needs a tag or transfer = true")
if r.Tag == "" {
return fmt.Errorf("a rule needs a tag")
}
path := filepath.Join(root, RulesFile)
@@ -252,9 +251,6 @@ func formatRule(r Rule) string {
write("type", r.Type)
write("account", r.Account)
write("tag", r.Tag)
if r.Transfer {
b.WriteString("transfer = true\n")
}
// Last, so the patterns and the tag stay lined up above it however long
// the note runs.
write("note", r.Note)
+3 -7
View File
@@ -181,7 +181,7 @@ func TestAppendRuleRejectsIncomplete(t *testing.T) {
// Globs and tags containing quotes must survive the round trip.
func TestAppendRuleQuotesValues(t *testing.T) {
root := t.TempDir()
if err := AppendRule(root, Rule{Match: `*"ODD" PAYEE*`, Tag: "misc", Transfer: true}); err != nil {
if err := AppendRule(root, Rule{Match: `*"ODD" PAYEE*`, Tag: "misc"}); err != nil {
t.Fatal(err)
}
loaded, err := LoadRules(root)
@@ -191,9 +191,6 @@ func TestAppendRuleQuotesValues(t *testing.T) {
if loaded.Rule[0].Match != `*"ODD" PAYEE*` {
t.Errorf("match = %q, want the quotes preserved", loaded.Rule[0].Match)
}
if !loaded.Rule[0].Transfer {
t.Error("transfer flag was not written")
}
}
// A note is documentation carried with the rule. It is a key rather than a
@@ -267,9 +264,8 @@ tag = "salary"
# Moving money to myself.
[[rule]]
match = "*TO SAVINGS*"
transfer = true
tag = "transfer"
match = "*TO SAVINGS*"
tag = "transfer"
`
// Deleting must edit the file textually: a user's comments and layout are not