mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 04:46:31 +03:00
more cleanups
This commit is contained in:
parent
8d70ed87ea
commit
760befef89
@ -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
|
||||
|
@ -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.
|
||||
|
||||
-}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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