Skip to content
Permalink
Browse files

reg: test and fix for --average, broken since 1.12 (#1003)

  • Loading branch information...
simonmichael committed Apr 6, 2019
1 parent 71f9b74 commit 13dc1096a51964aa5e99ee113d167ace3fee9cbd
Showing with 20 additions and 2 deletions.
  1. +2 −2 hledger-lib/Hledger/Reports/PostingsReport.hs
  2. +18 −0 tests/register/average.test
@@ -81,8 +81,8 @@ postingsReport opts q j = (totallabel, items)
startbal | average_ opts = if historical then precedingavg else 0
| otherwise = if historical then precedingsum else 0
startnum = if historical then length precedingps + 1 else 1
runningcalc | average_ opts = \i avg amt -> divideMixedAmount (fromIntegral i) avg + amt - avg -- running average
| otherwise = \_ bal amt -> bal + amt -- running total
runningcalc | average_ opts = \i avg amt -> avg + divideMixedAmount (fromIntegral i) (amt - avg) -- running average
| otherwise = \_ bal amt -> bal + amt -- running total

totallabel = "Total"

@@ -0,0 +1,18 @@
2019-1-1
(a) 1.0

2019-1-2
(a) 1

2019-1-3
(a) 1

2019-1-4
(a) 1

$ hledger -f- register -A
2019/01/01 (a) 1.0 1.0
2019/01/02 (a) 1.0 1.0
2019/01/03 (a) 1.0 1.0
2019/01/04 (a) 1.0 1.0
>=

0 comments on commit 13dc109

Please sign in to comment.
You can’t perform that action at this time.