timesheet

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 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"

	TypePublicHoliday     = "Public Holiday"
	TypeMilitaryService   = "Military Service"
	TypeSpecialOccasions  = "Special Occasions"
	TypeUnpaid            = "Unpaid"
	TypeLegalLeavesPrefix = "Legal Leaves"

	StateApproved  = "validate"
	StateToApprove = "confirm"
	StateDraft     = "draft"
)
View Source
const (
	ActionSignIn  = "sign_in"
	ActionSignOut = "sign_out"
)

Variables

This section is empty.

Functions

func ToDuration added in v0.3.0

func ToDuration(hours float64) time.Duration

ToDuration returns the given hours as time.Duration with 3 decimal precision.

Types

type AbsenceBlock added in v0.2.0

type AbsenceBlock struct {
	Date   time.Time
	Reason string
}

type AttendanceBlock

type AttendanceBlock struct {
	// Start is the localized beginning time of the attendance
	Start time.Time
	// End is the localized finish time of the attendance
	End    time.Time
	Reason string
}

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
	Year           int
	Month          int
}

type Reporter

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

func NewReporter added in v0.2.0

func NewReporter(attendances []odoo.Attendance, leaves []odoo.Leave, employee *odoo.Employee, contracts []odoo.Contract) *Reporter

func (*Reporter) CalculateReport added in v0.2.0

func (r *Reporter) CalculateReport() Report

func (*Reporter) SetMonth added in v0.2.0

func (r *Reporter) SetMonth(year, month int) *Reporter

func (*Reporter) SetTimeZone added in v0.4.0

func (r *Reporter) SetTimeZone(zone string) *Reporter

type Summary

type Summary struct {
	TotalOvertime  time.Duration
	TotalLeaveDays time.Duration
}

Jump to

Keyboard shortcuts

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