Merge pull request #188 from rdesfo/0.23

0.23
This commit is contained in:
Simon Michael 2014-05-12 13:24:32 -07:00
commit 820f230c31
2 changed files with 17 additions and 12 deletions

View File

@ -97,8 +97,8 @@ tests_Hledger_Cli = TestList
,"account directive should preserve \"virtual\" posting type" ~: do
j <- readJournal Nothing Nothing Nothing "!account test\n2008/12/07 One\n (from) $-1\n (to) $1\n" >>= either error' return
let p = head $ tpostings $ head $ jtxns j
assertBool "" $ (paccount p) == "test:from"
assertBool "" $ (ptype p) == VirtualPosting
assertBool "" $ paccount p == "test:from"
assertBool "" $ ptype p == VirtualPosting
]
@ -188,6 +188,7 @@ sample_journal_str = unlines
]
-}
defaultyear_journal_str :: String
defaultyear_journal_str = unlines
["Y2009"
,""
@ -337,9 +338,10 @@ defaultyear_journal_str = unlines
-- ,""
-- ]
journal7 :: Journal
journal7 = nulljournal {jtxns =
[
txnTieKnot $ Transaction {
txnTieKnot Transaction {
tdate=parsedate "2007/01/01",
tdate2=Nothing,
tstatus=False,
@ -354,7 +356,7 @@ journal7 = nulljournal {jtxns =
tpreceding_comment_lines=""
}
,
txnTieKnot $ Transaction {
txnTieKnot Transaction {
tdate=parsedate "2007/02/01",
tdate2=Nothing,
tstatus=False,
@ -369,7 +371,7 @@ journal7 = nulljournal {jtxns =
tpreceding_comment_lines=""
}
,
txnTieKnot $ Transaction {
txnTieKnot Transaction {
tdate=parsedate "2007/01/02",
tdate2=Nothing,
tstatus=False,
@ -384,7 +386,7 @@ journal7 = nulljournal {jtxns =
tpreceding_comment_lines=""
}
,
txnTieKnot $ Transaction {
txnTieKnot Transaction {
tdate=parsedate "2007/01/03",
tdate2=Nothing,
tstatus=False,
@ -399,7 +401,7 @@ journal7 = nulljournal {jtxns =
tpreceding_comment_lines=""
}
,
txnTieKnot $ Transaction {
txnTieKnot Transaction {
tdate=parsedate "2007/01/03",
tdate2=Nothing,
tstatus=False,
@ -414,7 +416,7 @@ journal7 = nulljournal {jtxns =
tpreceding_comment_lines=""
}
,
txnTieKnot $ Transaction {
txnTieKnot Transaction {
tdate=parsedate "2007/01/03",
tdate2=Nothing,
tstatus=False,
@ -431,4 +433,5 @@ journal7 = nulljournal {jtxns =
]
}
ledger7 :: Ledger
ledger7 = ledgerFromJournal Any journal7

View File

@ -6,6 +6,7 @@ Print a histogram report. (The "activity" command).
module Hledger.Cli.Histogram
where
import Data.List
import Data.Maybe
import Data.Ord
@ -19,8 +20,8 @@ import Hledger.Query
import Prelude hiding (putStr)
import Hledger.Utils.UTF8IOCompat (putStr)
activitymode = (defCommandMode $ ["activity"] ++ aliases) {
activitymode :: Mode RawOpts
activitymode = (defCommandMode $ ["activity"] : aliases) {
modeHelp = "show an ascii barchart of posting counts per interval (default: daily)" `withAliases` aliases
,modeHelpSuffix = []
,modeGroupFlags = Group {
@ -31,6 +32,7 @@ activitymode = (defCommandMode $ ["activity"] ++ aliases) {
}
where aliases = []
barchar :: Char
barchar = '*'
-- | Print a histogram of some statistic per reporting interval, such as
@ -46,8 +48,8 @@ showHistogram opts q j = concatMap (printDayWith countBar) spanps
i = intervalFromOpts opts
interval | i == NoInterval = Days 1
| otherwise = i
span = queryDateSpan (date2_ opts) q `spanDefaultsFrom` journalDateSpan (date2_ opts) j
spans = filter (DateSpan Nothing Nothing /=) $ splitSpan interval span
span' = queryDateSpan (date2_ opts) q `spanDefaultsFrom` journalDateSpan (date2_ opts) j
spans = filter (DateSpan Nothing Nothing /=) $ splitSpan interval span'
spanps = [(s, filter (isPostingInDateSpan s) ps) | s <- spans]
-- same as Register
-- should count transactions, not postings ?