show clockin/out times in timelog entries, detect clockout < clockin
This commit is contained in:
parent
614e6e6932
commit
470cae55ca
@ -13,6 +13,7 @@ import Ledger.Types
|
|||||||
import Ledger.Dates
|
import Ledger.Dates
|
||||||
import Ledger.Commodity
|
import Ledger.Commodity
|
||||||
import Ledger.Amount
|
import Ledger.Amount
|
||||||
|
import Ledger.Entry
|
||||||
|
|
||||||
instance Show TimeLogEntry where
|
instance Show TimeLogEntry where
|
||||||
show t = printf "%s %s %s" (show $ tlcode t) (show $ tldatetime t) (tlcomment t)
|
show t = printf "%s %s %s" (show $ tlcode t) (show $ tldatetime t) (tlcomment t)
|
||||||
@ -36,17 +37,21 @@ clockoutFor (TimeLogEntry _ t _) = TimeLogEntry 'o' t ""
|
|||||||
-- entry, representing the time expenditure. Note this entry is not balanced,
|
-- entry, representing the time expenditure. Note this entry is not balanced,
|
||||||
-- since we omit the \"assets:time\" transaction for simpler output.
|
-- since we omit the \"assets:time\" transaction for simpler output.
|
||||||
entryFromTimeLogInOut :: TimeLogEntry -> TimeLogEntry -> Entry
|
entryFromTimeLogInOut :: TimeLogEntry -> TimeLogEntry -> Entry
|
||||||
entryFromTimeLogInOut i o =
|
entryFromTimeLogInOut i o
|
||||||
Entry {
|
| outtime >= intime = e
|
||||||
|
| otherwise =
|
||||||
|
error $ "clock-out time less than clock-in time in:\n" ++ showEntry e
|
||||||
|
where
|
||||||
|
e = Entry {
|
||||||
edate = outdate, -- like ledger
|
edate = outdate, -- like ledger
|
||||||
estatus = True,
|
estatus = True,
|
||||||
ecode = "",
|
ecode = "",
|
||||||
edescription = "",
|
edescription = showtime intime ++ " - " ++ showtime outtime,
|
||||||
ecomment = "",
|
ecomment = "",
|
||||||
etransactions = txns,
|
etransactions = txns,
|
||||||
epreceding_comment_lines=""
|
epreceding_comment_lines=""
|
||||||
}
|
}
|
||||||
where
|
showtime = show . timeToTimeOfDay . utctDayTime
|
||||||
acctname = tlcomment i
|
acctname = tlcomment i
|
||||||
indate = utctDay intime
|
indate = utctDay intime
|
||||||
outdate = utctDay outtime
|
outdate = utctDay outtime
|
||||||
|
|||||||
@ -15,6 +15,7 @@ module Data.Ord,
|
|||||||
module Data.Tree,
|
module Data.Tree,
|
||||||
module Data.Time.Clock,
|
module Data.Time.Clock,
|
||||||
module Data.Time.Calendar,
|
module Data.Time.Calendar,
|
||||||
|
module Data.Time.LocalTime,
|
||||||
module Debug.Trace,
|
module Debug.Trace,
|
||||||
module Ledger.Utils,
|
module Ledger.Utils,
|
||||||
module Text.Printf,
|
module Text.Printf,
|
||||||
@ -32,6 +33,7 @@ import Data.Ord
|
|||||||
import Data.Tree
|
import Data.Tree
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
import Data.Time.Calendar
|
import Data.Time.Calendar
|
||||||
|
import Data.Time.LocalTime
|
||||||
import Debug.Trace
|
import Debug.Trace
|
||||||
import Test.HUnit
|
import Test.HUnit
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user