packages feed

hledger 0.19.1 → 0.19.2

raw patch · 5 files changed

+49/−70 lines, 5 files

Files

Hledger/Cli.hs view
@@ -23,9 +23,7 @@                      tests_Hledger_Cli               ) where-import qualified Data.Map as Map import Data.Time.Calendar-import System.Time (ClockTime(TOD)) import Test.HUnit  import Hledger@@ -110,12 +108,9 @@       "expenses","expenses:food","expenses:food:dining","expenses:phone","expenses:vacation",       "liabilities","liabilities:credit cards","liabilities:credit cards:discover"] -  ,"journalCanonicaliseAmounts" ~:-   "use the greatest precision" ~:-    (map precision $ journalAmountAndPriceCommodities $ journalCanonicaliseAmounts $ journalWithAmounts ["1","2.00"]) `is` [2,2]--  ,"commodities" ~:-    Map.elems (ledgerCommodities ledger7) `is` [Commodity {symbol="$", side=L, spaced=False, decimalpoint='.', precision=2, separator=',', separatorpositions=[]}]+  -- ,"journalCanonicaliseAmounts" ~:+  --  "use the greatest precision" ~:+  --   (map asprecision $ journalAmountAndPriceCommodities $ journalCanonicaliseAmounts $ journalWithAmounts ["1","2.00"]) `is` [2,2]    -- don't know what this should do   -- ,"elideAccountName" ~: do@@ -129,9 +124,9 @@     tdate (head $ jtxns j) `is` fromGregorian 2009 1 1     return () -  ,"show dollars" ~: showAmount (dollars 1) ~?= "$1.00"+  ,"show dollars" ~: showAmount (usd 1) ~?= "$1.00" -  ,"show hours" ~: showAmount (hours 1) ~?= "1.0h"+  ,"show hours" ~: showAmount (hrs 1) ~?= "1.0h"   ] @@ -337,9 +332,7 @@ --  ,"" --  ] -journal7 = Journal-          [] -          [] +journal7 = nulljournal {jtxns =            [            txnTieKnot $ Transaction {              tdate=parsedate "2007/01/01",@@ -353,7 +346,7 @@               Posting {                 pstatus=False,                 paccount="assets:cash",-                pamount=(Mixed [dollars 4.82]),+                pamount=(Mixed [usd 4.82]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -362,7 +355,7 @@               Posting {                 pstatus=False,                 paccount="equity:opening balances",-                pamount=(Mixed [dollars (-4.82)]),+                pamount=(Mixed [usd (-4.82)]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -384,7 +377,7 @@               Posting {                 pstatus=False,                 paccount="expenses:vacation",-                pamount=(Mixed [dollars 179.92]),+                pamount=(Mixed [usd 179.92]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -393,7 +386,7 @@               Posting {                 pstatus=False,                 paccount="assets:checking",-                pamount=(Mixed [dollars (-179.92)]),+                pamount=(Mixed [usd (-179.92)]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -415,7 +408,7 @@               Posting {                 pstatus=False,                 paccount="assets:saving",-                pamount=(Mixed [dollars 200]),+                pamount=(Mixed [usd 200]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -424,7 +417,7 @@               Posting {                 pstatus=False,                 paccount="assets:checking",-                pamount=(Mixed [dollars (-200)]),+                pamount=(Mixed [usd (-200)]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -446,7 +439,7 @@               Posting {                 pstatus=False,                 paccount="expenses:food:dining",-                pamount=(Mixed [dollars 4.82]),+                pamount=(Mixed [usd 4.82]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -455,7 +448,7 @@               Posting {                 pstatus=False,                 paccount="assets:cash",-                pamount=(Mixed [dollars (-4.82)]),+                pamount=(Mixed [usd (-4.82)]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -477,7 +470,7 @@               Posting {                 pstatus=False,                 paccount="expenses:phone",-                pamount=(Mixed [dollars 95.11]),+                pamount=(Mixed [usd 95.11]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -486,7 +479,7 @@               Posting {                 pstatus=False,                 paccount="assets:checking",-                pamount=(Mixed [dollars (-95.11)]),+                pamount=(Mixed [usd (-95.11)]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -508,7 +501,7 @@               Posting {                 pstatus=False,                 paccount="liabilities:credit cards:discover",-                pamount=(Mixed [dollars 80]),+                pamount=(Mixed [usd 80]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -517,7 +510,7 @@               Posting {                 pstatus=False,                 paccount="assets:checking",-                pamount=(Mixed [dollars (-80)]),+                pamount=(Mixed [usd (-80)]),                 pcomment="",                 ptype=RegularPosting,                 ptags=[],@@ -527,12 +520,7 @@              tpreceding_comment_lines=""            }           ]-          []-          []-          ""-          nullctx-          []-          (TOD 0 0)+         }  ledger7 = ledgerFromJournal Any journal7 @@ -549,20 +537,13 @@ -- timelogentry2_str  = "o 2007/03/11 16:30:00\n" -- timelogentry2 = TimeLogEntry Out (parsedatetime "2007/03/11 16:30:00") "" --- a1 = Mixed [(hours 1){price=Just $ Mixed [Amount (comm "$") 10 Nothing]}]--- a2 = Mixed [(hours 2){price=Just $ Mixed [Amount (comm "EUR") 10 Nothing]}]+-- a1 = Mixed [(hrs 1){aprice=Just $ Mixed [Amount (comm "$") 10 Nothing]}]+-- a2 = Mixed [(hrs 2){aprice=Just $ Mixed [Amount (comm "EUR") 10 Nothing]}] -- a3 = Mixed $ amounts a1 ++ amounts a2 -journalWithAmounts :: [String] -> Journal-journalWithAmounts as =-        Journal-        []-        []-        [t | a <- as, let t = nulltransaction{tdescription=a,tpostings=[nullposting{pamount=parse a,ptransaction=Just t}]}]-        []-        []-        ""-        nullctx-        []-        (TOD 0 0)-    where parse = fromparse . parseWithCtx nullctx amount+-- journalWithAmounts :: [String] -> Journal+-- journalWithAmounts as =+--        nulljournal{jtxns=+--         [t | a <- as, let t = nulltransaction{tdescription=a,tpostings=[nullposting{pamount=parse a,ptransaction=Just t}]}]+--         }+--     where parse = fromparse . parseWithCtx nullctx amountp
Hledger/Cli/Add.hs view
@@ -17,7 +17,6 @@ import Data.List import Data.Maybe import Data.Time.Calendar-import Safe (headMay) import System.Console.Haskeline (InputT, runInputT, defaultSettings, setComplete, getInputLine) import System.Console.Haskeline.Completion import System.IO ( stderr, hPutStrLn, hPutStr )@@ -148,22 +147,20 @@                 -- I think 1 or 4, whichever would show the most decimal places                 p = maxprecisionwithpoint       amountstr <- runInteractionDefault $ askFor (printf "amount  %d" n) defaultamountstr validateamount-      let a  = fromparse $ runParser (amount <|> return missingmixedamt) ctx     "" amountstr-          a' = fromparse $ runParser (amount <|> return missingmixedamt) nullctx "" amountstr-          defaultamtused = Just (showMixedAmount a) == defaultamountstr-          commodityadded | c == cwithnodef = Nothing-                         | otherwise       = c-              where c          = maybemixedamountcommodity a-                    cwithnodef = maybemixedamountcommodity a'-                    maybemixedamountcommodity = maybe Nothing (Just . commodity) . headMay . amounts-          p = nullposting{paccount=stripbrackets account,-                          pamount=a,-                          ptype=postingtype account}-          st' = if defaultamtused then st-                   else st{psHistory = historicalps',-                           psSuggestHistoricalAmount = False}-      when (isJust commodityadded) $-           liftIO $ hPutStrLn stderr $ printf "using default commodity (%s)" (symbol $ fromJust commodityadded)+      let a  = fromparse $ runParser (amountp <|> return missingamt) ctx     "" amountstr+          a' = fromparse $ runParser (amountp <|> return missingamt) nullctx "" amountstr+          wasdefaultamtused = Just (showAmount a) == defaultamountstr+          defaultcommodityadded | acommodity a == acommodity a' = Nothing+                                | otherwise                     = Just $ acommodity a+          p = nullposting{paccount=stripbrackets account+                         ,pamount=mixed a+                         ,ptype=postingtype account+                         }+          st' = if wasdefaultamtused+                 then st+                 else st{psHistory=historicalps', psSuggestHistoricalAmount=False}+      when (isJust defaultcommodityadded) $+           liftIO $ hPutStrLn stderr $ printf "using default commodity (%s)" (fromJust defaultcommodityadded)       getPostings st' (enteredps ++ [p])     where       j = psJournal st@@ -179,7 +176,7 @@       postingtype _ = RegularPosting       stripbrackets = dropWhile (`elem` "([") . reverse . dropWhile (`elem` "])") . reverse       validateamount = Just $ \s -> (null s && not (null enteredrealps))-                                   || isRight (runParser (amount>>many spacenonewline>>eof) ctx "" s)+                                   || isRight (runParser (amountp >> many spacenonewline >> eof) ctx "" s)  -- | Prompt for and read a string value, optionally with a default value -- and a validator. A validator causes the prompt to repeat until the
Hledger/Cli/Stats.hs view
@@ -62,7 +62,7 @@              path = journalFilePath j              ts = sortBy (comparing tdate) $ filter (spanContainsDate span . tdate) $ jtxns j              as = nub $ map paccount $ concatMap tpostings ts-             cs = Map.keys $ canonicaliseCommodities $ nub $ map commodity $ concatMap amounts $ map pamount $ concatMap tpostings ts+             cs = Map.keys $ canonicalStyles $ concatMap amounts $ map pamount $ concatMap tpostings ts              lastdate | null ts = Nothing                       | otherwise = Just $ tdate $ last ts              lastelapsed = maybe Nothing (Just . diffDays today) lastdate
Hledger/Cli/Utils.hs view
@@ -103,12 +103,13 @@ fileModificationTime f     | null f = getClockTime     | otherwise = (do+-- getModificationTime returned a ClockTime till GHC 7.6 (directory 1.2), now it's UTCTime #if __GLASGOW_HASKELL__ < 706         clo <- getModificationTime f #else         utc <- getModificationTime f         let nom = utcTimeToPOSIXSeconds utc-        let clo = TOD (read $ show nom) 0 -- XXX+        let clo = TOD (read $ takeWhile (`elem` "0123456789") $ show nom) 0 -- XXX read #endif         return clo         )
hledger.cabal view
@@ -1,6 +1,6 @@ name:           hledger -- also in cpp-options below-version: 0.19.1+version: 0.19.2 category:       Finance synopsis:       The main command-line interface for the hledger accounting tool. description:@@ -34,14 +34,14 @@  source-repository head   type:     darcs-  location: http://joyful.com/repos/hledger+  location: http://hub.darcs.net/simon/hledger  flag threaded     Description:   Build with support for multithreaded execution     Default:       True  library-  cpp-options:    -DVERSION="0.19.1"+  cpp-options:    -DVERSION="0.19.2"   ghc-options:    -W   -- should be the same as below   exposed-modules:@@ -110,7 +110,7 @@                   Hledger.Cli.Print                   Hledger.Cli.Register                   Hledger.Cli.Stats-  cpp-options:    -DVERSION="0.19.1"+  cpp-options:    -DVERSION="0.19.2"   ghc-options:    -W   if flag(threaded)        ghc-options:   -threaded