more cleanups

This commit is contained in:
Simon Michael 2008-10-15 06:00:10 +00:00
parent 8d70ed87ea
commit 760befef89
5 changed files with 17 additions and 15 deletions

View File

@ -15,15 +15,17 @@ import Ledger.Types
commoditytests = TestList [
]
-- for nullamt, autoamt, etc.
unknown = Commodity {symbol="",side=L,spaced=False,comma=False,precision=0,rate=1}
-- convenient amount and commodity constructors, for tests etc.
dollar = Commodity {symbol="$",side=L,spaced=False,comma=False,precision=2,rate=1}
euro = Commodity {symbol="EUR",side=L,spaced=False,comma=False,precision=2,rate=0.760383}
pound = Commodity {symbol="£",side=L,spaced=False,comma=False,precision=2,rate=0.512527}
hour = Commodity {symbol="h",side=R,spaced=False,comma=False,precision=1,rate=100}
-- | convenient amount constructors
dollars = Amount dollar
euros = Amount euro
pounds = Amount pound

View File

@ -1,7 +1,7 @@
{-|
An 'Entry' represents a normal entry in the ledger file. It normally
contains two or more 'RawTransaction's which balance.
An 'Entry' represents a regular entry in the ledger file. It contains two
or more 'RawTransaction's whose sum must be zero.
-}

View File

@ -332,9 +332,9 @@ amountquantity = do
return (quantity, precision, comma)
<?> "commodity quantity"
-- | parse the two strings of digits before and after a decimal point, if
-- any. The integer part may contain commas, or either part may be empty,
-- or there may be no point.
-- | parse the two strings of digits before and after a possible decimal
-- point. The integer part may contain commas, or either part may be
-- empty, or there may be no point.
numberparts :: Parser (String,String)
numberparts = numberpartsstartingwithdigit <|> numberpartsstartingwithpoint

View File

@ -1,7 +1,7 @@
{-|
A 'TimeLog' is a parsed timelog file (generated by timeclock.el),
containing zero or more 'TimeLogEntry's. It can be converted to a
A 'TimeLog' is a parsed timelog file (see timeclock.el or the command-line
version) containing zero or more 'TimeLogEntry's. It can be converted to a
'RawLedger' for querying.
-}
@ -34,7 +34,9 @@ entriesFromTimeLogEntries [i] = entriesFromTimeLogEntries [i, clockoutFor i]
entriesFromTimeLogEntries (i:o:rest) = [entryFromTimeLogInOut i o] ++ entriesFromTimeLogEntries rest
-- | When there is a trailing clockin entry, provide the missing clockout.
-- "Now" would be preferable but requires IO, for now use the clockin time.
-- An entry for now is what we want but this requires IO so for now use
-- the clockin time, ie don't count the current clocked-in period.
clockoutFor :: TimeLogEntry -> TimeLogEntry
clockoutFor (TimeLogEntry _ t _) = TimeLogEntry 'o' t ""
-- | Convert a timelog clockin and clockout entry to an equivalent ledger
@ -52,12 +54,10 @@ entryFromTimeLogInOut i o =
}
where
acctname = tlcomment i
indate = showDateFrom intime
outdate = showDateFrom outtime
indate = showdate intime
outdate = showdate outtime
showdate = formatTime defaultTimeLocale "%Y/%m/%d"
intime = parsedatetime $ tldatetime i
outtime = parsedatetime $ tldatetime o
amount = hours $ realToFrac (diffUTCTime outtime intime) / 3600
txns = [RawTransaction acctname amount "", RawTransaction "assets:TIME" (-amount) ""]
showDateFrom :: UTCTime -> String
showDateFrom = formatTime defaultTimeLocale "%Y/%m/%d"

View File

@ -1,6 +1,6 @@
{-|
Standard always-available imports and utilities.
Provide a number of standard modules and utilities.
-}