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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user