mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 10:17:35 +03:00
cashflow: make totals row and -N more like balance/bs/is (#518)
This commit is contained in:
parent
b658a6b843
commit
e50dede708
@ -15,7 +15,7 @@ module Hledger.Cli.BalanceView (
|
||||
) where
|
||||
|
||||
import Control.Monad (unless)
|
||||
import Data.List (intercalate, foldl')
|
||||
import Data.List (intercalate, foldl', isPrefixOf)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Monoid (Sum(..), (<>))
|
||||
import System.Console.CmdArgs.Explicit as C
|
||||
@ -100,7 +100,8 @@ multiBalanceviewQueryReport
|
||||
-> ([Table String String MixedAmount], [[MixedAmount]], Sum MixedAmount)
|
||||
multiBalanceviewQueryReport ropts q0 j t q = ([tabl], [coltotals], Sum tot)
|
||||
where
|
||||
ropts' = ropts { no_total_ = False, empty_ = True }
|
||||
singlesection = "Cash" `isPrefixOf` t -- TODO temp
|
||||
ropts' = ropts { no_total_ = singlesection && no_total_ ropts, empty_ = True }
|
||||
q' = And [q0, q j]
|
||||
MultiBalanceReport (dates, rows, (coltotals,tot,avg)) =
|
||||
multiBalanceReport ropts' q' j
|
||||
@ -114,7 +115,7 @@ multiBalanceviewQueryReport ropts q0 j t q = ([tabl], [coltotals], Sum tot)
|
||||
|
||||
-- | Prints out a balance report according to a given view
|
||||
balanceviewReport :: BalanceView -> CliOpts -> Journal -> IO ()
|
||||
balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts, rawopts_=raw} j = do
|
||||
balanceviewReport BalanceView{..} CliOpts{command_=cmd, reportopts_=ropts, rawopts_=raw} j = do
|
||||
currDay <- getCurrentDay
|
||||
let q0 = queryFromOpts currDay ropts'
|
||||
let title = bvtitle ++ maybe "" (' ':) balanceclarification
|
||||
@ -125,7 +126,7 @@ balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts, rawopts_=raw} j = d
|
||||
bvqueries
|
||||
mapM_ putStrLn (title : "" : views)
|
||||
|
||||
unless (no_total_ ropts') . mapM_ putStrLn $
|
||||
unless (no_total_ ropts' || cmd=="cashflow") . mapM_ putStrLn $ -- TODO temp
|
||||
[ "Total:"
|
||||
, "--------------------"
|
||||
, padleft 20 $ showMixedAmountWithoutPrice (getSum amt)
|
||||
|
@ -12,9 +12,6 @@ Cash flows:
|
||||
--------------------
|
||||
1
|
||||
|
||||
Total:
|
||||
--------------------
|
||||
1
|
||||
>>>2
|
||||
>>>= 0
|
||||
|
||||
@ -48,9 +45,6 @@ Cash flows:
|
||||
--------------------
|
||||
$-40.00
|
||||
|
||||
Total:
|
||||
--------------------
|
||||
$-40.00
|
||||
>>>2
|
||||
>>>= 0
|
||||
|
||||
@ -84,9 +78,6 @@ Cash flows:
|
||||
--------------------
|
||||
$9,960.00
|
||||
|
||||
Total:
|
||||
--------------------
|
||||
$9,960.00
|
||||
>>>2
|
||||
>>>= 0
|
||||
|
||||
@ -120,9 +111,6 @@ Cash flows:
|
||||
--------------------
|
||||
$10,000.00
|
||||
|
||||
Total:
|
||||
--------------------
|
||||
$10,000.00
|
||||
>>>2
|
||||
>>>= 0
|
||||
|
||||
@ -155,9 +143,6 @@ Cash flows:
|
||||
--------------------
|
||||
0
|
||||
|
||||
Total:
|
||||
--------------------
|
||||
0
|
||||
>>>2
|
||||
>>>= 0
|
||||
|
||||
@ -179,7 +164,7 @@ Cashflow Statement
|
||||
|
||||
>>>= 0
|
||||
|
||||
# 6. Multicolumn test (historical)
|
||||
# 7. Multicolumn test (historical)
|
||||
hledger -f sample.journal cashflow -p 'monthly in 2008' -A --historical
|
||||
>>>
|
||||
Cashflow Statement (Historical Ending Balances)
|
||||
@ -196,3 +181,65 @@ Cashflow Statement (Historical Ending Balances)
|
||||
|
||||
|
||||
>>>= 0
|
||||
|
||||
# 8. without -N/--no-total (single column)
|
||||
hledger -f sample.journal cf
|
||||
>>>
|
||||
Cashflow Statement
|
||||
|
||||
Cash flows:
|
||||
$-1 assets
|
||||
$1 bank:saving
|
||||
$-2 cash
|
||||
--------------------
|
||||
$-1
|
||||
|
||||
>>>2
|
||||
>>>=
|
||||
|
||||
# 9. with -N (single column)
|
||||
hledger -f sample.journal cf -N
|
||||
>>>
|
||||
Cashflow Statement
|
||||
|
||||
Cash flows:
|
||||
$-1 assets
|
||||
$1 bank:saving
|
||||
$-2 cash
|
||||
|
||||
>>>2
|
||||
>>>=
|
||||
|
||||
# 10. without -N (multi column)
|
||||
hledger -f sample.journal cf -Y
|
||||
>>>
|
||||
Cashflow Statement
|
||||
|
||||
|| 2008
|
||||
====================++=======
|
||||
Cash flows ||
|
||||
--------------------++-------
|
||||
assets:bank:saving || $1
|
||||
assets:cash || $-2
|
||||
--------------------++-------
|
||||
|| $-1
|
||||
|
||||
|
||||
>>>2
|
||||
>>>=
|
||||
|
||||
# 11. with -N (multi column)
|
||||
hledger -f sample.journal cf -Y -N
|
||||
>>>
|
||||
Cashflow Statement
|
||||
|
||||
|| 2008
|
||||
====================++=======
|
||||
Cash flows ||
|
||||
--------------------++-------
|
||||
assets:bank:saving || $1
|
||||
assets:cash || $-2
|
||||
|
||||
|
||||
>>>2
|
||||
>>>=
|
||||
|
Loading…
Reference in New Issue
Block a user