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
+11 -13
View File
@@ -1,9 +1,8 @@
// Package rules applies the ordered glob rules from rules.toml to
// transactions, deciding their automatic tag and whether they are a transfer
// between the user's own accounts.
// transactions, deciding their automatic tag.
//
// Only the rule_* columns are ever written. Manual edits made in the TUI live
// in separate columns and survive any number of re-runs.
// Only rule_tag is ever written. A tag set by hand in the TUI lives in its own
// column and survives any number of re-runs.
package rules
import (
@@ -76,17 +75,16 @@ func (e *Engine) Usage(txns []model.Transaction) []int {
return counts
}
// ApplyTxn returns the tag and transfer flag for a transaction. An unmatched
// transaction gets an empty tag and is not a transfer.
func (e *Engine) ApplyTxn(accountSlug string, t model.Transaction) (tag string, transfer bool) {
// ApplyTxn returns the tag for a transaction, empty if no rule matches.
func (e *Engine) ApplyTxn(accountSlug string, t model.Transaction) string {
if r := e.Match(accountSlug, t); r != nil {
return r.Tag, r.Transfer
return r.Tag
}
return "", false
return ""
}
// Apply is the description-only shorthand, for callers that have nothing else.
func (e *Engine) Apply(accountSlug, description string) (tag string, transfer bool) {
func (e *Engine) Apply(accountSlug, description string) string {
return e.ApplyTxn(accountSlug, model.Transaction{Description: description})
}
@@ -99,11 +97,11 @@ func (e *Engine) Retag(db *store.DB) (int, error) {
}
var changed []store.RuleAssignment
for _, t := range txns {
tag, transfer := e.ApplyTxn(t.AccountSlug, t)
if tag == t.RuleTag && transfer == t.RuleTransfer {
tag := e.ApplyTxn(t.AccountSlug, t)
if tag == t.RuleTag {
continue
}
changed = append(changed, store.RuleAssignment{ID: t.ID, Tag: tag, Transfer: transfer})
changed = append(changed, store.RuleAssignment{ID: t.ID, Tag: tag})
}
if len(changed) == 0 {
return 0, nil