dev:clarify: rename jcommodities to jdeclaredcommodities
This commit is contained in:
parent
80fa7e2db6
commit
445e80fd41
@ -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
|
||||
|
||||
|
||||
@ -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:"
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
@ -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 >>)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user