Documentation ¶
Index ¶
- Constants
- type AbsenceBlock
- type AttendanceShift
- type DailySummary
- func (s *DailySummary) CalculateAbsenceTime() time.Duration
- func (s *DailySummary) CalculateDailyMax() time.Duration
- func (s *DailySummary) CalculateExcusedTime() time.Duration
- func (s *DailySummary) CalculateOvertime() time.Duration
- func (s *DailySummary) CalculateWorkingTime() time.Duration
- func (s *DailySummary) HasAbsences() bool
- func (s *DailySummary) IsHoliday() bool
- func (s *DailySummary) IsWeekend() bool
- type Report
- type ReportBuilder
- type Summary
- type YearlyReport
- type YearlyReportBuilder
- type YearlySummary
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 ¶
This section is empty.
Types ¶
type AbsenceBlock ¶ added in v0.2.0
type AttendanceShift ¶ added in v0.7.0
type DailySummary ¶
type DailySummary struct { // Date is the localized date of the summary. Date time.Time Shifts []AttendanceShift 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) CalculateAbsenceTime ¶ added in v0.7.0
func (s *DailySummary) CalculateAbsenceTime() time.Duration
CalculateAbsenceTime accumulates all absence hours from that day.
func (*DailySummary) CalculateDailyMax ¶ added in v0.7.0
func (s *DailySummary) CalculateDailyMax() time.Duration
CalculateDailyMax 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) CalculateExcusedTime ¶ added in v0.7.0
func (s *DailySummary) CalculateExcusedTime() time.Duration
CalculateExcusedTime 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) CalculateWorkingTime ¶ added in v0.7.0
func (s *DailySummary) CalculateWorkingTime() time.Duration
CalculateWorkingTime 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) IsHoliday ¶ added in v0.7.0
func (s *DailySummary) IsHoliday() bool
IsHoliday returns true if there is a "personalized" leave. Public and unpaid holidays return false. If the holiday falls on a weekend, the day is not counted.
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 ReportBuilder ¶ added in v0.7.0
type ReportBuilder struct {
// contains filtered or unexported fields
}
func NewReporter ¶ added in v0.2.0
func NewReporter(attendances model.AttendanceList, leaves odoo.List[model.Leave], employee *model.Employee, contracts model.ContractList) *ReportBuilder
func (*ReportBuilder) CalculateReport ¶ added in v1.0.0
func (r *ReportBuilder) CalculateReport() (Report, error)
func (*ReportBuilder) SetRange ¶ added in v1.0.0
func (r *ReportBuilder) SetRange(from, to time.Time) *ReportBuilder
SetRange sets the time range in which the report should consider calculations. For example, to build a monthly report, set `from` to the first day of the month from midnight, and `to` to the first day of the next month at midnight.
func (*ReportBuilder) SetTimeZone ¶ added in v0.7.0
func (r *ReportBuilder) SetTimeZone(zone string) *ReportBuilder
func (*ReportBuilder) SkipClampingToNow ¶ added in v1.0.0
func (r *ReportBuilder) SkipClampingToNow(skip bool) *ReportBuilder
SkipClampingToNow ignores the current time when preparing the daily summaries within the time range. By default, the reporter doesn't include days that are happening in the future and thus calculate overtime wrongly.
type Summary ¶
type Summary struct { TotalOvertime time.Duration TotalExcusedTime time.Duration TotalWorkedTime time.Duration // TotalLeave is the amount of paid leave days. // This value respects FTE ratio, e.g. in a 50% ratio a public holiday is still counted as '1d'. TotalLeave float64 AverageWorkload float64 }
type YearlyReport ¶ added in v0.7.0
type YearlyReport struct { MonthlyReports []Report Employee *model.Employee Year int Summary YearlySummary }
type YearlyReportBuilder ¶ added in v1.0.0
type YearlyReportBuilder struct { ReportBuilder // contains filtered or unexported fields }
func NewYearlyReporter ¶ added in v1.0.0
func NewYearlyReporter(attendances model.AttendanceList, leaves odoo.List[model.Leave], employee *model.Employee, contracts model.ContractList) *YearlyReportBuilder
func (*YearlyReportBuilder) CalculateYearlyReport ¶ added in v1.0.0
func (r *YearlyReportBuilder) CalculateYearlyReport() (YearlyReport, error)
func (*YearlyReportBuilder) SetYear ¶ added in v1.0.0
func (r *YearlyReportBuilder) SetYear(year int) *YearlyReportBuilder