diff --git a/hledger/Hledger/Cli/Balance.hs b/hledger/Hledger/Cli/Balance.hs index 6f7a0e500..885bb5715 100644 --- a/hledger/Hledger/Cli/Balance.hs +++ b/hledger/Hledger/Cli/Balance.hs @@ -132,8 +132,7 @@ type BalanceReportItem = (AccountName -- full account name balance :: [Opt] -> [String] -> Journal -> IO () balance opts args j = do t <- getCurrentLocalTime - let j' = journalSelectingDate (whichDateFromOpts opts) j - putStr $ balanceReportAsText opts $ balanceReport opts (optsToFilterSpec opts args t) j' + putStr $ balanceReportAsText opts $ balanceReport opts (optsToFilterSpec opts args t) j -- | Render a balance report as plain text suitable for console output. balanceReportAsText :: [Opt] -> BalanceReport -> String @@ -166,7 +165,8 @@ balanceReport opts filterspec j = (items, total) acctnames = sort $ tail $ flatten $ treemap aname accttree accttree = ledgerAccountTree (fromMaybe 99999 $ depthFromOpts opts) l total = sum $ map abalance $ ledgerTopAccounts l - l = journalToLedger filterspec j + l = journalToLedger filterspec j' + j' = journalSelectingDate (whichDateFromOpts opts) j -- | Get data for one balance report line item. mkitem :: AccountName -> BalanceReportItem mkitem a = (a, adisplay, indent, abal) diff --git a/hledger/Hledger/Cli/Print.hs b/hledger/Hledger/Cli/Print.hs index 012b41cb3..ced8a5af8 100644 --- a/hledger/Hledger/Cli/Print.hs +++ b/hledger/Hledger/Cli/Print.hs @@ -32,15 +32,16 @@ type JournalReportItem = Transaction print' :: [Opt] -> [String] -> Journal -> IO () print' opts args j = do t <- getCurrentLocalTime - let j' = journalSelectingDate (whichDateFromOpts opts) j - putStr $ showTransactions opts (optsToFilterSpec opts args t) j' + putStr $ showTransactions opts (optsToFilterSpec opts args t) j showTransactions :: [Opt] -> FilterSpec -> Journal -> String -showTransactions opts fspec j = journalReportAsText opts fspec $ journalReport [] fspec j +showTransactions opts fspec j = journalReportAsText opts fspec $ journalReport opts fspec j journalReportAsText :: [Opt] -> FilterSpec -> JournalReport -> String journalReportAsText opts _ items = concatMap (showTransactionForPrint effective) items where effective = Effective `elem` opts journalReport :: [Opt] -> FilterSpec -> Journal -> JournalReport -journalReport _ fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j +journalReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j' + where j' = journalSelectingDate (whichDateFromOpts opts) j +