lib: generateAutomaticPostings -> applyTransactionModifiers
This commit is contained in:
parent
bb36693155
commit
eae9d78bb1
@ -31,7 +31,7 @@ module Hledger.Read.Common (
|
|||||||
rjp,
|
rjp,
|
||||||
genericSourcePos,
|
genericSourcePos,
|
||||||
journalSourcePos,
|
journalSourcePos,
|
||||||
generateAutomaticPostings,
|
applyTransactionModifiers,
|
||||||
parseAndFinaliseJournal,
|
parseAndFinaliseJournal,
|
||||||
setYear,
|
setYear,
|
||||||
getYear,
|
getYear,
|
||||||
@ -204,9 +204,10 @@ journalSourcePos p p' = JournalSourcePos (sourceName p) (fromIntegral . unPos $
|
|||||||
| otherwise = unPos $ sourceLine p' -- might be at end of file withat last new-line
|
| otherwise = unPos $ sourceLine p' -- might be at end of file withat last new-line
|
||||||
|
|
||||||
|
|
||||||
-- | Generate Automatic postings and add them to the current journal.
|
-- | Apply any transaction modifier rules in the journal
|
||||||
generateAutomaticPostings :: Journal -> Journal
|
-- (adding automated postings to transactions, eg).
|
||||||
generateAutomaticPostings j = j { jtxns = map applyallmodifiers $ jtxns j }
|
applyTransactionModifiers :: Journal -> Journal
|
||||||
|
applyTransactionModifiers j = j { jtxns = map applyallmodifiers $ jtxns j }
|
||||||
where
|
where
|
||||||
applyallmodifiers =
|
applyallmodifiers =
|
||||||
foldr (flip (.) . transactionModifierToFunction Q.Any) id (jtxnmodifiers j)
|
foldr (flip (.) . transactionModifierToFunction Q.Any) id (jtxnmodifiers j)
|
||||||
@ -221,7 +222,7 @@ parseAndFinaliseJournal parser iopts f txt = do
|
|||||||
ep <- liftIO $ runParserT (evalStateT parser nulljournal {jparsedefaultyear=Just y}) f txt
|
ep <- liftIO $ runParserT (evalStateT parser nulljournal {jparsedefaultyear=Just y}) f txt
|
||||||
case ep of
|
case ep of
|
||||||
Right pj ->
|
Right pj ->
|
||||||
let pj' = if auto_ iopts then generateAutomaticPostings pj else pj in
|
let pj' = if auto_ iopts then applyTransactionModifiers pj else pj in
|
||||||
case journalFinalise t f txt (not $ ignore_assertions_ iopts) pj' of
|
case journalFinalise t f txt (not $ ignore_assertions_ iopts) pj' of
|
||||||
Right j -> return j
|
Right j -> return j
|
||||||
Left e -> throwError e
|
Left e -> throwError e
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module Hledger.Cli.Utils
|
|||||||
journalTransform,
|
journalTransform,
|
||||||
journalApplyValue,
|
journalApplyValue,
|
||||||
journalAddForecast,
|
journalAddForecast,
|
||||||
generateAutomaticPostings,
|
applyTransactionModifiers, -- XXX why reexported here ?
|
||||||
journalReload,
|
journalReload,
|
||||||
journalReloadIfChanged,
|
journalReloadIfChanged,
|
||||||
journalFileIsNewer,
|
journalFileIsNewer,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user