diff --git a/Hledger/Cli/Commands/Stats.hs b/Hledger/Cli/Commands/Stats.hs index 43d6b5a31..4db849037 100644 --- a/Hledger/Cli/Commands/Stats.hs +++ b/Hledger/Cli/Commands/Stats.hs @@ -72,7 +72,9 @@ showStats _ _ l today = tnum7 = length $ filter withinlast7 ts withinlast7 t = d >= addDays (-7) today && (d<=today) where d = tdate t txnrate7 = fromIntegral tnum7 / 7 :: Double - acctnum = length $ accounts l - acctdepth = maximum $ map (accountNameLevel.aname) $ accounts l + acctnum = length as + acctdepth | null as = 0 + | otherwise = maximum $ map (accountNameLevel.aname) as + as = accounts l cs = Map.elems $ commodities l diff --git a/tests/stats-empty-file.test b/tests/stats-empty-file.test new file mode 100644 index 000000000..ba06eb8a4 --- /dev/null +++ b/tests/stats-empty-file.test @@ -0,0 +1,3 @@ +bin/hledger -f- stats +<<< +>>> /Accounts.* 0 \(depth 0\)/