Documentation
¶
Index ¶
- Constants
- func ToDuration(hours float64) time.Duration
- type AbsenceBlock
- type AttendanceBlock
- type DailySummary
- func (s *DailySummary) CalculateAbsenceHours() time.Duration
- func (s *DailySummary) CalculateDailyMaxHours() float64
- func (s *DailySummary) CalculateExcusedHours() float64
- func (s *DailySummary) CalculateOvertime() time.Duration
- func (s *DailySummary) CalculateWorkingHours() float64
- func (s *DailySummary) HasAbsences() bool
- func (s *DailySummary) IsWeekend() bool
- type Report
- type Reporter
- type Summary
Constants ¶
const ( ReasonSickLeave = "Sick / Medical Consultation" ReasonOutsideOfficeHours = "Outside office hours" ReasonAuthorities = "Authorities" ReasonPublicService = "Requested Public Service" TypePublicHoliday = "Public Holiday" TypeMilitaryService = "Military Service" TypeSpecialOccasions = "Special Occasions" TypeUnpaid = "Unpaid" TypeLegalLeavesPrefix = "Legal Leaves" StateApproved = "validate" StateToApprove = "confirm" StateDraft = "draft" )
const ( ActionSignIn = "sign_in" ActionSignOut = "sign_out" )
Variables ¶
This section is empty.
Functions ¶
func ToDuration ¶ added in v0.3.0
ToDuration returns the given hours as time.Duration with 3 decimal precision.
Types ¶
type AbsenceBlock ¶ added in v0.2.0
type AttendanceBlock ¶
type DailySummary ¶
type DailySummary struct { // Date is the localized date of the summary. Date time.Time Blocks []AttendanceBlock Absences []AbsenceBlock FTERatio float64 }
func NewDailySummary ¶
func NewDailySummary(fteRatio float64, date time.Time) *DailySummary
NewDailySummary creates a new instance. The fteRatio is the percentage (input a value between 0..1) of the employee and is used to calculate the daily maximum hours an employee should work. Date is expected to be in a localized timezone.
func (*DailySummary) CalculateAbsenceHours ¶ added in v0.2.0
func (s *DailySummary) CalculateAbsenceHours() time.Duration
CalculateAbsenceHours accumulates all absence hours from that day.
func (*DailySummary) CalculateDailyMaxHours ¶ added in v0.2.0
func (s *DailySummary) CalculateDailyMaxHours() float64
CalculateDailyMaxHours returns the theoretical amount of hours that an employee should work on this day.
- It returns 0 for weekend days.
- It returns 8.5 hours multiplied by FTE ratio for days in 2020 and earlier.
- It returns 8.0 hours multiplied by FTE ratio for days in 2021 and later.
func (*DailySummary) CalculateExcusedHours ¶
func (s *DailySummary) CalculateExcusedHours() float64
CalculateExcusedHours accumulates all hours that are excused in some way (sick leave etc) from that day.
func (*DailySummary) CalculateOvertime ¶
func (s *DailySummary) CalculateOvertime() time.Duration
CalculateOvertime returns the duration of overtime. If returned duration is positive, then the employee did overtime and undertime if duration is negative.
The overtime is then calculated according to these business rules:
- Outside office hours are multiplied by 1.5 (as a compensation)
- Excused hours like sick leave, authorities or public service can be used to "fill up" the daily theoretical maximum if the working hours are less than said maximum. However, there's no overtime possible using excused hours
- If the working hours exceed the theoretical daily maximum, then the excused hours are basically ignored. Example: it's not possible to work 9 hours, have 1 hour sick leave and expect 2 hours overtime for an 8 hours daily maximum, the overtime here is 1 hour.
func (*DailySummary) CalculateWorkingHours ¶
func (s *DailySummary) CalculateWorkingHours() float64
CalculateWorkingHours accumulates all working hours from that day. The outside office hours are multiplied with 1.5.
func (*DailySummary) HasAbsences ¶ added in v0.2.0
func (s *DailySummary) HasAbsences() bool
HasAbsences returns true if there are any absences.
func (*DailySummary) IsWeekend ¶ added in v0.2.0
func (s *DailySummary) IsWeekend() bool
IsWeekend returns true if the date falls on a Saturday or Sunday.
type Report ¶
type Report struct { DailySummaries []*DailySummary Summary Summary Employee *odoo.Employee }
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}