diff options
| author | Teddy Wing | 2017-06-03 13:02:03 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-03 13:02:03 +0200 | 
| commit | f017c462593496efbc0810ec2603da49a2e3d9d8 (patch) | |
| tree | 093979e62d7e832ff272f57d3380beb1d9a18786 | |
| parent | 758cf0bf7e899acee89ee4b8a39c5565622aee31 (diff) | |
| download | timetasker-f017c462593496efbc0810ec2603da49a2e3d9d8.tar.bz2 | |
Add `NewTimeEntry()`
A new function that creates a `TimeEntry` build from a `Profile`,
`Project`, and a few other parameters. Makes it a bit easier to create
`TimeEntry`ies.
Additionally, add a `PersonID` field to `TimeEntry` so we can pass it
around as a self-contained thing without worrying about having to pass
a `Profile` along with it.
| -rw-r--r-- | timetask/time_entry.go | 22 | 
1 files changed, 22 insertions, 0 deletions
| diff --git a/timetask/time_entry.go b/timetask/time_entry.go index 1cc4203..161de3e 100644 --- a/timetask/time_entry.go +++ b/timetask/time_entry.go @@ -3,6 +3,7 @@ package timetask  import "time"  type TimeEntry struct { +	PersonID    int  	Client      int  	Project     int  	Module      int @@ -13,3 +14,24 @@ type TimeEntry struct {  	Billable    bool  	Description string  } + +func NewTimeEntry( +	profile Profile, +	project Project, +	date time.Time, +	time int, +	description string, +) TimeEntry { +	return TimeEntry{ +		PersonID: profile.PersonID, +		Client: project.Client, +		Project: project.Project, +		Module: project.Module, +		Task: project.Task, +		WorkType: project.WorkType, +		Date: date, +		Time: time, +		Billable: project.Billable, +		Description: description, +	} +} | 
