timesheet

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonSickLeave          = "Sick / Medical Consultation"
	ReasonOutsideOfficeHours = "Outside office hours"
	ReasonAuthorities        = "Authorities"
	ReasonPublicService      = "Requested Public Service"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttendanceBlock

type AttendanceBlock struct {
	Start  time.Time
	End    time.Time
	Reason string
}

type DailySummary

type DailySummary struct {
	Date     time.Time
	Blocks   []AttendanceBlock
	FTERatio float64
}

func NewDailySummary

func NewDailySummary(fteRatio float64) *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.

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.

type Report

type Report struct {
	DailySummaries []*DailySummary
	Summary        Summary
}

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

func NewReport

func NewReport() *Reporter

func (*Reporter) CalculateReportForMonth

func (r *Reporter) CalculateReportForMonth(year, month int, fteRatio float64) Report

func (*Reporter) SetAttendances

func (r *Reporter) SetAttendances(attendances []odoo.Attendance) *Reporter

func (*Reporter) SetLeaves

func (r *Reporter) SetLeaves(leaves []odoo.Leave) *Reporter

type Summary

type Summary struct {
	TotalWorkedHours time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL