diff --git a/hledger-lib/Hledger/Query.hs b/hledger-lib/Hledger/Query.hs index 1f4d3934d..bad3cb0f2 100644 --- a/hledger-lib/Hledger/Query.hs +++ b/hledger-lib/Hledger/Query.hs @@ -49,6 +49,7 @@ module Hledger.Query ( matchesCommodity, matchesPriceDirective, words'', + prefixes, -- * tests tests_Query ) diff --git a/hledger-web/Hledger/Web/Foundation.hs b/hledger-web/Hledger/Web/Foundation.hs index c4e5cb4fc..ea4b05426 100644 --- a/hledger-web/Hledger/Web/Foundation.hs +++ b/hledger-web/Hledger/Web/Foundation.hs @@ -122,7 +122,7 @@ instance Yesod App where -- flip the default for items with zero amounts, show them by default ropts' = ropts { empty_ = not (empty_ ropts) } accounts = - balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j qopts $ + balanceReportAsHtml (JournalR, RegisterR) here hideEmptyAccts j q qopts $ balanceReport ropts' m j topShowmd = if showSidebar then "col-md-4" else "col-any-0" :: Text diff --git a/hledger-web/Hledger/Web/Widget/Common.hs b/hledger-web/Hledger/Web/Widget/Common.hs index 73902c6c9..43d4f189e 100644 --- a/hledger-web/Hledger/Web/Widget/Common.hs +++ b/hledger-web/Hledger/Web/Widget/Common.hs @@ -37,6 +37,7 @@ import Yesod import Hledger import Hledger.Cli.Utils (writeFileWithBackupIfChanged) import Hledger.Web.Settings (manualurl) +import qualified Hledger.Query as Query #if MIN_VERSION_yesod(1,6,0) journalFile404 :: FilePath -> Journal -> HandlerFor m (FilePath, Text) @@ -82,8 +83,8 @@ helplink topic label _ = H.a ! A.href u ! A.target "hledgerhelp" $ toHtml label where u = textValue $ manualurl <> if T.null topic then "" else T.cons '#' topic -- | Render a "BalanceReport" as html. -balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> [QueryOpt] -> BalanceReport -> HtmlUrl r -balanceReportAsHtml (journalR, registerR) here hideEmpty j qopts (items, total) = +balanceReportAsHtml :: Eq r => (r, r) -> r -> Bool -> Journal -> Text -> [QueryOpt] -> BalanceReport -> HtmlUrl r +balanceReportAsHtml (journalR, registerR) here hideEmpty j q qopts (items, total) = $(hamletFile "templates/balance-report.hamlet") where l = ledgerFromJournal Any j @@ -113,3 +114,13 @@ transactionFragment j = in \t -> printf "transaction-%d-%d" (hm HashMap.! sourceFilePath (tsourcepos t)) (tindex t) + +removeInacct :: Text -> [Text] +removeInacct = + map quoteIfSpaced . + filter (\term -> + not $ T.isPrefixOf "inacct:" term || T.isPrefixOf "inacctonly:" term) . + Query.words'' Query.prefixes + +replaceInacct :: Text -> Text -> Text +replaceInacct q acct = T.unwords $ acct : removeInacct q diff --git a/hledger-web/templates/balance-report.hamlet b/hledger-web/templates/balance-report.hamlet index 2476c36dc..14529edde 100644 --- a/hledger-web/templates/balance-report.hamlet +++ b/hledger-web/templates/balance-report.hamlet @@ -11,11 +11,11 @@ $forall (acct, adisplay, aindent, abal) <- items
\#{indent aindent} - #{adisplay} $if hasSubAccounts acct - only ^{mixedAmountAsHtml abal}