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 module Currency
where where
import qualified Data.Map as Map
import Data.Map ((!))
import Utils import Utils
import Types import Types
@ -12,8 +14,10 @@ currencies =
,Currency "m" 1 -- minutes ,Currency "m" 1 -- minutes
] ]
currencymap = Map.fromList [(sym, c) | c@(Currency sym rate) <- currencies]
getcurrency :: String -> Currency 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 :: Currency -> Currency -> Double
conversionRate oldc newc = (rate newc) / (rate oldc) conversionRate oldc newc = (rate newc) / (rate oldc)

View File

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

44
NOTES
View File

@ -2,37 +2,27 @@ hledger project notes
* TO DO * TO DO
** bugs ** bugs
*** handle unknown currencies ** ledger features
** compatibility *** print command
** basic features *** handle mixed amounts, non-money currencies
*** print **** handle precision per currency
*** !include *** handle time logs
*** -j and -J graph data output **** fix timelog parser
**** handle time amounts
** 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
switch to Data.Time.* switch to Data.Time.*
fix errors fix errors
- read seconds to pico - read seconds to pico
try System.Time ? try System.Time ?
*** !include
*** timelog simple format *** -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 *** auto-generate missing clock-out
*** graph automation *** graph automation
*** entry and smart data entry *** entry and smart data entry

View File

@ -4,6 +4,7 @@ module Utils (
module Char, module Char,
module Data.List, module Data.List,
module Data.Tree, module Data.Tree,
module Data.Map,
module Data.Ord, module Data.Ord,
module Text.Printf, module Text.Printf,
module Text.Regex, module Text.Regex,
@ -15,6 +16,7 @@ where
import Char import Char
import Data.List import Data.List
import Data.Tree import Data.Tree
import qualified Data.Map
import Data.Ord import Data.Ord
import Text.Printf import Text.Printf
import Text.Regex import Text.Regex