clarify modifiedaccountnamep

This commit is contained in:
Simon Michael 2015-09-24 14:23:52 -10:00
parent f4c963b648
commit 591abefe9e
2 changed files with 12 additions and 10 deletions

View File

@ -31,7 +31,7 @@ module Hledger.Read.JournalReader (
datetimep, datetimep,
codep, codep,
accountnamep, accountnamep,
modifiedaccountname, modifiedaccountnamep,
postingp, postingp,
amountp, amountp,
amountp', amountp',
@ -577,7 +577,7 @@ postingp = do
many1 spacenonewline many1 spacenonewline
status <- statusp status <- statusp
many spacenonewline many spacenonewline
account <- modifiedaccountname account <- modifiedaccountnamep
let (ptype, account') = (accountNamePostingType account, unbracket account) let (ptype, account') = (accountNamePostingType account, unbracket account)
amount <- spaceandamountormissing amount <- spaceandamountormissing
massertion <- partialbalanceassertion massertion <- partialbalanceassertion
@ -657,13 +657,15 @@ test_postingp = do
#endif #endif
-- | Parse an account name, then apply any parent account prefix and/or account aliases currently in effect. -- | Parse an account name, then apply any parent account prefix and/or account aliases currently in effect.
modifiedaccountname :: Stream [Char] m Char => ParsecT [Char] JournalContext m AccountName modifiedaccountnamep :: Stream [Char] m Char => ParsecT [Char] JournalContext m AccountName
modifiedaccountname = do modifiedaccountnamep = do
a <- accountnamep parent <- getParentAccount
prefix <- getParentAccount
let prefixed = prefix `joinAccountNames` a
aliases <- getAccountAliases aliases <- getAccountAliases
return $ accountNameApplyAliases aliases prefixed a <- accountnamep
return $
accountNameApplyAliases aliases $
joinAccountNames parent
a
-- | Parse an account name. Account names start with a non-space, may -- | Parse an account name. Account names start with a non-space, may
-- have single spaces inside them, and are terminated by two or more -- have single spaces inside them, and are terminated by two or more

View File

@ -61,7 +61,7 @@ import Hledger.Data
-- XXX too much reuse ? -- XXX too much reuse ?
import Hledger.Read.JournalReader ( import Hledger.Read.JournalReader (
directive, marketpricedirective, defaultyeardirective, emptyorcommentlinep, datetimep, directive, marketpricedirective, defaultyeardirective, emptyorcommentlinep, datetimep,
parseJournalWith, modifiedaccountname, genericSourcePos parseJournalWith, modifiedaccountnamep, genericSourcePos
) )
import Hledger.Utils import Hledger.Utils
@ -107,7 +107,7 @@ timelogentry = do
code <- oneOf "bhioO" code <- oneOf "bhioO"
many1 spacenonewline many1 spacenonewline
datetime <- datetimep datetime <- datetimep
account <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> modifiedaccountname) account <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> modifiedaccountnamep)
description <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> restofline) description <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> restofline)
return $ TimeLogEntry sourcepos (read [code]) datetime account description return $ TimeLogEntry sourcepos (read [code]) datetime account description