more cleanups
This commit is contained in:
parent
8d70ed87ea
commit
760befef89
@ -15,15 +15,17 @@ import Ledger.Types
|
|||||||
|
|
||||||
commoditytests = TestList [
|
commoditytests = TestList [
|
||||||
]
|
]
|
||||||
|
|
||||||
-- for nullamt, autoamt, etc.
|
-- for nullamt, autoamt, etc.
|
||||||
unknown = Commodity {symbol="",side=L,spaced=False,comma=False,precision=0,rate=1}
|
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}
|
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}
|
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}
|
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}
|
hour = Commodity {symbol="h",side=R,spaced=False,comma=False,precision=1,rate=100}
|
||||||
|
|
||||||
-- | convenient amount constructors
|
|
||||||
dollars = Amount dollar
|
dollars = Amount dollar
|
||||||
euros = Amount euro
|
euros = Amount euro
|
||||||
pounds = Amount pound
|
pounds = Amount pound
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{-|
|
{-|
|
||||||
|
|
||||||
An 'Entry' represents a normal entry in the ledger file. It normally
|
An 'Entry' represents a regular entry in the ledger file. It contains two
|
||||||
contains two or more 'RawTransaction's which balance.
|
or more 'RawTransaction's whose sum must be zero.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
|||||||
@ -332,9 +332,9 @@ amountquantity = do
|
|||||||
return (quantity, precision, comma)
|
return (quantity, precision, comma)
|
||||||
<?> "commodity quantity"
|
<?> "commodity quantity"
|
||||||
|
|
||||||
-- | parse the two strings of digits before and after a decimal point, if
|
-- | parse the two strings of digits before and after a possible decimal
|
||||||
-- any. The integer part may contain commas, or either part may be empty,
|
-- point. The integer part may contain commas, or either part may be
|
||||||
-- or there may be no point.
|
-- empty, or there may be no point.
|
||||||
numberparts :: Parser (String,String)
|
numberparts :: Parser (String,String)
|
||||||
numberparts = numberpartsstartingwithdigit <|> numberpartsstartingwithpoint
|
numberparts = numberpartsstartingwithdigit <|> numberpartsstartingwithpoint
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{-|
|
{-|
|
||||||
|
|
||||||
A 'TimeLog' is a parsed timelog file (generated by timeclock.el),
|
A 'TimeLog' is a parsed timelog file (see timeclock.el or the command-line
|
||||||
containing zero or more 'TimeLogEntry's. It can be converted to a
|
version) containing zero or more 'TimeLogEntry's. It can be converted to a
|
||||||
'RawLedger' for querying.
|
'RawLedger' for querying.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
@ -34,7 +34,9 @@ entriesFromTimeLogEntries [i] = entriesFromTimeLogEntries [i, clockoutFor i]
|
|||||||
entriesFromTimeLogEntries (i:o:rest) = [entryFromTimeLogInOut i o] ++ entriesFromTimeLogEntries rest
|
entriesFromTimeLogEntries (i:o:rest) = [entryFromTimeLogInOut i o] ++ entriesFromTimeLogEntries rest
|
||||||
|
|
||||||
-- | When there is a trailing clockin entry, provide the missing clockout.
|
-- | 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 ""
|
clockoutFor (TimeLogEntry _ t _) = TimeLogEntry 'o' t ""
|
||||||
|
|
||||||
-- | Convert a timelog clockin and clockout entry to an equivalent ledger
|
-- | Convert a timelog clockin and clockout entry to an equivalent ledger
|
||||||
@ -52,12 +54,10 @@ entryFromTimeLogInOut i o =
|
|||||||
}
|
}
|
||||||
where
|
where
|
||||||
acctname = tlcomment i
|
acctname = tlcomment i
|
||||||
indate = showDateFrom intime
|
indate = showdate intime
|
||||||
outdate = showDateFrom outtime
|
outdate = showdate outtime
|
||||||
|
showdate = formatTime defaultTimeLocale "%Y/%m/%d"
|
||||||
intime = parsedatetime $ tldatetime i
|
intime = parsedatetime $ tldatetime i
|
||||||
outtime = parsedatetime $ tldatetime o
|
outtime = parsedatetime $ tldatetime o
|
||||||
amount = hours $ realToFrac (diffUTCTime outtime intime) / 3600
|
amount = hours $ realToFrac (diffUTCTime outtime intime) / 3600
|
||||||
txns = [RawTransaction acctname amount "", RawTransaction "assets:TIME" (-amount) ""]
|
txns = [RawTransaction acctname amount "", RawTransaction "assets:TIME" (-amount) ""]
|
||||||
|
|
||||||
showDateFrom :: UTCTime -> String
|
|
||||||
showDateFrom = formatTime defaultTimeLocale "%Y/%m/%d"
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{-|
|
{-|
|
||||||
|
|
||||||
Standard always-available imports and utilities.
|
Provide a number of standard modules and utilities.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user