import: sort new transactions by date, across files

This commit is contained in:
Simon Michael 2017-09-21 10:31:15 -10:00
parent 25074aec0e
commit 0b7a50d0f0

View File

@ -8,6 +8,8 @@ module Hledger.Cli.Commands.Import (
where where
import Control.Monad import Control.Monad
import Data.List
import Data.Ord
import Data.String.Here import Data.String.Here
import Hledger import Hledger
import Hledger.Cli.CliOptions import Hledger.Cli.CliOptions
@ -46,7 +48,7 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do
case enewj of case enewj of
Left e -> error' e Left e -> error' e
Right newj -> Right newj ->
case jtxns newj of case sortBy (comparing tdate) $ jtxns newj of
[] -> putStrLn "no new transactions" [] -> putStrLn "no new transactions"
newts | dryrun -> do newts | dryrun -> do
printf "would import %d new transactions:\n\n" (length newts) printf "would import %d new transactions:\n\n" (length newts)