Skip to content

Commit 6a74f58

Browse files
committed
register: aggregation by tags or payee
1 parent 12090e3 commit 6a74f58

14 files changed

Lines changed: 434 additions & 223 deletions

File tree

TODO.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### Features
22

3+
- register: aggregate by tags, payee, etc
34
- thousand separator in amounts
45
- check for account/cc numbers in transactions
56
- balance: last reconciled posting date
@@ -24,8 +25,9 @@
2425

2526
### coin2html
2627

27-
- update user docs in README (details, balances, screenshots ...)
2828
- allow dropping subaccounts from aggregations (in both chart and register)
29+
- show reconciliation state in balance view (last reconciled date? vs balance date?)
30+
- show reconciliation flag in non-aggregated register
2931
- filter subaccounts, payee, tag...
3032
- brush to select date range
3133
- buttons to reset To/From to Min/Max date
@@ -35,6 +37,7 @@
3537
- tooltips for columns, inputs and wherever useful
3638
- preserve UI state in history (make back/forward buttons work)
3739
- trim to time range on export (need to recalc posting balances!)
40+
- trim to account subtree (need to recalc outer posting balances!)
3841
- show commodities and prices
3942
- investment performance summary
4043

cmd/coin/register.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,22 @@ func (cmd *cmdRegister) execute(f io.Writer) {
101101
}
102102
}
103103

104-
func (cmd *cmdRegister) flatAggregatedRegister(f io.Writer, acc *coin.Account, by *reducer) {
104+
func (cmd *cmdRegister) flatAggregatedRegister(f io.Writer, acc *coin.Account, by *timeReducer) {
105105
totals := accountTotals{}
106106
acc.WithChildrenDo(func(a *coin.Account) {
107107
ts := totals.newTotals(a, by)
108108
for _, p := range cmd.trim(a.Postings) {
109-
ts.add(p.Transaction.Posted, p.Quantity)
109+
ts.add(p)
110110
}
111111
})
112112
var accounts []*coin.Account
113113
totals, accounts = totals.top(cmd.top)
114114
top := totals[accounts[0]]
115+
// propagate timelines from totals up to top
115116
for _, ts := range totals {
116-
top.mergeTime(ts)
117+
if ts != top { top.mergeTime(ts) }
117118
}
119+
// propagate full timeline from top down to other totals
118120
totals.mergeTime(top)
119121
if cmd.cumulative {
120122
totals.makeCumulative()
@@ -133,12 +135,12 @@ func (cmd *cmdRegister) flatAggregatedRegister(f io.Writer, acc *coin.Account, b
133135
totals.output(f, accounts, label, cmd.output)
134136
}
135137

136-
func (cmd *cmdRegister) recursiveAggregatedRegister(f io.Writer, acc *coin.Account, by *reducer) {
138+
func (cmd *cmdRegister) recursiveAggregatedRegister(f io.Writer, acc *coin.Account, by *timeReducer) {
137139
totals := accountTotals{}
138140
acc.WithChildrenDo(func(a *coin.Account) {
139141
ts := totals.newTotals(a, by)
140142
for _, p := range cmd.trim(a.Postings) {
141-
ts.add(p.Transaction.Posted, p.Quantity)
143+
ts.add(p)
142144
}
143145
})
144146
if cmd.recurse {
@@ -176,7 +178,7 @@ func (cmd *cmdRegister) recursiveAggregatedRegister(f io.Writer, acc *coin.Accou
176178
totals.output(f, accounts, label, cmd.output)
177179
}
178180

179-
func (cmd *cmdRegister) period() *reducer {
181+
func (cmd *cmdRegister) period() *timeReducer {
180182
switch {
181183
case cmd.weekly:
182184
return &week

0 commit comments

Comments
 (0)