mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-29 13:22:27 +03:00
dev: more thorough Journal anonymisation, and a note (#1817)
This commit is contained in:
parent
3472c3cb6d
commit
248ddf9378
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user