dev: more thorough Journal anonymisation, and a note (#1817)

This commit is contained in:
Simon Michael 2022-01-29 09:19:45 -10:00
parent 3472c3cb6d
commit 248ddf9378
2 changed files with 8 additions and 3 deletions

View File

@ -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.

View File

@ -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