begin arbitrary currency support

This commit is contained in:
Simon Michael 2007-07-04 02:24:33 +00:00
parent 45d4d0ffac
commit d739ac0718
4 changed files with 24 additions and 29 deletions

View File

@ -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)

View File

@ -2,7 +2,6 @@ module Ledger
where
import qualified Data.Map as Map
import Data.Map ((!))
import Utils
import Types
import Amount

44
NOTES
View File

@ -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

View File

@ -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