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:
+6
-38
@@ -1,5 +1,5 @@
|
||||
// Package tui is the terminal interface: browse accounts, tag transactions,
|
||||
// mark transfers by hand, and see where the money went.
|
||||
// and see where the money went.
|
||||
package tui
|
||||
|
||||
import (
|
||||
@@ -191,7 +191,6 @@ func New(root string, db *store.DB, accounts []*config.Account, engine *rules.En
|
||||
{Title: "Account", Width: 12},
|
||||
{Title: "Amount", Width: 12},
|
||||
{Title: "Tag", Width: 14},
|
||||
{Title: "T", Width: 1},
|
||||
{Title: "Description", Width: 40},
|
||||
}),
|
||||
ruleGlob: newInput("*LIDL*"),
|
||||
@@ -209,7 +208,6 @@ func New(root string, db *store.DB, accounts []*config.Account, engine *rules.En
|
||||
{Title: "Pattern", Width: 34},
|
||||
{Title: "Account", Width: 12},
|
||||
{Title: "Tag", Width: 14},
|
||||
{Title: "T", Width: 1},
|
||||
{Title: "Txns", Width: 6},
|
||||
{Title: "Note", Width: 24},
|
||||
}),
|
||||
@@ -269,16 +267,12 @@ func (m *Model) reloadTxns() error {
|
||||
|
||||
rows := make([]table.Row, 0, len(txns))
|
||||
for _, t := range txns {
|
||||
transfer := ""
|
||||
if t.IsTransfer() {
|
||||
transfer = "T"
|
||||
}
|
||||
tag := t.Tag()
|
||||
if tag != "" && t.ManualTag != "" {
|
||||
tag += "*" // marks a manual override
|
||||
}
|
||||
rows = append(rows, table.Row{
|
||||
t.Date, t.AccountSlug, t.FormatAmount(), tag, transfer, t.Description,
|
||||
t.Date, t.AccountSlug, t.FormatAmount(), tag, t.Description,
|
||||
})
|
||||
}
|
||||
// Keep the cursor in range after the row count shrinks (e.g. tagging the
|
||||
@@ -573,16 +567,12 @@ func (m *Model) reloadRuleList() error {
|
||||
if m.ruleUsage[i] == 0 {
|
||||
marker = "✗"
|
||||
}
|
||||
transfer := ""
|
||||
if r.Transfer {
|
||||
transfer = "T"
|
||||
}
|
||||
account := r.Account
|
||||
if account == "" {
|
||||
account = "(all)"
|
||||
}
|
||||
rows = append(rows, table.Row{
|
||||
fmt.Sprintf("%d", i+1), marker, rulePattern(r), account, r.Tag, transfer,
|
||||
fmt.Sprintf("%d", i+1), marker, rulePattern(r), account, r.Tag,
|
||||
fmt.Sprintf("%d", m.ruleUsage[i]), r.Note,
|
||||
})
|
||||
}
|
||||
@@ -1116,30 +1106,8 @@ func (m *Model) updateNormal(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
m.text.Focus()
|
||||
return m, nil
|
||||
|
||||
case "x":
|
||||
// Toggle the manual transfer override away from whatever is in effect.
|
||||
if m.view != viewTxns {
|
||||
return m, nil
|
||||
}
|
||||
t, ok := m.selected()
|
||||
if !ok {
|
||||
return m, nil
|
||||
}
|
||||
v := !t.IsTransfer()
|
||||
if err := m.db.SetManualTransfer(t.ID, &v); err != nil {
|
||||
m.err = err
|
||||
return m, nil
|
||||
}
|
||||
if v {
|
||||
m.status = "marked as transfer"
|
||||
} else {
|
||||
m.status = "unmarked as transfer"
|
||||
}
|
||||
m.err = m.reloadTxns()
|
||||
return m, nil
|
||||
|
||||
case "c":
|
||||
// Drop manual overrides and fall back to what the rules say.
|
||||
// Drop the manual tag and fall back to what the rules say.
|
||||
if m.view != viewTxns {
|
||||
return m, nil
|
||||
}
|
||||
@@ -1386,7 +1354,7 @@ func (m *Model) title() string {
|
||||
}
|
||||
return fmt.Sprintf("money · rules · %d rules · %d match nothing", len(m.engine.Rules()), unused)
|
||||
case viewReport:
|
||||
return "money · report · " + scope + " · transfers excluded"
|
||||
return "money · report · " + scope
|
||||
default:
|
||||
return fmt.Sprintf("money · transactions · %s · %d rows", scope, len(m.txns))
|
||||
}
|
||||
@@ -1421,6 +1389,6 @@ func (m *Model) help() string {
|
||||
case viewReport:
|
||||
return "1 accounts · 2 transactions · 4 new rule · 5 rules · u untagged · a all accounts · q quit"
|
||||
default:
|
||||
return "t tag · x transfer · c clear · / search · u untagged · a all · i import · r retag · 4 new rule · 5 rules · q quit"
|
||||
return "t tag · c clear · / search · u untagged · a all · i import · r retag · 4 new rule · 5 rules · q quit"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user