dev:journalTransform: cleanup

This commit is contained in:
Simon Michael 2024-01-21 10:25:55 -10:00
parent f3073990cc
commit 0cdc012fd9

View File

@ -57,6 +57,7 @@ import Hledger.Read
import Hledger.Reports import Hledger.Reports
import Hledger.Utils import Hledger.Utils
import Control.Monad (when) import Control.Monad (when)
import Data.Functor ((<&>))
-- | Standard error message for a bad output format specified with -O/-o. -- | Standard error message for a bad output format specified with -O/-o.
unsupportedOutputFormatError :: String -> String unsupportedOutputFormatError :: String -> String
@ -74,22 +75,18 @@ withJournalDo opts cmd = do
j <- runExceptT $ journalTransform opts <$> readJournalFiles (inputopts_ opts) journalpaths j <- runExceptT $ journalTransform opts <$> readJournalFiles (inputopts_ opts) journalpaths
either error' cmd j -- PARTIAL: either error' cmd j -- PARTIAL:
-- | Apply some extra post-parse transformations to the journal, if -- | Apply some extra post-parse transformations to the journal, if enabled by options.
-- specified by options. These happen after journal validation, but -- These happen after parsing and finalising the journal, but before report calculation.
-- before report calculation. They include: -- They are, in processing order:
-- --
-- - adding forecast transactions (--forecast)
-- - pivoting account names (--pivot) -- - pivoting account names (--pivot)
--
-- - anonymising (--anonymise). -- - anonymising (--anonymise).
-- --
-- This will return an error message if the query in any auto posting rule fails
-- to parse, or the generated transactions are not balanced.
journalTransform :: CliOpts -> Journal -> Journal journalTransform :: CliOpts -> Journal -> Journal
journalTransform opts = journalTransform opts =
anonymiseByOpts opts pivotByOpts opts
-- - converting amounts to market value (--value) <&> anonymiseByOpts opts
-- . journalApplyValue ropts
. pivotByOpts opts
-- | Apply the pivot transformation on a journal, if option is present. -- | Apply the pivot transformation on a journal, if option is present.
pivotByOpts :: CliOpts -> Journal -> Journal pivotByOpts :: CliOpts -> Journal -> Journal