2007-03-12 10:40:33 +03:00
|
|
|
module TimeLog
|
|
|
|
where
|
|
|
|
import Utils
|
2007-07-02 18:54:36 +04:00
|
|
|
import Types
|
2007-07-02 20:43:14 +04:00
|
|
|
import Currency
|
2007-03-12 10:58:11 +03:00
|
|
|
import Amount
|
2007-03-12 10:40:33 +03:00
|
|
|
import Transaction
|
|
|
|
import Entry
|
2007-07-02 23:15:39 +04:00
|
|
|
import RawLedger
|
2007-03-12 10:40:33 +03:00
|
|
|
|
|
|
|
instance Show TimeLogEntry where
|
|
|
|
show t = printf "%s %s %s" (show $ tcode t) (tdatetime t) (tcomment t)
|
|
|
|
|
|
|
|
instance Show TimeLog where
|
|
|
|
show tl = printf "TimeLog with %d entries" $ length $ timelog_entries tl
|
|
|
|
|
2007-07-02 23:15:39 +04:00
|
|
|
ledgerFromTimeLog :: TimeLog -> RawLedger
|
2007-03-12 10:40:33 +03:00
|
|
|
ledgerFromTimeLog tl =
|
2007-07-02 23:15:39 +04:00
|
|
|
RawLedger [] [] (entriesFromTimeLogEntries $ timelog_entries tl)
|
2007-03-12 10:40:33 +03:00
|
|
|
|
|
|
|
entriesFromTimeLogEntries :: [TimeLogEntry] -> [Entry]
|
|
|
|
|
|
|
|
entriesFromTimeLogEntries [clockin] =
|
|
|
|
entriesFromTimeLogEntries [clockin, clockoutNowEntry]
|
|
|
|
|
|
|
|
entriesFromTimeLogEntries [clockin,clockout] =
|
|
|
|
[
|
|
|
|
Entry {
|
|
|
|
edate = indate,
|
|
|
|
estatus = True,
|
|
|
|
ecode = "",
|
|
|
|
edescription = accountname,
|
|
|
|
etransactions = [
|
|
|
|
Transaction accountname amount,
|
|
|
|
Transaction "TIME" (-amount)
|
|
|
|
]}
|
|
|
|
]
|
|
|
|
where
|
2007-03-12 10:58:11 +03:00
|
|
|
accountname = tcomment clockin
|
|
|
|
intime = tdatetime clockin
|
|
|
|
indate = dateFrom $ tdatetime clockin
|
|
|
|
outtime = tdatetime clockout
|
2007-03-12 20:53:39 +03:00
|
|
|
amount = hours 0 -- read $ outtime - intime
|
2007-03-12 10:40:33 +03:00
|
|
|
|
|
|
|
entriesFromTimeLogEntries many =
|
|
|
|
(entriesFromTimeLogEntries $ take 2 many) ++
|
|
|
|
(entriesFromTimeLogEntries $ drop 2 many)
|
|
|
|
|
|
|
|
clockoutNowEntry = TimeLogEntry ' ' "" ""
|
|
|
|
dateFrom = id
|