createSummaryFromCalendarDetail Function
Overview
The createSummaryFromCalendarDetail function is responsible for creating a summary placeholder header and details from a CalendarSchedule. It is typically used for generating new attendance summaries.
Function Signature
func createSummaryFromCalendarDetail(calSched *entity.CalendarScheduleTable, idx int, cache *caching.AllCacheStruct) AttendanceSummariesCompute
Parameters
| Parameter | Type | Description |
|---|---|---|
calSched | *entity.CalendarScheduleTable | The calendar schedule containing data to populate the attendance summary. |
idx | int | The index of the specific detail within the calendar schedule's details to use. |
cache | *caching.AllCacheStruct | A cache structure containing preloaded shift and rule data for use in the summary generation. |
Returns
AttendanceSummariesCompute: A struct containing the generated attendance summary and related metadata.
Function Details
-
Initialize Temporary Structures:
- Creates a temporary
AttendanceSummariesComputeobject (tmp) and initializes its properties using the data from the providedCalendarScheduleTableandAllCacheStruct.
- Creates a temporary
-
Populate Summary Fields:
- Sets key fields in the
tmpstruct using values fromcalSched:UserProfileIDCompanyIDTheDateScheduleIDCalendarScheduleID, etc.
- Populates shift-specific details like
ShiftID,OrderNum, andCalendarHolidayIDfrom the details indexed byidx.
- Sets key fields in the
-
Set Flags and Indicators:
- Configures flags for overtime, work type, holiday behavior, and other operational modes (e.g.,
IsOvertime,IsFlexible,IsIgnoreHoliday, etc.).
- Configures flags for overtime, work type, holiday behavior, and other operational modes (e.g.,
-
Set Shift from Cache:
- Retrieves shift details from the provided cache structure based on
ShiftID.
- Retrieves shift details from the provided cache structure based on
-
Generate Break Details:
- Calls the
createBreakDetailsfunction to generate break-related information for the summary.
- Calls the
-
Return the Generated Summary:
- Returns the fully populated
AttendanceSummariesComputestruct.
- Returns the fully populated
Key Notes
- Header Type: The function initializes the summary as a placeholder header with
SummaryTypeset toSUMMARY_HEADER. - Integration with Cache: Leverages the cache for shift information to ensure efficiency and reduce database calls.
- Customizable Flags: Handles various schedule attributes such as overtime rules and flexible schedules.
- Break Details: Delegates break-related logic to the
createBreakDetailsfunction for modularity.
Example Usage
calSched := &entity.CalendarScheduleTable{
UserProfileID: "user123",
CompanyID: "companyXYZ",
TheDate: "2024-12-01",
// other fields...
}
cache := &caching.AllCacheStruct{
Shifts: preloadedShifts,
}
summary := createSummaryFromCalendarDetail(calSched, 0, cache)
// Use `summary` as needed...
Dependencies
- Entities:
entity.CalendarScheduleTableentity.AttendanceSummariesTable
- Cache:
caching.AllCacheStruct
Related Functions
createBreakDetails:- Used to handle break-related details within the generated summary.