diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index 5fc92a6f1..c709d00b3 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -530,6 +530,8 @@ data Journal = Journal { -- TODO: FilePath is a sloppy type here, don't assume it's a -- real file; values like "", "-", "(string)" can be seen ,jlastreadtime :: POSIXTime -- ^ when this journal was last read from its file(s) + -- NOTE: after adding new fields, eg involving account names, consider updating + -- the Anon instance in Hleger.Cli.Anon } deriving (Eq, Generic) -- | A journal in the process of being parsed, not yet finalised. diff --git a/hledger/Hledger/Cli/Anon.hs b/hledger/Hledger/Cli/Anon.hs index 0fb71dbd2..0b2d1815c 100644 --- a/hledger/Hledger/Cli/Anon.hs +++ b/hledger/Hledger/Cli/Anon.hs @@ -19,6 +19,7 @@ import Numeric (showHex) import qualified Data.Text as T import Hledger.Data +import Data.Map (mapKeys) class Anon a where -- | Consistent converter to structure with sensitive data anonymized @@ -27,9 +28,11 @@ class Anon a where instance Anon Journal where -- Apply the anonymisation transformation on a journal after finalisation anon j = j { jtxns = map anon . jtxns $ j - , jparseparentaccounts = map anonAccount $ jparseparentaccounts j - , jparsealiases = [] -- already applied - , jdeclaredaccounts = map (first anon) $ jdeclaredaccounts j + , jparseparentaccounts = map anonAccount $ jparseparentaccounts j + , jparsealiases = [] -- already applied + , jdeclaredaccounts = map (first anon) $ jdeclaredaccounts j + , jdeclaredaccounttags = mapKeys anon $ jdeclaredaccounttags j + , jdeclaredaccounttypes = (map anon) <$> jdeclaredaccounttypes j } instance Anon Posting where