packages feed

hledger-interest 1.5.1 → 1.5.2

raw patch · 4 files changed

+91/−58 lines, 4 filesdep ~hledger-lib

Dependency ranges changed: hledger-lib

Files

Hledger/Interest/DayCountConvention.hs view
@@ -16,7 +16,7 @@ diffAct date1 date2 = assert (date1 <= date2) $ fromInteger (date2 `diffDays` date1)  mkDiff30_360 :: (Integer,Int,Int) -> (Integer,Int,Int) -> Integer-mkDiff30_360 (y1,m1,d1) (y2,m2,d2) = 360*(y2-y1) + 30*(toInteger (m2-m1)) + toInteger (d2-d1)+mkDiff30_360 (y1,m1,d1) (y2,m2,d2) = 360*(y2-y1) + 30*toInteger (m2-m1) + toInteger (d2-d1)  -- The un-corrected naked formular. 
Hledger/Interest/Rate.hs view
@@ -1,4 +1,4 @@-module Hledger.Interest.Rate ( Rate, perAnno, constant, bgb288, ingDiba ) where+module Hledger.Interest.Rate ( Rate, perAnno, constant, bgb288, ingDiba, db24 ) where  import Data.Time.Calendar import Data.Time.Calendar.OrdinalDate@@ -45,6 +45,21 @@   , (day 2010 07 01, day 2010 12 31,  12 / 10000)   , (day 2011 01 01, day 2011 06 30,  12 / 10000)   , (day 2011 07 01, day 2999 12 31,  37 / 10000)+  , (day 2011 01 01, day 2011 06 30,  12 / 10000)+  , (day 2011 07 01, day 2011 12 31,  37 / 10000)+  , (day 2012 01 01, day 2012 06 30,  12 / 10000)+  , (day 2012 07 01, day 2012 12 31,  12 / 10000)+  , (day 2013 01 01, day 2013 06 30, -13 / 10000)+  , (day 2013 07 01, day 2013 12 31, -38 / 10000)+  , (day 2014 01 01, day 2014 06 30, -63 / 10000)+  , (day 2014 07 01, day 2014 12 31, -73 / 10000)+  , (day 2015 01 01, day 2015 06 30, -83 / 10000)+  , (day 2015 07 01, day 2015 12 31, -83 / 10000)+  , (day 2016 01 01, day 2016 06 30, -83 / 10000)+  , (day 2016 07 01, day 2016 12 31, -88 / 10000)+  , (day 2017 01 01, day 2017 06 30, -88 / 10000)+  , (day 2017 07 01, day 2017 12 31, -88 / 10000)+  , (day 2018 01 01, day 2018 06 30, -88 / 10000)   ]  ingDiba :: Rate@@ -58,4 +73,15 @@   , (day 2010 01 01, day 2010 12 31, 150 / 10000)   , (day 2011 01 01, day 2011 07 14, 150 / 10000)   , (day 2011 07 15, day 2999 12 31, 175 / 10000)+  ]++db24 :: Rate+db24 date = (to, p)+  where+    (_,to,p) = head (dropWhile (\(_,to',_) -> to' < date) db24Table)++db24Table :: [(Day, Day, Decimal)]+db24Table =+  [ (day 2000 10 06, day 2010 09 15, 638 / 10000)+  , (day 2010 09 16, day 2999 12 31, 415 / 10000)   ]
Main.hs view
@@ -10,7 +10,7 @@ import Data.Maybe import Data.Ord import qualified Data.Text as T-import Distribution.Text ( display )+import Data.Version import System.Console.GetOpt import System.Environment import System.Exit@@ -19,48 +19,52 @@ import Paths_hledger_interest ( version )  data Options = Options-  { optVerbose      :: Bool-  , optShowVersion  :: Bool-  , optShowHelp     :: Bool-  , optInput        :: FilePath-  , optSourceAcc    :: String-  , optTargetAcc    :: String-  , optDCC          :: Maybe DayCountConvention-  , optRate         :: Maybe Rate-  , optBalanceToday :: Bool+  { optVerbose          :: Bool+  , optShowVersion      :: Bool+  , optShowHelp         :: Bool+  , optInput            :: FilePath+  , optSourceAcc        :: String+  , optTargetAcc        :: String+  , optDCC              :: Maybe DayCountConvention+  , optRate             :: Maybe Rate+  , optBalanceToday     :: Bool+  , optIgnoreAssertions :: Bool   }  defaultOptions :: Options defaultOptions = Options-  { optVerbose      = True-  , optShowVersion  = False-  , optShowHelp     = False-  , optInput        = "-"-  , optSourceAcc    = ""-  , optTargetAcc    = ""-  , optDCC          = Nothing-  , optRate         = Nothing-  , optBalanceToday = False+  { optVerbose          = True+  , optShowVersion      = False+  , optShowHelp         = False+  , optInput            = "-"+  , optSourceAcc        = ""+  , optTargetAcc        = ""+  , optDCC              = Nothing+  , optRate             = Nothing+  , optBalanceToday     = False+  , optIgnoreAssertions = False   }  options :: [OptDescr (Options -> Options)] options =- [ Option ['h'] ["help"]        (NoArg (\o -> o { optShowHelp = True }))                            "print this message and exit"- , Option ['V'] ["version"]     (NoArg (\o -> o { optShowVersion = True }))                         "show version number and exit"- , Option ['v'] ["verbose"]     (NoArg (\o -> o { optVerbose = True }))                             "echo input ledger to stdout (default)"- , Option ['q'] ["quiet"]       (NoArg (\o -> o { optVerbose = False }))                            "don't echo input ledger to stdout"- , Option []    ["today"]       (NoArg (\o -> o { optBalanceToday = True }))                        "compute interest up until today"- , Option ['f'] ["file"]        (ReqArg (\f o -> o { optInput = f }) "FILE")                        "input ledger file (pass '-' for stdin)"- , Option ['s'] ["source"]      (ReqArg (\a o -> o { optSourceAcc = a }) "ACCOUNT")                 "interest source account"- , Option ['t'] ["target"]      (ReqArg (\a o -> o { optTargetAcc = a }) "ACCOUNT")                 "interest target account"- , Option []    ["act"]         (NoArg (\o -> o { optDCC = Just diffAct }))                         "use 'act' day counting convention"- , Option []    ["30-360"]      (NoArg (\o -> o { optDCC = Just diff30_360 }))                      "use '30/360' day counting convention"- , Option []    ["30E-360"]     (NoArg (\o -> o { optDCC = Just diff30E_360 }))                     "use '30E/360' day counting convention"- , Option []    ["30E-360isda"] (NoArg (\o -> o { optDCC = Just diff30E_360isda }))                 "use '30E/360isda' day counting convention"- , Option []    ["constant"]    (ReqArg (\r o -> o { optRate = Just (constant (read r)) }) "RATE")  "constant interest rate"- , Option []    ["annual"]      (ReqArg (\r o -> o { optRate = Just (perAnno (read r)) }) "RATE")   "annual interest rate"- , Option []    ["bgb288"]      (NoArg (\o -> o { optRate = Just bgb288, optDCC = Just diffAct }))  "compute interest according to German BGB288"- , Option []    ["ing-diba"]    (NoArg (\o -> o { optRate = Just ingDiba, optDCC = Just diffAct })) "compute interest according for Ing-Diba Tagesgeld account"+ [ Option ['h'] ["help"]              (NoArg (\o -> o { optShowHelp = True }))                             "print this message and exit"+ , Option ['V'] ["version"]           (NoArg (\o -> o { optShowVersion = True }))                          "show version number and exit"+ , Option ['v'] ["verbose"]           (NoArg (\o -> o { optVerbose = True }))                              "echo input ledger to stdout (default)"+ , Option ['q'] ["quiet"]             (NoArg (\o -> o { optVerbose = False }))                             "don't echo input ledger to stdout"+ , Option []    ["today"]             (NoArg (\o -> o { optBalanceToday = True }))                         "compute interest up until today"+ , Option ['f'] ["file"]              (ReqArg (\f o -> o { optInput = f }) "FILE")                         "input ledger file (pass '-' for stdin)"+ , Option ['s'] ["source"]            (ReqArg (\a o -> o { optSourceAcc = a }) "ACCOUNT")                  "interest source account"+ , Option ['t'] ["target"]            (ReqArg (\a o -> o { optTargetAcc = a }) "ACCOUNT")                  "interest target account"+ , Option ['I'] ["ignore-assertions"] (NoArg (\o -> o { optIgnoreAssertions = True }))                     "ignore any failing balance assertions"+ , Option []    ["act"]               (NoArg (\o -> o { optDCC = Just diffAct }))                          "use 'act' day counting convention"+ , Option []    ["30-360"]            (NoArg (\o -> o { optDCC = Just diff30_360 }))                       "use '30/360' day counting convention"+ , Option []    ["30E-360"]           (NoArg (\o -> o { optDCC = Just diff30E_360 }))                      "use '30E/360' day counting convention"+ , Option []    ["30E-360isda"]       (NoArg (\o -> o { optDCC = Just diff30E_360isda }))                  "use '30E/360isda' day counting convention"+ , Option []    ["constant"]          (ReqArg (\r o -> o { optRate = Just (constant (read r)) }) "RATE")   "constant interest rate"+ , Option []    ["annual"]            (ReqArg (\r o -> o { optRate = Just (perAnno (read r)) }) "RATE")    "annual interest rate"+ , Option []    ["bgb288"]            (NoArg (\o -> o { optRate = Just bgb288, optDCC = Just diffAct }))   "compute interest according to German BGB288"+ , Option []    ["db24"]              (NoArg (\o -> o { optRate = Just db24, optDCC = Just diff30E_360 })) "HACK: Deutsche Bank 24"+ , Option []    ["ing-diba"]          (NoArg (\o -> o { optRate = Just ingDiba, optDCC = Just diffAct }))  "HACK: compute interest according for Ing-Diba Tagesgeld account"  ]  usageMessage :: String@@ -80,7 +84,7 @@ main :: IO () main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do   (opts, args) <- getArgs >>= parseOpts-  when (optShowVersion opts) (putStrLn (display version) >> exitSuccess)+  when (optShowVersion opts) (putStrLn (showVersion version) >> exitSuccess)   when (optShowHelp opts) (putStr usageMessage >> exitSuccess)   when (null (optSourceAcc opts)) (commandLineError "required --source option is missing\n")   when (null (optTargetAcc opts)) (commandLineError "required --target option is missing\n")@@ -88,7 +92,8 @@   when (isNothing (optRate opts)) (commandLineError "no interest rate specified\n")   when (length args < 1) (commandLineError "required argument ACCOUNT is missing\n")   when (length args > 1) (commandLineError "only one interest ACCOUNT may be specified\n")-  jnl' <- readJournalFile Nothing Nothing False (optInput opts) >>= either fail return+  let ledgerInputOptions = definputopts { ignore_assertions_ = optIgnoreAssertions opts }+  jnl' <- readJournalFile ledgerInputOptions (optInput opts) >>= either fail return   let [interestAcc] = args       jnl = filterJournalTransactions (Acct interestAcc) jnl'       ts  = sortBy (comparing tdate) (jtxns jnl)
hledger-interest.cabal view
@@ -1,5 +1,5 @@ Name:                   hledger-interest-Version:                1.5.1+Version:                1.5.2 Synopsis:               computes interest for a given account License:                BSD3 License-file:           LICENSE@@ -9,9 +9,9 @@ Category:               Finance Build-type:             Simple Cabal-version:          >= 1.6-Tested-with:            GHC > 7.10 && < 8.1-Data-files:             README.md+Extra-source-files:     README.md Stability:              stable+tested-with:            GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.2  Description:  hledger-interest is a small command-line utility based on Simon@@ -92,21 +92,22 @@  available options:  .  > Usage: hledger-interest [OPTION...] ACCOUNT- >   -h          --help            print this message and exit- >   -V          --version         show version number and exit- >   -v          --verbose         echo input ledger to stdout (default)- >   -q          --quiet           don't echo input ledger to stdout- >               --today           update account until today- >   -f FILE     --file=FILE       input ledger file- >   -s ACCOUNT  --source=ACCOUNT  interest source account- >   -t ACCOUNT  --target=ACCOUNT  interest target account- >               --act             use 'act' day counting convention- >               --30-360          use '30/360' day counting convention- >               --30E-360         use '30E/360' day counting convention- >               --30E-360isda     use '30E/360isda' day counting convention- >               --constant=RATE   constant interest rate- >               --annual=RATE     annual interest rate- >               --bgb288          compute interest according to German BGB288+ >   -h          --help               print this message and exit+ >   -V          --version            show version number and exit+ >   -v          --verbose            echo input ledger to stdout (default)+ >   -q          --quiet              don't echo input ledger to stdout+ >               --today              compute interest up until today+ >   -f FILE     --file=FILE          input ledger file (pass '-' for stdin)+ >   -s ACCOUNT  --source=ACCOUNT     interest source account+ >   -t ACCOUNT  --target=ACCOUNT     interest target account+ >   -I          --ignore-assertions  ignore any failing balance assertions+ >               --act                use 'act' day counting convention+ >               --30-360             use '30/360' day counting convention+ >               --30E-360            use '30E/360' day counting convention+ >               --30E-360isda        use '30E/360isda' day counting convention+ >               --constant=RATE      constant interest rate+ >               --annual=RATE        annual interest rate+ >               --bgb288             compute interest according to German BGB288  Source-Repository head   Type:                 git@@ -114,8 +115,9 @@  Executable hledger-interest   Main-is:              Main.hs-  Build-depends:        base >= 3 && < 5, hledger-lib > 1, time, mtl, Cabal, Decimal, text+  Build-depends:        base >= 3 && < 5, hledger-lib >= 1.9.1, time, mtl, Cabal, Decimal, text   other-modules:        Hledger.Interest                         Hledger.Interest.DayCountConvention                         Hledger.Interest.Rate+                        Paths_hledger_interest   Ghc-Options:          -Wall