structs

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTypeAuto     = RequestType("auto")
	RequestTypeVacation = RequestType("vacation")
	RequestTypeTimeOff  = RequestType("time-off")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	// Approved is set to true if the off-time request has been approved.
	// Requests that are not approved are ignored when calculating an the
	// current vacation credit of an employee.
	Approved bool `json:"approved" bson:"approved"`

	// ApprovedAt is set to the time the off-time request has been approved
	// my management.
	ApprovedAt time.Time `json:"approvedAt" bson:"approvedAt"`

	// ApproverID holds the ID of the user that approved the request.
	ApproverID string `json:"approverId" bson:"approverId"`

	// Comment is an optional comment that may be set by management to
	// justify approval or rejection of an off-time request.
	Comment string `json:"comment" bson:"comment"`
}

Approval holds approval information for an off-time request.

func (*Approval) ToProto

func (approval *Approval) ToProto() *rosterv1.OffTimeApproval

type Constraint

type Constraint struct {
	ID            primitive.ObjectID `json:"id" bson:"_id"`
	Description   string             `json:"description" bson:"description" hcl:",label"`
	Expression    string             `json:"expression" bson:"expression" hcl:"expr"`
	AppliesToRole []string           `json:"appliesToRole" bson:"appliesToRole" hcl:"appliesToRole"`
	AppliesToUser []string           `json:"appliesToUser" bson:"appliesToUser" hcl:"appliesToUser"`
	Hard          bool               `json:"hard" bson:"hard" hcl:"hard"`
	Penalty       int                `json:"penalty" bson:"penalty" hcl:"penalty"`
	Deny          bool               `json:"deny" bson:"deny" hcl:"deny"`
	RosterOnly    bool               `json:"rosterOnly" bson:"rosterOnly"`
	CreatedAt     time.Time          `bson:"createdAt"`
	CreatorId     string             `bson:"creatorId"`
	UpdatedAt     time.Time          `bson:"updatedAt"`
	LastUpdatedBy string             `bson:"lastUpdatedBy"`
}

func (Constraint) ToProto

func (c Constraint) ToProto() *rosterv1.Constraint

type ConstraintViolation

type ConstraintViolation struct {
	ID      primitive.ObjectID `json:"id"`
	Panalty int                `json:"penalty"`
	Type    string             `json:"type"` // offtime, constraint
	Name    string             `json:"name"`
	Hard    bool               `json:"hard"`
}

type Daytime

type Daytime time.Duration

Daytime represents a time during any day. It is encoded as the duration from midnight. Note that this makes Daytime timezone specific so it is important to always use the same timezone when calculating and actual time.Time.

An example would be:

var dt = Daytime(8 * time.Hour + 30 * time.Minute) // 08:30
daytime.Midnight(time.Now()).Add()

func (*Daytime) FromProto

func (dt *Daytime) FromProto(protoDayTime *rosterv1.Daytime)

func (Daytime) MarshalJSON

func (dt Daytime) MarshalJSON() ([]byte, error)

func (Daytime) String

func (dt Daytime) String() string

func (Daytime) ToProto

func (dt Daytime) ToProto() *rosterv1.Daytime

func (*Daytime) UnmarshalJSON

func (dt *Daytime) UnmarshalJSON(blob []byte) error

type DutyRoster

type DutyRoster struct {
	ID             primitive.ObjectID `bson:"_id"`
	From           string             `bson:"from"`
	To             string             `bson:"to"`
	Shifts         []PlannedShift     `bson:"shifts"`
	Approved       bool               `bson:"approved"`
	ApprovedAt     time.Time          `bson:"approved_at"`
	ApproverUserId string             `bson:"approver_user_id"`
	LastModifiedBy string             `bson:"last_modified_by"`
	CreatedAt      time.Time          `bson:"created_at"`
	UpdatedAt      time.Time          `bson:"updated_at"`
	ShiftTags      []string           `bson:"shift_tags"`
	RosterTypeName string             `bson:"roster_type_name"`

	Deleted      bool               `bson:"deleted,omitempty"`
	SupersededBy primitive.ObjectID `bson:"supersededBy,omitempty"`
}

func (DutyRoster) FromTime

func (r DutyRoster) FromTime() time.Time

func (DutyRoster) IsApproved

func (r DutyRoster) IsApproved() bool

func (DutyRoster) ToProto

func (r DutyRoster) ToProto() *rosterv1.Roster

func (DutyRoster) ToTime

func (r DutyRoster) ToTime() time.Time

type JSDuration

type JSDuration time.Duration

func (JSDuration) MarshalJSON

func (d JSDuration) MarshalJSON() ([]byte, error)

func (*JSDuration) UnmarshalJSON

func (d *JSDuration) UnmarshalJSON(blob []byte) error

type OffTimeCosts

type OffTimeCosts struct {
	ID         primitive.ObjectID `bson:"_id"`
	UserID     string             `bson:"userId"`
	OfftimeID  primitive.ObjectID `bson:"offtimeId"`
	RosterID   primitive.ObjectID `bson:"rosterId"`
	CreatedAt  time.Time          `bson:"createdAt"`
	CreatorId  string             `bson:"creatorId"`
	Costs      time.Duration      `bson:"costs"`
	IsVacation bool               `bson:"isVacation"`
	Date       time.Time          `bson:"date"`
	Comment    string             `bson:"comment"`
}

OffTimeCosts describes the vacation costs of an off-time request.

type OffTimeEntry

type OffTimeEntry struct {
	// ID is the ID of the OffTimeEntry in the MongoDB database collection.
	ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`

	// From holds the time at which the employee requests off-time or after which
	// credits given by management apply (only if RequestType == "credits")
	From time.Time `json:"from" bson:"from"`

	// To holds the time until which the employee requests off-time. This field
	// is left empty (zero-time) for RequestType == "credits"
	To time.Time `json:"to" bson:"to"`

	// Description may holds an optional description about the off-time request.
	Description string `json:"description" bson:"description"`

	// RequestorId is the identifier of the employee for which this off-time request
	// is. Note that employees can only ever request off-time for themselves but
	// management may create off-time requests on behave of an employee for auditing
	// and history-keeping purposes.
	RequestorId string `json:"requestorId" bson:"requestorId"`

	// RequestType is the request type of this off-time request. See RequestType for
	// available types and their meaning.
	RequestType RequestType `json:"requestType" bson:"requestType"`

	// CreatedAt holds the time at which the request has been created.
	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`

	// CreatorId holds the name of the user that created this request.
	// Normally this is the same as staffID but may be set to the name of
	// a management user if the off-time request has been created on behave
	// of another user.
	CreatorId string `json:"creatorId" bson:"creatorId"`

	// Approval holds information about the approval of this request.
	// If Approval is still nil this request has neither been approved
	// nor rejected by management and must not be considered for overtime and
	// vacation credit calculations.
	Approval *Approval `json:"approval" bson:"approval"`
}

func (OffTimeEntry) ToProto

func (entry OffTimeEntry) ToProto() *rosterv1.OffTimeEntry

type PlannedShift

type PlannedShift struct {
	From            time.Time          `bson:"from"`
	To              time.Time          `bson:"to"`
	AssignedUserIds []string           `bson:"assigned_user_ids"`
	WorkShiftID     primitive.ObjectID `bson:"work_shift_id"`
}

func (*PlannedShift) FromProto

func (p *PlannedShift) FromProto(protoShift *rosterv1.PlannedShift) error

func (PlannedShift) ToProto

func (p PlannedShift) ToProto() *rosterv1.PlannedShift

type RequestType

type RequestType string

RequestType describes the type of an off-time request.

It may be one of the following:

  • vacation: A request for vacation. That means that the employee is expecting to pay for the off-time request with the full amount of vacation days required for it.
  • time-off: A request for compensatory time-off. That means that the employee either must have enough overtime or that he/she is willing to work more time during the rest of the month.
  • auto: The employee doesn't really care if it's vacation or compensatory time-off and it's up to the management to decide.

func (RequestType) ToProto

func (requestType RequestType) ToProto() rosterv1.OffTimeType

type RequiredShift

type RequiredShift struct {
	From            time.Time
	To              time.Time
	WorkShiftID     primitive.ObjectID
	EligibleUserIds []string
	OnHoliday       bool
	OnWeekend       bool
	Violations      map[string]*rosterv1.ConstraintViolationList
}

func (RequiredShift) ToProto

func (rs RequiredShift) ToProto() *rosterv1.RequiredShift

type RosterType

type RosterType struct {
	UniqueName string   `bson:"unique_name"`
	ShiftTags  []string `bson:"shift_tags"`
	OnCallTags []string `bson:"on_call_tags"`
}

func (RosterType) ToProto

func (t RosterType) ToProto() *rosterv1.RosterType

type WorkShift

type WorkShift struct {
	From               Daytime            `json:"from" bson:"from" hcl:"from"`
	Duration           JSDuration         `json:"duration" bson:"duration" hcl:"to"`
	ID                 primitive.ObjectID `json:"id" bson:"_id"`
	Days               []time.Weekday     `json:"days" bson:"days" hcl:"days"`
	ShortName          string             `json:"shortName" bson:"shortName"`
	Name               string             `json:"name" bson:"name" hcl:",label"`
	OnHoliday          bool               `json:"onHoliday" bson:"onHoliday" hcl:"onHoliday"`
	EligibleRoles      []string           `json:"eligibleRoles" bson:"eligibleRoles,omitempty" hcl:"eligibleRoles"`
	MinutesWorth       *int               `json:"minutesWorth,omitempty" bson:"minutesWorth,omitempty" hcl:"minutesWorth"`
	RequiredStaffCount int                `json:"requiredStaffCount" bson:"requiredStaffCount" hcl:"requiredStaffCount"`
	Color              string             `json:"color" bson:"color" hcl:"color"`
	Description        string             `json:"description" bson:"description"`
	Order              int                `json:"order" bson:"order"`
	Tags               []string           `json:"tags" bson:"tags"`
	Deleted            bool               `bson:"deleted"`
}

func (WorkShift) AtDay

func (ws WorkShift) AtDay(t time.Time) (time.Time, time.Time)

func (WorkShift) ToProto

func (shift WorkShift) ToProto() *rosterv1.WorkShift

type WorkTime

type WorkTime struct {
	ID                        primitive.ObjectID `json:"id" bson:"_id"`
	UserID                    string             `json:"userID" bson:"userID"`
	TimePerWeek               time.Duration      `json:"timePerWeek" bson:"timePerWeek"`
	ApplicableFrom            time.Time          `json:"applicableFrom" bson:"applicableFrom"`
	VacationWeeksPerYear      float32            `json:"vacationWeeksPerYear" bson:"vacationWeeksPerYear"`
	OvertimeAllowancePerMonth time.Duration      `json:"overtimeAllowance" bson:"overtimeAllowance"`
	EndsWith                  time.Time          `json:"endsWith,omitempty" bson:"endsWith,omitempty"`
	ExcludeFromTimeTracking   bool               `json:"excludeFromTimeTracking" bson:"excludeFromTimeTracking"`
}

type WorkTimeStatus

type WorkTimeStatus struct {
	TimePerWeek           JSDuration `json:"timePerWeek"`
	ExpectedWorkTime      JSDuration `json:"expectedWorkTime"`
	PlannedWorkTime       JSDuration `json:"plannedWorkTime"`
	Penalty               int        `json:"penalty"`
	OvertimePenaltyRatio  float64    `json:"overtimePenaltyRation" bson:"overtimePenaltyRation"`
	UndertimePenaltyRatio float64    `json:"undertimePenaltyRation" bson:"undertimePenaltyRation"`
}

Jump to

Keyboard shortcuts

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