From 445e80fd41e1ab8aac559f816a8a3bfd1f20955b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 2 Nov 2024 15:48:04 -1000 Subject: [PATCH] dev:clarify: rename jcommodities to jdeclaredcommodities --- hledger-lib/Hledger/Data/Journal.hs | 14 +++++++------- hledger-lib/Hledger/Data/JournalChecks.hs | 2 +- hledger-lib/Hledger/Data/Types.hs | 4 ++-- hledger-lib/Hledger/Read/Common.hs | 4 ++-- hledger-lib/Hledger/Read/JournalReader.hs | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 102a551a6..57cd3071e 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -205,7 +205,7 @@ journalDbg j@Journal{..} = chomp $ unlines $ ,"jdeclaredaccounttypes: " <> shw jdeclaredaccounttypes ,"jaccounttypes: " <> shw jaccounttypes ,"jglobalcommoditystyles: " <> shw jglobalcommoditystyles - ,"jcommodities: " <> shw jcommodities + ,"jdeclaredcommodities: " <> shw jdeclaredcommodities ,"jinferredcommoditystyles: " <> shw jinferredcommoditystyles ,"jpricedirectives: " <> shw jpricedirectives ,"jinferredmarketprices: " <> shw jinferredmarketprices @@ -279,8 +279,8 @@ journalConcat j1 j2 = -- ,jglobalcommoditystyles :: M.Map CommoditySymbol AmountStyle ,jglobalcommoditystyles = (<>) (jglobalcommoditystyles j1) (jglobalcommoditystyles j2) -- - -- ,jcommodities :: M.Map CommoditySymbol Commodity - ,jcommodities = (<>) (jcommodities j1) (jcommodities j2) + -- ,jdeclaredcommodities :: M.Map CommoditySymbol Commodity + ,jdeclaredcommodities = (<>) (jdeclaredcommodities j1) (jdeclaredcommodities j2) -- -- ,jinferredcommoditystyles :: M.Map CommoditySymbol AmountStyle ,jinferredcommoditystyles = (<>) (jinferredcommoditystyles j1) (jinferredcommoditystyles j2) @@ -343,7 +343,7 @@ nulljournal = Journal { ,jdeclaredaccounttypes = M.empty ,jaccounttypes = M.empty ,jglobalcommoditystyles = M.empty - ,jcommodities = M.empty + ,jdeclaredcommodities = M.empty ,jinferredcommoditystyles = M.empty ,jpricedirectives = [] ,jinferredmarketprices = [] @@ -404,11 +404,11 @@ showJournalAmountsDebug = show.map showMixedAmountOneLine.journalPostingAmounts -- | Sorted unique commodity symbols declared by commodity directives in this journal. journalCommoditiesDeclared :: Journal -> [CommoditySymbol] -journalCommoditiesDeclared = M.keys . jcommodities +journalCommoditiesDeclared = M.keys . jdeclaredcommodities -- | Sorted unique commodity symbols declared or inferred from this journal. journalCommodities :: Journal -> S.Set CommoditySymbol -journalCommodities j = M.keysSet (jcommodities j) <> M.keysSet (jinferredcommoditystyles j) +journalCommodities j = M.keysSet (jdeclaredcommodities j) <> M.keysSet (jinferredcommoditystyles j) -- | Unique transaction descriptions used in this journal. journalDescriptions :: Journal -> [Text] @@ -891,7 +891,7 @@ journalCommodityStyles j = globalstyles <> declaredstyles <> defaultcommoditystyle <> inferredstyles where globalstyles = jglobalcommoditystyles j - declaredstyles = M.mapMaybe cformat $ jcommodities j + declaredstyles = M.mapMaybe cformat $ jdeclaredcommodities j defaultcommoditystyle = M.fromList $ catMaybes [jparsedefaultcommodity j] inferredstyles = jinferredcommoditystyles j diff --git a/hledger-lib/Hledger/Data/JournalChecks.hs b/hledger-lib/Hledger/Data/JournalChecks.hs index ddb21ba41..870fd7c88 100644 --- a/hledger-lib/Hledger/Data/JournalChecks.hs +++ b/hledger-lib/Hledger/Data/JournalChecks.hs @@ -84,7 +84,7 @@ journalCheckCommodities j = do mapM_ checkPriceDirectiveCommodities $ jpricedirectives j mapM_ checkPostingCommodities $ journalPostings j where - firstUndeclaredOf comms = find (`M.notMember` jcommodities j) comms + firstUndeclaredOf comms = find (`M.notMember` jdeclaredcommodities j) comms errmsg = unlines [ "%s:%d:" diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index 694500cf6..bcb39e906 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -596,8 +596,8 @@ data Journal = Journal { ,jdeclaredaccounttags :: M.Map AccountName [Tag] -- ^ Accounts which have tags declared in their directives, and those tags. (Does not include parents' tags.) ,jdeclaredaccounttypes :: M.Map AccountType [AccountName] -- ^ Accounts whose type has been explicitly declared in their account directives, grouped by type. ,jaccounttypes :: M.Map AccountName AccountType -- ^ All accounts for which a type has been declared or can be inferred from its parent or its name. - ,jglobalcommoditystyles :: M.Map CommoditySymbol AmountStyle -- ^ per-commodity display styles declared globally, eg by command line option or import command - ,jcommodities :: M.Map CommoditySymbol Commodity -- ^ commodities and formats declared by commodity directives + ,jdeclaredcommodities :: M.Map CommoditySymbol Commodity -- ^ commodities (and display styles) declared by commodity directives + ,jglobalcommoditystyles :: M.Map CommoditySymbol AmountStyle -- ^ per-commodity display styles declared globally, usually by command line options (see also the import command) ,jinferredcommoditystyles :: M.Map CommoditySymbol AmountStyle -- ^ commodity styles inferred from journal amounts ,jpricedirectives :: [PriceDirective] -- ^ Declarations of market prices by P directives, in parse order (after journal finalisation) ,jinferredmarketprices :: [MarketPrice] -- ^ Market prices implied by transactions, in parse order (after journal finalisation) diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 72fd08e5a..4e2e3770c 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -436,8 +436,8 @@ getDefaultAmountStyle = fmap snd <$> getDefaultCommodityAndStyle -- prior to the current position) commodity directive for the given commodity, if any. getAmountStyle :: CommoditySymbol -> JournalParser m (Maybe AmountStyle) getAmountStyle commodity = do - Journal{jcommodities} <- get - let mspecificStyle = M.lookup commodity jcommodities >>= cformat + Journal{jdeclaredcommodities} <- get + let mspecificStyle = M.lookup commodity jdeclaredcommodities >>= cformat mdefaultStyle <- fmap snd <$> getDefaultCommodityAndStyle return $ listToMaybe $ catMaybes [mspecificStyle, mdefaultStyle] diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 120c6eb19..a08084edf 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -374,7 +374,7 @@ includedirectivep = do ,jparseparentaccounts = jparseparentaccounts j ,jparsedecimalmark = jparsedecimalmark j ,jparsealiases = jparsealiases j - ,jcommodities = jcommodities j + ,jdeclaredcommodities = jdeclaredcommodities j -- ,jparsetransactioncount = jparsetransactioncount j ,jparsetimeclockentries = jparsetimeclockentries j ,jincludefilestack = filepath : jincludefilestack j @@ -509,7 +509,7 @@ commoditydirectiveonelinep = do let comm = Commodity{csymbol=acommodity, cformat=Just $ dbg6 "style from commodity directive" astyle} if isNothing $ asdecimalmark astyle then customFailure $ parseErrorAt off pleaseincludedecimalpoint - else modify' (\j -> j{jcommodities=M.insert acommodity comm $ jcommodities j}) + else modify' (\j -> j{jdeclaredcommodities=M.insert acommodity comm $ jdeclaredcommodities j}) pleaseincludedecimalpoint :: String pleaseincludedecimalpoint = chomp $ unlines [ @@ -535,7 +535,7 @@ commoditydirectivemultilinep = do subdirectives <- many $ indented (eitherP (formatdirectivep sym) (lift restofline)) let mfmt = lastMay $ lefts subdirectives let comm = Commodity{csymbol=sym, cformat=mfmt} - modify' (\j -> j{jcommodities=M.insert sym comm $ jcommodities j}) + modify' (\j -> j{jdeclaredcommodities=M.insert sym comm $ jdeclaredcommodities j}) where indented = (lift skipNonNewlineSpaces1 >>)