Documentation
¶
Index ¶
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" )
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 AttendanceShift 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 }
func (*AttendanceShift) Duration ¶ added in v1.3.0
func (s *AttendanceShift) Duration() time.Duration
Duration returns the difference between AttendanceShift.Start and AttendanceShift.End.
func (*AttendanceShift) String ¶ added in v1.3.0
func (s *AttendanceShift) String() string
String implements fmt.Stringer.
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) CalculateOvertimeSummary ¶ added in v1.1.0
func (s *DailySummary) CalculateOvertimeSummary() OvertimeSummary
CalculateOvertimeSummary 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) 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 OvertimeSummary ¶ added in v1.1.0
type OvertimeSummary struct { RegularWorkingTime time.Duration SickLeaveTime time.Duration AuthoritiesTime time.Duration OutOfOfficeTime time.Duration DailyMax time.Duration PublicServiceTime time.Duration }
func (OvertimeSummary) ExcusedTime ¶ added in v1.1.0
func (s OvertimeSummary) ExcusedTime() time.Duration
ExcusedTime returns the sum of AuthoritiesTime, PublicServiceTime and SickLeaveTime.
func (OvertimeSummary) Overtime ¶ added in v1.1.0
func (s OvertimeSummary) Overtime() time.Duration
Overtime returns the total overtime with all business rules respected.
func (OvertimeSummary) WorkingTime ¶ added in v1.1.0
func (s OvertimeSummary) WorkingTime() time.Duration
WorkingTime is the sum of OutOfOfficeTime (multiplied with 1.5) and RegularWorkingTime.
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(location *time.Location) *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 TotalOutOfOfficeTime 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