Documentation
¶
Index ¶
- func Migrate(db *gorm.DB) error
- type EmployeeOvertimeService
- func (e *EmployeeOvertimeService) CountByEmployeeID(employeeID string, startDate *time.Time, endDate *time.Time) (map[string]int64, error)
- func (e *EmployeeOvertimeService) CreateEmployeeOvertime(employeeOvertime *models.EmployeeOvertimeModel) error
- func (e *EmployeeOvertimeService) DeleteEmployeeOvertime(id string) error
- func (e *EmployeeOvertimeService) FindAllByEmployeeID(request *http.Request, employeeID string) (paginate.Page, error)
- func (e *EmployeeOvertimeService) FindAllEmployeeOvertimes(request *http.Request) (paginate.Page, error)
- func (e *EmployeeOvertimeService) GetEmployeeOvertimeByID(id string) (*models.EmployeeOvertimeModel, error)
- func (e *EmployeeOvertimeService) UpdateEmployeeOvertime(employeeOvertime *models.EmployeeOvertimeModel) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EmployeeOvertimeService ¶
type EmployeeOvertimeService struct {
// contains filtered or unexported fields
}
func NewEmployeeOvertimeService ¶
func NewEmployeeOvertimeService(ctx *context.ERPContext) *EmployeeOvertimeService
NewEmployeeOvertimeService creates a new instance of EmployeeOvertimeService.
The EmployeeOvertimeService is responsible for managing operations related to employee overtime. This function initializes the service with a GORM database and an ERP context, which are used for database operations and authentication/authorization purposes respectively.
Parameters:
- ctx: A pointer to an ERPContext that provides access to the database and other context-specific information.
Returns:
- A pointer to a new instance of EmployeeOvertimeService.
func (*EmployeeOvertimeService) CountByEmployeeID ¶
func (e *EmployeeOvertimeService) CountByEmployeeID(employeeID string, startDate *time.Time, endDate *time.Time) (map[string]int64, error)
CountByEmployeeID returns a map of counts of employee overtime records filtered by the given employee ID and date range, grouped by status.
The map contains the following keys: - PENDING: the count of records with "PENDING" status - APPROVED: the count of records with "APPROVED" status - REJECTED: the count of records with "REJECTED" status
Parameters:
- employeeID: The ID of the employee whose overtime records are being counted.
- startDate: The start date of the date range for filtering overtime records.
- endDate: The end date of the date range for filtering overtime records.
Returns:
- A map of overtime counts by status.
- An error if the operation fails.
func (*EmployeeOvertimeService) CreateEmployeeOvertime ¶
func (e *EmployeeOvertimeService) CreateEmployeeOvertime(employeeOvertime *models.EmployeeOvertimeModel) error
func (*EmployeeOvertimeService) DeleteEmployeeOvertime ¶
func (e *EmployeeOvertimeService) DeleteEmployeeOvertime(id string) error
DeleteEmployeeOvertime deletes an employee overtime record from the database by ID.
The function takes an ID as input and returns an error if the deletion operation fails. The function uses GORM to delete the employee overtime data from the employee_overtimes table. If the deletion is successful, the error is nil. Otherwise, the error contains information about what went wrong.
func (*EmployeeOvertimeService) FindAllByEmployeeID ¶
func (e *EmployeeOvertimeService) FindAllByEmployeeID(request *http.Request, employeeID string) (paginate.Page, error)
FindAllByEmployeeID retrieves a paginated list of employee overtime records by employee ID.
This function takes an HTTP request and an employee ID as inputs. It uses GORM to query the database for employee overtime records, preloading the associated Employee (with User, JobTitle, WorkLocation, WorkShift, Branch) and Approver (with User) models. It applies various filters based on the request parameters such as company ID, search term, date range, specific date, approver ID, and reviewer ID. The results can be ordered based on a specified order parameter or defaults to ordering by start_time_request in descending order.
Pagination is utilized to manage the result set, and any necessary request modifications are applied using the utils.FixRequest utility. The function returns a paginated page of EmployeeOvertimeModel and an error if the operation fails.
func (*EmployeeOvertimeService) FindAllEmployeeOvertimes ¶
func (e *EmployeeOvertimeService) FindAllEmployeeOvertimes(request *http.Request) (paginate.Page, error)
FindAllEmployeeOvertimes retrieves a paginated list of employee overtime records.
This function takes an HTTP request as input and returns a paginated page of EmployeeOvertimeModel and an error if the operation fails. It uses GORM to query the database for employee overtime records, preloading the associated Employee (with User, JobTitle, WorkLocation, WorkShift, Branch) and Approver (with User) models. It applies various filters based on the request parameters such as company ID, search term, date range, specific date, approver ID, and reviewer ID. The results can be ordered based on a specified order parameter or defaults to ordering by start_time_request in descending order.
Pagination is utilized to manage the result set, and any necessary request modifications are applied using the utils.FixRequest utility.
func (*EmployeeOvertimeService) GetEmployeeOvertimeByID ¶
func (e *EmployeeOvertimeService) GetEmployeeOvertimeByID(id string) (*models.EmployeeOvertimeModel, error)
GetEmployeeOvertimeByID retrieves an employee overtime by its ID from the database.
The function takes an overtime ID as input and returns a pointer to an EmployeeOvertimeModel and an error if the operation fails. It uses GORM to preload related models, including Employee, Approver, Attendance, and ApprovalByAdmin, ensuring all relevant data is fetched. If the overtime is found, it returns the model; otherwise, it returns an error indicating what went wrong.
func (*EmployeeOvertimeService) UpdateEmployeeOvertime ¶
func (e *EmployeeOvertimeService) UpdateEmployeeOvertime(employeeOvertime *models.EmployeeOvertimeModel) error
UpdateEmployeeOvertime updates an existing employee overtime record in the database.
The function takes an EmployeeOvertimeModel pointer as input and returns an error if the operation fails. The function uses GORM to update the employee overtime data in the employee_overtimes table where the ID matches.
If the update is successful, the error is nil. Otherwise, the error contains information about what went wrong.