register, print: fix reverse ordering of same-day transactions

This commit is contained in:
Simon Michael 2012-06-29 18:06:58 +00:00
parent 6ccecb6ae0
commit 34318906d8
3 changed files with 7 additions and 5 deletions

View File

@ -167,9 +167,9 @@ data Journal = Journal {
final_comment_lines :: String, -- ^ any trailing comments from the journal file
jContext :: JournalContext, -- ^ the context (parse state) at the end of parsing
files :: [(FilePath, String)], -- ^ the file path and raw text of the main and
-- any included journal files. The main file is
-- first followed by any included files in the
-- order encountered.
-- any included journal files. The main file is
-- first followed by any included files in the
-- order encountered (XXX reversed, cf journalAddFile).
filereadtime :: ClockTime -- ^ when this journal was last read from its file(s)
} deriving (Eq, Typeable)

View File

@ -79,7 +79,7 @@ parse _ = -- trace ("running "++format++" reader") .
-- | Flatten a list of JournalUpdate's into a single equivalent one.
combineJournalUpdates :: [JournalUpdate] -> JournalUpdate
combineJournalUpdates us = liftM (foldl' (flip (.)) id) $ sequence us
combineJournalUpdates us = liftM (foldl' (.) id) $ sequence us
-- | Given a JournalUpdate-generating parsec parser, file path and data string,
-- parse and post-process a Journal so that it's ready to use, or give an error.
@ -191,6 +191,7 @@ includedirective = do
journalAddFile :: (FilePath,String) -> Journal -> Journal
journalAddFile f j@Journal{files=fs} = j{files=fs++[f]}
-- XXX currently called in reverse order of includes, I can't see why
accountdirective :: GenParser Char JournalContext JournalUpdate
accountdirective = do

View File

@ -42,7 +42,8 @@ showLedgerStats l today span =
-- w2 = maximum $ map (length . show . snd) stats
stats = [
("Main journal file", path) -- ++ " (from " ++ source ++ ")")
,("Included journal files", unlines $ drop 1 $ journalFilePaths j)
,("Included journal files", unlines $ reverse $ -- cf journalAddFile
drop 1 $ journalFilePaths j)
,("Transactions span", printf "%s to %s (%d days)" (start span) (end span) days)
,("Last transaction", maybe "none" show lastdate ++ showelapsed lastelapsed)
,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)