diff --git a/Currency.hs b/Currency.hs index bbf5861a1..f3a4a03a0 100644 --- a/Currency.hs +++ b/Currency.hs @@ -1,5 +1,7 @@ module Currency where +import qualified Data.Map as Map +import Data.Map ((!)) import Utils import Types @@ -12,8 +14,10 @@ currencies = ,Currency "m" 1 -- minutes ] +currencymap = Map.fromList [(sym, c) | c@(Currency sym rate) <- currencies] + getcurrency :: String -> Currency -getcurrency s = head $ [(Currency symbol rate) | (Currency symbol rate) <- currencies, symbol==s] +getcurrency s = Map.findWithDefault (Currency s 1) s currencymap conversionRate :: Currency -> Currency -> Double conversionRate oldc newc = (rate newc) / (rate oldc) diff --git a/Ledger.hs b/Ledger.hs index 035bc951c..527ec4cbe 100644 --- a/Ledger.hs +++ b/Ledger.hs @@ -2,7 +2,6 @@ module Ledger where import qualified Data.Map as Map import Data.Map ((!)) - import Utils import Types import Amount diff --git a/NOTES b/NOTES index 87cbf8f0a..ff6621617 100644 --- a/NOTES +++ b/NOTES @@ -2,37 +2,27 @@ hledger project notes * TO DO ** bugs -*** handle unknown currencies -** compatibility -** basic features -*** print -*** !include -*** -j and -J graph data output - -** advanced features -*** handle mixed amounts -*** ledger 3.0-style elision -*** -p period expressions -*** -d display expressions -*** read gnucash files -*** other args, directives - -*** more speed -** new features -*** feature: read timelog files -**** fix up Amounts -***** allow flexible display by currency -***** allow parsing by currency -***** fix arithmetic - -**** timelog parser - handle time amounts +** ledger features +*** print command +*** handle mixed amounts, non-money currencies +**** handle precision per currency +*** handle time logs +**** fix timelog parser +**** handle time amounts switch to Data.Time.* fix errors - read seconds to pico try System.Time ? - -*** timelog simple format +*** !include +*** -j and -J graph data output +*** more speed +*** ledger 3.0-style elision +*** -p period expressions +*** -d display expressions +*** read gnucash files +*** other ledger args, directives +** new features +*** simpler timelog format *** auto-generate missing clock-out *** graph automation *** entry and smart data entry diff --git a/Utils.hs b/Utils.hs index c9b3fffca..145131501 100644 --- a/Utils.hs +++ b/Utils.hs @@ -4,6 +4,7 @@ module Utils ( module Char, module Data.List, module Data.Tree, + module Data.Map, module Data.Ord, module Text.Printf, module Text.Regex, @@ -15,6 +16,7 @@ where import Char import Data.List import Data.Tree +import qualified Data.Map import Data.Ord import Text.Printf import Text.Regex