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
AttendanceSummariesCompute
object (tmp
) and initializes its properties using the data from the providedCalendarScheduleTable
andAllCacheStruct
.
- Creates a temporary
-
Populate Summary Fields:
- Sets key fields in the
tmp
struct using values fromcalSched
:UserProfileID
CompanyID
TheDate
ScheduleID
CalendarScheduleID
, etc.
- Populates shift-specific details like
ShiftID
,OrderNum
, andCalendarHolidayID
from 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
createBreakDetails
function to generate break-related information for the summary.
- Calls the
-
Return the Generated Summary:
- Returns the fully populated
AttendanceSummariesCompute
struct.
- Returns the fully populated
Key Notes
- Header Type: The function initializes the summary as a placeholder header with
SummaryType
set 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
createBreakDetails
function 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.CalendarScheduleTable
entity.AttendanceSummariesTable
- Cache:
caching.AllCacheStruct
Related Functions
createBreakDetails
:- Used to handle break-related details within the generated summary.