@@ -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