Beispiel #1
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L5TN_OTF_1516 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Base();
            //Put your code here

            ORM_CMN_CAL_CalculationTimeframe.Query timeFrameQuery = new ORM_CMN_CAL_CalculationTimeframe.Query();
            timeFrameQuery.Tenant_RefID = securityTicket.TenantID;
            timeFrameQuery.IsDeleted    = false;
            var timeFrames = ORM_CMN_CAL_CalculationTimeframe.Query.Search(Connection, Transaction, timeFrameQuery);
            if (timeFrames != null && timeFrames.Any(x => x.CalculationTimeframe_StartDate.Year == Parameter.year) && timeFrames.Any(x => x.CalculationTimeframe_StartDate.Year == Parameter.year + 1))
            {
                var timeFrame     = timeFrames.First(x => x.CalculationTimeframe_StartDate.Year == Parameter.year);
                var nextTimeFrame = timeFrames.First(x => x.CalculationTimeframe_StartDate.Year == Parameter.year + 1);
                ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query employeeAbsenceTimeFrameSatisticQuery = new ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query();
                employeeAbsenceTimeFrameSatisticQuery.CalculationTimeframe_RefID = timeFrame.CMN_CAL_CalculationTimeframeID;
                employeeAbsenceTimeFrameSatisticQuery.Tenant_RefID = securityTicket.TenantID;
                employeeAbsenceTimeFrameSatisticQuery.IsDeleted    = false;
                var employeeAbsenceTimeFrameSatistics = ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query.Search(Connection, Transaction, employeeAbsenceTimeFrameSatisticQuery);
                if (employeeAbsenceTimeFrameSatistics != null)
                {
                    foreach (var previousEmployeeAbsenceTimeFrameSatistic in employeeAbsenceTimeFrameSatistics)
                    {
                        ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query currentEmployeeAbsenceTimeFrameSatisticQuery = new ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query();
                        currentEmployeeAbsenceTimeFrameSatisticQuery.AbsenceReason_RefID        = previousEmployeeAbsenceTimeFrameSatistic.AbsenceReason_RefID;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.Employee_RefID             = previousEmployeeAbsenceTimeFrameSatistic.Employee_RefID;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.Tenant_RefID               = securityTicket.TenantID;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.IsDeleted                  = false;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.CalculationTimeframe_RefID = nextTimeFrame.CMN_CAL_CalculationTimeframeID;
                        var currentEmployeeAbsenceTimeFrameSatistics = ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query.Search(Connection, Transaction, currentEmployeeAbsenceTimeFrameSatisticQuery);
                        if (currentEmployeeAbsenceTimeFrameSatistics != null)
                        {
                            foreach (var currentEmployeeAbsenceTimeFrameSatistic in currentEmployeeAbsenceTimeFrameSatistics)
                            {
                                currentEmployeeAbsenceTimeFrameSatistic.R_AbsenceCarryOver_InDays  = 0;
                                currentEmployeeAbsenceTimeFrameSatistic.R_AbsenceCarryOver_InHours = 0;
                                currentEmployeeAbsenceTimeFrameSatistic.Save(Connection, Transaction);
                            }
                        }
                    }
                }
                timeFrame.CalculationTimefrate_EndDate = new DateTime(0);
                timeFrame.Save(Connection, Transaction);
            }
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_L5TN_GCTFFTAY_1320 Execute(DbConnection Connection, DbTransaction Transaction, P_L5TN_GCTFFTAY_1320 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5TN_GCTFFTAY_1320();
            //Put your code here

            ORM_CMN_CAL_CalculationTimeframe.Query calcTimeFrameQuery = new ORM_CMN_CAL_CalculationTimeframe.Query();
            calcTimeFrameQuery.Tenant_RefID = securityTicket.TenantID;
            calcTimeFrameQuery.IsDeleted    = false;

            var calcTimeFrame = ORM_CMN_CAL_CalculationTimeframe.Query.Search(Connection, Transaction, calcTimeFrameQuery).FirstOrDefault(x => x.CalculationTimeframe_StartDate.Year == Parameter.Year);

            returnValue.Result = new L5TN_GCTFFTAY_1320();

            L5TN_GCTFFT_1529 result = new L5TN_GCTFFT_1529();


            if (calcTimeFrame == null)
            {
                ORM_CMN_CAL_CalculationTimeframe newCalcTimeframe = new ORM_CMN_CAL_CalculationTimeframe();
                newCalcTimeframe.CalculationTimeframe_StartDate        = new DateTime(Parameter.Year, 1, 1);
                newCalcTimeframe.CalculationTimeframe_EstimatedEndDate = new DateTime(Parameter.Year, 12, 31);
                newCalcTimeframe.IsCalculationTimeframe_Active         = false;
                newCalcTimeframe.Tenant_RefID = securityTicket.TenantID;
                newCalcTimeframe.Save(Connection, Transaction);

                result.CalculationTimeframe_EstimatedEndDate = newCalcTimeframe.CalculationTimeframe_EstimatedEndDate;
                result.CalculationTimeframe_StartDate        = newCalcTimeframe.CalculationTimeframe_StartDate;
                result.CalculationTimefrate_EndDate          = newCalcTimeframe.CalculationTimefrate_EndDate;
                result.CMN_CAL_CalculationTimeframeID        = newCalcTimeframe.CMN_CAL_CalculationTimeframeID;
                result.Creation_Timestamp            = newCalcTimeframe.Creation_Timestamp;
                result.IsCalculationTimeframe_Active = newCalcTimeframe.IsCalculationTimeframe_Active;
            }
            else
            {
                result.CalculationTimeframe_EstimatedEndDate = calcTimeFrame.CalculationTimeframe_EstimatedEndDate;
                result.CalculationTimeframe_StartDate        = calcTimeFrame.CalculationTimeframe_StartDate;
                result.CalculationTimefrate_EndDate          = calcTimeFrame.CalculationTimefrate_EndDate;
                result.CMN_CAL_CalculationTimeframeID        = calcTimeFrame.CMN_CAL_CalculationTimeframeID;
                result.Creation_Timestamp            = calcTimeFrame.Creation_Timestamp;
                result.IsCalculationTimeframe_Active = calcTimeFrame.IsCalculationTimeframe_Active;
            }

            returnValue.Result.CalculationTimeFrame = result;

            return(returnValue);

            #endregion UserCode
        }
Beispiel #3
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5TN_SCTF_1041 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here


            if (Parameter.IsCalculationTimeframe_Active)
            {
                ORM_CMN_CAL_CalculationTimeframe.Query query = new ORM_CMN_CAL_CalculationTimeframe.Query();
                query.Tenant_RefID = securityTicket.TenantID;
                ORM_CMN_CAL_CalculationTimeframe.Query values = new ORM_CMN_CAL_CalculationTimeframe.Query();
                values.IsCalculationTimeframe_Active = false;
                ORM_CMN_CAL_CalculationTimeframe.Query.Update(Connection, Transaction, query, values);
            }
            ORM_CMN_CAL_CalculationTimeframe timeFrame = new ORM_CMN_CAL_CalculationTimeframe();
            if (Parameter.CMN_CAL_CalculationTimeframeID != Guid.Empty)
            {
                var result = timeFrame.Load(Connection, Transaction, Parameter.CMN_CAL_CalculationTimeframeID);
                if (result.Status != FR_Status.Success || timeFrame.CMN_CAL_CalculationTimeframeID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }

            timeFrame.CalculationTimeframe_EstimatedEndDate = Parameter.CalculationTimeframe_EstimatedEndDate;
            timeFrame.CalculationTimeframe_StartDate        = Parameter.CalculationTimeframe_StartDate;
            timeFrame.CalculationTimefrate_EndDate          = Parameter.CalculationTimefrate_EndDate;
            timeFrame.IsCalculationTimeframe_Active         = Parameter.IsCalculationTimeframe_Active;
            timeFrame.Tenant_RefID = securityTicket.TenantID;
            timeFrame.Save(Connection, Transaction);
            returnValue.Result = timeFrame.CMN_CAL_CalculationTimeframeID;

            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L5TN_CTF_1341 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            ORM_CMN_CAL_CalculationTimeframe.Query timeFrameQuery = new ORM_CMN_CAL_CalculationTimeframe.Query();
            timeFrameQuery.Tenant_RefID = securityTicket.TenantID;
            timeFrameQuery.IsDeleted    = false;
            var timeFrames = ORM_CMN_CAL_CalculationTimeframe.Query.Search(Connection, Transaction, timeFrameQuery);
            if (timeFrames != null && timeFrames.Any(x => x.CalculationTimeframe_StartDate.Year == Parameter.year) && timeFrames.Any(x => x.CalculationTimeframe_StartDate.Year == Parameter.year + 1))
            {
                var currentTimeFrame = timeFrames.First(x => x.CalculationTimeframe_StartDate.Year == Parameter.year);
                var nextTimeFrame    = timeFrames.First(x => x.CalculationTimeframe_StartDate.Year == Parameter.year + 1);

                ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query employeeAbsenceTimeFrameSatisticQuery = new ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query();
                employeeAbsenceTimeFrameSatisticQuery.CalculationTimeframe_RefID = currentTimeFrame.CMN_CAL_CalculationTimeframeID;
                employeeAbsenceTimeFrameSatisticQuery.Tenant_RefID = securityTicket.TenantID;
                employeeAbsenceTimeFrameSatisticQuery.IsDeleted    = false;
                var employeeAbsenceTimeFrameSatistics = ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query.Search(Connection, Transaction, employeeAbsenceTimeFrameSatisticQuery);
                if (employeeAbsenceTimeFrameSatistics != null)
                {
                    foreach (var previousEmployeeAbsenceTimeFrameSatistic in employeeAbsenceTimeFrameSatistics)
                    {
                        ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query currentEmployeeAbsenceTimeFrameSatisticQuery = new ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query();
                        currentEmployeeAbsenceTimeFrameSatisticQuery.AbsenceReason_RefID        = previousEmployeeAbsenceTimeFrameSatistic.AbsenceReason_RefID;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.Employee_RefID             = previousEmployeeAbsenceTimeFrameSatistic.Employee_RefID;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.Tenant_RefID               = securityTicket.TenantID;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.IsDeleted                  = false;
                        currentEmployeeAbsenceTimeFrameSatisticQuery.CalculationTimeframe_RefID = nextTimeFrame.CMN_CAL_CalculationTimeframeID;
                        var currentEmployeeAbsenceTimeFrameSatistics = ORM_CMN_BPT_EMP_Employee_AbsenceReason_TimeframeStatistic.Query.Search(Connection, Transaction, currentEmployeeAbsenceTimeFrameSatisticQuery);
                        if (currentEmployeeAbsenceTimeFrameSatistics != null)
                        {
                            foreach (var currentEmployeeAbsenceTimeFrameSatistic in currentEmployeeAbsenceTimeFrameSatistics)
                            {
                                currentEmployeeAbsenceTimeFrameSatistic.R_AbsenceCarryOver_InDays  = previousEmployeeAbsenceTimeFrameSatistic.R_TotalAllowedAbsenceTime_InDays + previousEmployeeAbsenceTimeFrameSatistic.R_AbsenceCarryOver_InDays;
                                currentEmployeeAbsenceTimeFrameSatistic.R_AbsenceCarryOver_InHours = previousEmployeeAbsenceTimeFrameSatistic.R_TotalAllowedAbsenceTime_InHours + previousEmployeeAbsenceTimeFrameSatistic.R_AbsenceCarryOver_InHours;
                                currentEmployeeAbsenceTimeFrameSatistic.Save(Connection, Transaction);
                            }
                        }
                    }
                }
                //Calculate Balances
                if (timeFrames.Any(x => x.CalculationTimeframe_StartDate.Year == Parameter.year - 1))
                {
                    var previousTimeFrame = timeFrames.First(x => x.CalculationTimeframe_StartDate.Year == Parameter.year - 1);
                    ORM_CMN_BPT_EMP_STA_OvertimeStatistic.Query overtimeStatistics = new ORM_CMN_BPT_EMP_STA_OvertimeStatistic.Query();
                    overtimeStatistics.CMN_CAL_CalculationTimeframe_RefID = previousTimeFrame.CMN_CAL_CalculationTimeframeID;
                    overtimeStatistics.Tenant_RefID = securityTicket.TenantID;
                    overtimeStatistics.IsDeleted    = false;
                    var employeeOvertimeStatistics = ORM_CMN_BPT_EMP_STA_OvertimeStatistic.Query.Search(Connection, Transaction, overtimeStatistics);
                    List <ORM_CMN_BPT_EMP_STA_OvertimeStatistic> employeeTimeFrameStatistics = new List <ORM_CMN_BPT_EMP_STA_OvertimeStatistic>();
                    if (employeeOvertimeStatistics != null)
                    {
                        foreach (var previousEmployeeOvertimeStatistic in employeeOvertimeStatistics)
                        {
                            var currentEmploeeOvertimeStatistic = new ORM_CMN_BPT_EMP_STA_OvertimeStatistic();
                            currentEmploeeOvertimeStatistic.CMN_CAL_CalculationTimeframe_RefID = currentTimeFrame.CMN_CAL_CalculationTimeframeID;
                            currentEmploeeOvertimeStatistic.Employee_RefID            = previousEmployeeOvertimeStatistic.Employee_RefID;
                            currentEmploeeOvertimeStatistic.IsOvertimeInEmployeeDays  = previousEmployeeOvertimeStatistic.IsOvertimeInEmployeeDays;
                            currentEmploeeOvertimeStatistic.IsOvertimeInEmployeeHours = previousEmployeeOvertimeStatistic.IsOvertimeInEmployeeHours;
                            currentEmploeeOvertimeStatistic.OvertimeIn_EmployeeDays   = previousEmployeeOvertimeStatistic.OvertimeIn_EmployeeDays;
                            currentEmploeeOvertimeStatistic.OvertimeIn_EmployeeHours  = previousEmployeeOvertimeStatistic.OvertimeIn_EmployeeHours;
                        }
                    }

                    foreach (var employeeID in Parameter.employeesWithContractsForTenant)
                    {
                        ORM_CMN_BPT_EMP_STA_OvertimeStatistic currentEmploeeOvertimeStatistic = new ORM_CMN_BPT_EMP_STA_OvertimeStatistic();
                        if (employeeTimeFrameStatistics.Any(i => i.Employee_RefID == employeeID))
                        {
                            employeeTimeFrameStatistics.First(i => i.Employee_RefID == employeeID);
                            //cls_Get_EffectiveWorkTimes_For_Period_And_Employee.
                        }
                        else
                        {
                        }
                    }
                }



                currentTimeFrame.CalculationTimefrate_EndDate = new DateTime(currentTimeFrame.CalculationTimeframe_StartDate.Year, 12, 31, 23, 59, 59);
                currentTimeFrame.Save(Connection, Transaction);
            }



            //Put your code here
            return(returnValue);

            #endregion UserCode
        }