2007-03-12 10:40:33 +03:00
|
|
|
module TimeLog
|
|
|
|
where
|
2008-10-03 04:05:16 +04:00
|
|
|
import Ledger.Utils
|
2008-10-03 04:12:59 +04:00
|
|
|
import Ledger.Types
|
2007-07-02 20:43:14 +04:00
|
|
|
import Currency
|
2007-03-12 10:58:11 +03:00
|
|
|
import Amount
|
2008-10-03 03:55:01 +04:00
|
|
|
import RawTransaction
|
2007-07-04 13:51:37 +04:00
|
|
|
import LedgerEntry
|
2008-10-03 02:17:04 +04:00
|
|
|
import RawLedger
|
2007-03-12 10:40:33 +03:00
|
|
|
|
|
|
|
instance Show TimeLogEntry where
|
2007-07-04 16:05:54 +04:00
|
|
|
show t = printf "%s %s %s" (show $ tlcode t) (tldatetime t) (tlcomment t)
|
2007-03-12 10:40:33 +03:00
|
|
|
|
|
|
|
instance Show TimeLog where
|
|
|
|
show tl = printf "TimeLog with %d entries" $ length $ timelog_entries tl
|
|
|
|
|
2008-10-03 02:17:04 +04:00
|
|
|
ledgerFromTimeLog :: TimeLog -> RawLedger
|
2007-03-12 10:40:33 +03:00
|
|
|
ledgerFromTimeLog tl =
|
2008-10-03 02:17:04 +04:00
|
|
|
RawLedger [] [] (entriesFromTimeLogEntries $ timelog_entries tl) ""
|
2007-03-12 10:40:33 +03:00
|
|
|
|
2007-07-04 13:51:37 +04:00
|
|
|
entriesFromTimeLogEntries :: [TimeLogEntry] -> [LedgerEntry]
|
2007-03-12 10:40:33 +03:00
|
|
|
|
|
|
|
entriesFromTimeLogEntries [clockin] =
|
|
|
|
entriesFromTimeLogEntries [clockin, clockoutNowEntry]
|
|
|
|
|
|
|
|
entriesFromTimeLogEntries [clockin,clockout] =
|
|
|
|
[
|
2007-07-04 13:51:37 +04:00
|
|
|
LedgerEntry {
|
2007-03-12 10:40:33 +03:00
|
|
|
edate = indate,
|
|
|
|
estatus = True,
|
|
|
|
ecode = "",
|
|
|
|
edescription = accountname,
|
2007-07-04 16:05:54 +04:00
|
|
|
ecomment = "",
|
2007-03-12 10:40:33 +03:00
|
|
|
etransactions = [
|
2008-10-03 03:55:01 +04:00
|
|
|
RawTransaction accountname amount "",
|
|
|
|
RawTransaction "TIME" (-amount) ""
|
2008-06-28 08:44:33 +04:00
|
|
|
],
|
|
|
|
epreceding_comment_lines=""}
|
2007-03-12 10:40:33 +03:00
|
|
|
]
|
|
|
|
where
|
2007-07-04 16:05:54 +04:00
|
|
|
accountname = tlcomment clockin
|
|
|
|
intime = tldatetime clockin
|
|
|
|
indate = dateFrom $ tldatetime clockin
|
|
|
|
outtime = tldatetime 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
|