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
|
,"jdeclaredaccounttypes: " <> shw jdeclaredaccounttypes
|
||||||
,"jaccounttypes: " <> shw jaccounttypes
|
,"jaccounttypes: " <> shw jaccounttypes
|
||||||
,"jglobalcommoditystyles: " <> shw jglobalcommoditystyles
|
,"jglobalcommoditystyles: " <> shw jglobalcommoditystyles
|
||||||
,"jcommodities: " <> shw jcommodities
|
,"jdeclaredcommodities: " <> shw jdeclaredcommodities
|
||||||
,"jinferredcommoditystyles: " <> shw jinferredcommoditystyles
|
,"jinferredcommoditystyles: " <> shw jinferredcommoditystyles
|
||||||
,"jpricedirectives: " <> shw jpricedirectives
|
,"jpricedirectives: " <> shw jpricedirectives
|
||||||
,"jinferredmarketprices: " <> shw jinferredmarketprices
|
,"jinferredmarketprices: " <> shw jinferredmarketprices
|
||||||
@ -279,8 +279,8 @@ journalConcat j1 j2 =
|
|||||||
-- ,jglobalcommoditystyles :: M.Map CommoditySymbol AmountStyle
|
-- ,jglobalcommoditystyles :: M.Map CommoditySymbol AmountStyle
|
||||||
,jglobalcommoditystyles = (<>) (jglobalcommoditystyles j1) (jglobalcommoditystyles j2)
|
,jglobalcommoditystyles = (<>) (jglobalcommoditystyles j1) (jglobalcommoditystyles j2)
|
||||||
--
|
--
|
||||||
-- ,jcommodities :: M.Map CommoditySymbol Commodity
|
-- ,jdeclaredcommodities :: M.Map CommoditySymbol Commodity
|
||||||
,jcommodities = (<>) (jcommodities j1) (jcommodities j2)
|
,jdeclaredcommodities = (<>) (jdeclaredcommodities j1) (jdeclaredcommodities j2)
|
||||||
--
|
--
|
||||||
-- ,jinferredcommoditystyles :: M.Map CommoditySymbol AmountStyle
|
-- ,jinferredcommoditystyles :: M.Map CommoditySymbol AmountStyle
|
||||||
,jinferredcommoditystyles = (<>) (jinferredcommoditystyles j1) (jinferredcommoditystyles j2)
|
,jinferredcommoditystyles = (<>) (jinferredcommoditystyles j1) (jinferredcommoditystyles j2)
|
||||||
@ -343,7 +343,7 @@ nulljournal = Journal {
|
|||||||
,jdeclaredaccounttypes = M.empty
|
,jdeclaredaccounttypes = M.empty
|
||||||
,jaccounttypes = M.empty
|
,jaccounttypes = M.empty
|
||||||
,jglobalcommoditystyles = M.empty
|
,jglobalcommoditystyles = M.empty
|
||||||
,jcommodities = M.empty
|
,jdeclaredcommodities = M.empty
|
||||||
,jinferredcommoditystyles = M.empty
|
,jinferredcommoditystyles = M.empty
|
||||||
,jpricedirectives = []
|
,jpricedirectives = []
|
||||||
,jinferredmarketprices = []
|
,jinferredmarketprices = []
|
||||||
@ -404,11 +404,11 @@ showJournalAmountsDebug = show.map showMixedAmountOneLine.journalPostingAmounts
|
|||||||
|
|
||||||
-- | Sorted unique commodity symbols declared by commodity directives in this journal.
|
-- | Sorted unique commodity symbols declared by commodity directives in this journal.
|
||||||
journalCommoditiesDeclared :: Journal -> [CommoditySymbol]
|
journalCommoditiesDeclared :: Journal -> [CommoditySymbol]
|
||||||
journalCommoditiesDeclared = M.keys . jcommodities
|
journalCommoditiesDeclared = M.keys . jdeclaredcommodities
|
||||||
|
|
||||||
-- | Sorted unique commodity symbols declared or inferred from this journal.
|
-- | Sorted unique commodity symbols declared or inferred from this journal.
|
||||||
journalCommodities :: Journal -> S.Set CommoditySymbol
|
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.
|
-- | Unique transaction descriptions used in this journal.
|
||||||
journalDescriptions :: Journal -> [Text]
|
journalDescriptions :: Journal -> [Text]
|
||||||
@ -891,7 +891,7 @@ journalCommodityStyles j =
|
|||||||
globalstyles <> declaredstyles <> defaultcommoditystyle <> inferredstyles
|
globalstyles <> declaredstyles <> defaultcommoditystyle <> inferredstyles
|
||||||
where
|
where
|
||||||
globalstyles = jglobalcommoditystyles j
|
globalstyles = jglobalcommoditystyles j
|
||||||
declaredstyles = M.mapMaybe cformat $ jcommodities j
|
declaredstyles = M.mapMaybe cformat $ jdeclaredcommodities j
|
||||||
defaultcommoditystyle = M.fromList $ catMaybes [jparsedefaultcommodity j]
|
defaultcommoditystyle = M.fromList $ catMaybes [jparsedefaultcommodity j]
|
||||||
inferredstyles = jinferredcommoditystyles j
|
inferredstyles = jinferredcommoditystyles j
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ journalCheckCommodities j = do
|
|||||||
mapM_ checkPriceDirectiveCommodities $ jpricedirectives j
|
mapM_ checkPriceDirectiveCommodities $ jpricedirectives j
|
||||||
mapM_ checkPostingCommodities $ journalPostings j
|
mapM_ checkPostingCommodities $ journalPostings j
|
||||||
where
|
where
|
||||||
firstUndeclaredOf comms = find (`M.notMember` jcommodities j) comms
|
firstUndeclaredOf comms = find (`M.notMember` jdeclaredcommodities j) comms
|
||||||
|
|
||||||
errmsg = unlines [
|
errmsg = unlines [
|
||||||
"%s:%d:"
|
"%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.)
|
,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.
|
,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.
|
,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
|
,jdeclaredcommodities :: M.Map CommoditySymbol Commodity -- ^ commodities (and display styles) declared by commodity directives
|
||||||
,jcommodities :: M.Map CommoditySymbol Commodity -- ^ commodities and formats 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
|
,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)
|
,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)
|
,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.
|
-- prior to the current position) commodity directive for the given commodity, if any.
|
||||||
getAmountStyle :: CommoditySymbol -> JournalParser m (Maybe AmountStyle)
|
getAmountStyle :: CommoditySymbol -> JournalParser m (Maybe AmountStyle)
|
||||||
getAmountStyle commodity = do
|
getAmountStyle commodity = do
|
||||||
Journal{jcommodities} <- get
|
Journal{jdeclaredcommodities} <- get
|
||||||
let mspecificStyle = M.lookup commodity jcommodities >>= cformat
|
let mspecificStyle = M.lookup commodity jdeclaredcommodities >>= cformat
|
||||||
mdefaultStyle <- fmap snd <$> getDefaultCommodityAndStyle
|
mdefaultStyle <- fmap snd <$> getDefaultCommodityAndStyle
|
||||||
return $ listToMaybe $ catMaybes [mspecificStyle, mdefaultStyle]
|
return $ listToMaybe $ catMaybes [mspecificStyle, mdefaultStyle]
|
||||||
|
|
||||||
|
|||||||
@ -374,7 +374,7 @@ includedirectivep = do
|
|||||||
,jparseparentaccounts = jparseparentaccounts j
|
,jparseparentaccounts = jparseparentaccounts j
|
||||||
,jparsedecimalmark = jparsedecimalmark j
|
,jparsedecimalmark = jparsedecimalmark j
|
||||||
,jparsealiases = jparsealiases j
|
,jparsealiases = jparsealiases j
|
||||||
,jcommodities = jcommodities j
|
,jdeclaredcommodities = jdeclaredcommodities j
|
||||||
-- ,jparsetransactioncount = jparsetransactioncount j
|
-- ,jparsetransactioncount = jparsetransactioncount j
|
||||||
,jparsetimeclockentries = jparsetimeclockentries j
|
,jparsetimeclockentries = jparsetimeclockentries j
|
||||||
,jincludefilestack = filepath : jincludefilestack j
|
,jincludefilestack = filepath : jincludefilestack j
|
||||||
@ -509,7 +509,7 @@ commoditydirectiveonelinep = do
|
|||||||
let comm = Commodity{csymbol=acommodity, cformat=Just $ dbg6 "style from commodity directive" astyle}
|
let comm = Commodity{csymbol=acommodity, cformat=Just $ dbg6 "style from commodity directive" astyle}
|
||||||
if isNothing $ asdecimalmark astyle
|
if isNothing $ asdecimalmark astyle
|
||||||
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
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 :: String
|
||||||
pleaseincludedecimalpoint = chomp $ unlines [
|
pleaseincludedecimalpoint = chomp $ unlines [
|
||||||
@ -535,7 +535,7 @@ commoditydirectivemultilinep = do
|
|||||||
subdirectives <- many $ indented (eitherP (formatdirectivep sym) (lift restofline))
|
subdirectives <- many $ indented (eitherP (formatdirectivep sym) (lift restofline))
|
||||||
let mfmt = lastMay $ lefts subdirectives
|
let mfmt = lastMay $ lefts subdirectives
|
||||||
let comm = Commodity{csymbol=sym, cformat=mfmt}
|
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
|
where
|
||||||
indented = (lift skipNonNewlineSpaces1 >>)
|
indented = (lift skipNonNewlineSpaces1 >>)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user