Documentation
¶
Index ¶
- type ActionReason
- type Attendance
- type AttendanceList
- type Contract
- type ContractList
- type Employee
- type EmployeeList
- type Group
- type GroupCategory
- type GroupList
- type Leave
- type LeaveList
- type Odoo
- func (o Odoo) FetchAllAttendances(_ string, employeeID int) (AttendanceList, error)
- func (o Odoo) FetchAllContracts(employeeID int) (ContractList, error)
- func (o Odoo) FetchAllLeaves(employeeID int) (LeaveList, error)
- func (o Odoo) FetchAttendancesBetweenDates(employeeID int, begin, end time.Time) (AttendanceList, error)
- func (o Odoo) FetchEmployeeByID(employeeID int) (*Employee, error)
- func (o Odoo) FetchEmployeeByUserID(userID int) (*Employee, error)
- func (o Odoo) FetchGroupByName(category, name string) (*Group, error)
- func (o Odoo) FetchLeavesBetweenDates(employeeID int, begin, end time.Time) (LeaveList, error)
- func (o Odoo) FetchPayslipOfLastMonth(employeeID int, lastDayOfMonth time.Time) (*Payslip, error)
- func (o Odoo) SearchEmployee(searchString string) (*Employee, error)
- type Payslip
- type PayslipList
- type WorkingSchedule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionReason ¶
ActionReason describes the "action reason" from Odoo. Example raw values returned from Odoo:
- `false` (if no specific reason given)
- `[1, "Outside office hours"]`
- `[2, "Outside office hours"]`
- `[3, "Sick / Medical Consultation"]`
- `[4, "Sick / Medical Consultation"]`
- `[5, "Authorities"]`
- `[6, "Authorities"]`
- `[27, "Requested Public Service"]`
- `[28, "Requested Public Service"]`
func (ActionReason) MarshalJSON ¶
func (reason ActionReason) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*ActionReason) String ¶
func (reason *ActionReason) String() string
String implements fmt.Stringer.
func (*ActionReason) UnmarshalJSON ¶
func (reason *ActionReason) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Attendance ¶
type Attendance struct { // ID is an unique ID for each attendance entry ID int `json:"id,omitempty"` // DateTime is the entry timestamp in UTC // Format: '2006-01-02 15:04:05' DateTime *odoo.Date `json:"name,omitempty"` // Action is either "sign_in" or "sign_out" Action string `json:"action,omitempty"` // Reason describes the "action reason" from Odoo. // NOTE: This field has special meaning when calculating the overtime. Reason *ActionReason `json:"action_desc,omitempty"` }
Attendance is an entry or closing event of a shift.
type AttendanceList ¶
type AttendanceList struct {
Items []Attendance `json:"records,omitempty"`
}
AttendanceList list contains a slice of Attendance.
type Contract ¶
type Contract struct { ID float64 `json:"id"` // Start is the first day of the contract in UTC. Start *odoo.Date `json:"date_start"` // Start is the last day of the contract in UTC. // It is nil or Zero if the contract hasn't ended yet. End *odoo.Date `json:"date_end"` WorkingSchedule *WorkingSchedule `json:"working_hours"` }
type ContractList ¶
type ContractList struct {
Items []Contract `json:"records,omitempty"`
}
ContractList contains a slice of Contract.
func (ContractList) GetFTERatioForDay ¶
func (l ContractList) GetFTERatioForDay(day odoo.Date) (float64, error)
GetFTERatioForDay returns the workload ratio that is active for the given day. All involved dates are expected to be in UTC.
type EmployeeList ¶
type EmployeeList struct {
Items []Employee `json:"records,omitempty"`
}
EmployeeList contains a slice of Employee.
type Group ¶ added in v0.9.0
type Group struct { Name string `json:"name"` Category GroupCategory `json:"category_id"` UserIDs []int `json:"users"` }
Group contains a list of users.
type GroupCategory ¶ added in v0.9.0
GroupCategory is the parent group of a Group.
func (*GroupCategory) MarshalJSON ¶ added in v0.9.0
func (c *GroupCategory) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*GroupCategory) String ¶ added in v0.9.0
func (c *GroupCategory) String() string
String implements fmt.Stringer.
func (*GroupCategory) UnmarshalJSON ¶ added in v0.9.0
func (c *GroupCategory) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type GroupList ¶ added in v0.9.0
type GroupList struct {
Items []Group `json:"records,omitempty"`
}
GroupList contains a slice of Group.
type Leave ¶
type Leave struct { // ID is an unique ID for each leave entry ID int `json:"id"` // DateFrom is the starting timestamp of the leave in UTC // Format: DateTimeFormat DateFrom *odoo.Date `json:"date_from"` // DateTo is the ending timestamp of the leave in UTC // Format: DateTimeFormat DateTo *odoo.Date `json:"date_to"` // Type describes the "leave type" from Odoo. Type *odoo.LeaveType `json:"holiday_status_id,omitempty"` // State is the leave request state. // Example raw values returned from Odoo: // * `draft` (To Submit) // * `confirm` (To Approve) // * `validate` (Approved) State string `json:"state,omitempty"` }
func (Leave) SplitByDay ¶
type LeaveList ¶
type LeaveList struct {
Items []Leave `json:"records,omitempty"`
}
LeaveList contains a slice of Leave.
type Odoo ¶
type Odoo struct {
// contains filtered or unexported fields
}
Odoo is the developer-friendly odoo.Client with strongly-typed models.
func (Odoo) FetchAllAttendances ¶
func (o Odoo) FetchAllAttendances(_ string, employeeID int) (AttendanceList, error)
FetchAllAttendances retrieves all attendances associated with the given employee.
func (Odoo) FetchAllContracts ¶
func (o Odoo) FetchAllContracts(employeeID int) (ContractList, error)
func (Odoo) FetchAttendancesBetweenDates ¶
func (o Odoo) FetchAttendancesBetweenDates(employeeID int, begin, end time.Time) (AttendanceList, error)
FetchAttendancesBetweenDates retrieves all attendances associated with the given employee between 2 dates (inclusive each).
func (Odoo) FetchEmployeeByID ¶
FetchEmployeeByID fetches an Employee for the given employee ID. Returns nil if not found.
func (Odoo) FetchEmployeeByUserID ¶
FetchEmployeeByUserID fetches the Employee for the given user ID (which might not be the same as Employee.ID. Returns nil if not found.
func (Odoo) FetchGroupByName ¶ added in v0.9.0
func (Odoo) FetchLeavesBetweenDates ¶
func (Odoo) FetchPayslipOfLastMonth ¶
type Payslip ¶
type Payslip struct { ID int `json:"id"` Name string `json:"name"` Overtime interface{} `json:"x_overtime"` DateFrom odoo.Date `json:"date_from"` DateTo odoo.Date `json:"date_to"` }
func (Payslip) GetOvertime ¶
GetOvertime returns the plain field value as string.
func (Payslip) ParseOvertime ¶
ParseOvertime tries to parse the currently inconsistently-formatted custom field to a duration. If the field is empty, 0 is returned without error. It parses the following formats:
- hhh:mm (e.g. '15:54')
- hhh:mm:ss (e.g. '153:54:45')
- {1,2}d{1,2}h (e.g. '15d54m')
type PayslipList ¶
type PayslipList struct {
Items []Payslip `json:"records,omitempty"`
}
PayslipList contains a slice of Payslip.
type WorkingSchedule ¶
func (WorkingSchedule) GetFTERatio ¶
func (s WorkingSchedule) GetFTERatio() (float64, error)
GetFTERatio tries to extract the FTE ratio from the name of the schedule. It returns an error if it could not find a match
func (WorkingSchedule) MarshalJSON ¶
func (s WorkingSchedule) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*WorkingSchedule) String ¶
func (s *WorkingSchedule) String() string
String implements fmt.Stringer.
func (*WorkingSchedule) UnmarshalJSON ¶
func (s *WorkingSchedule) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.