private VMRosterModel CalculateRosterFields(VMRosterApplication vm, int _RotaAppID) { VAT_Shift shift = DDService.GetShift().Where(aa => aa.PShiftID == vm.ShiftID).First(); VMRosterModel _objmodel = new VMRosterModel(); try { int endPoint = 0; if (vm.RosterTypeID == 2) { endPoint = (vm.DateEnded.Value - vm.DateStarted.Value).Days + 1; } else if (vm.RosterTypeID == 3) { endPoint = 15; } else if (vm.RosterTypeID == 4) { endPoint = System.DateTime.DaysInMonth(vm.DateStarted.Value.Year, vm.DateEnded.Value.Month); } else if (vm.RosterTypeID == 4) { endPoint = 84; } _objmodel._RosterAttributes = new List <RosterAttributes>(); _objmodel.Criteria = ConvertCriteriaAbrvToFull("C"); _objmodel.RotaAppID = _RotaAppID; _objmodel.CriteriaValue = vm.CrewID; _objmodel.ShiftID = vm.ShiftID; _objmodel.StartDate = vm.DateStarted.Value; _objmodel.EndDate = vm.DateEnded.Value; _objmodel.NoOfDays = endPoint; _objmodel.CriteriaValueName = DDService.GetCrew().Where(aa => aa.PCrewID == vm.CrewID).First().CrewName; _objmodel.ShiftName = shift.ShiftName; DateTime _StartDate = vm.DateStarted.Value; for (int i = 1; i <= endPoint; i++) { string _day = _StartDate.Date.ToString("dddd"); string _date = _StartDate.Date.ToString("dd-MMM-yyyy"); string shiftStartTimeString = GetShiftStartTimeString(_StartDate.DayOfWeek, vm); TimeSpan shiftStartTime = ATAssistant.ConvertTime(shiftStartTimeString); int workMin = GetWorkMinutesForSpecificDates(_StartDate, vm); _objmodel._RosterAttributes.Add(new RosterAttributes { ID = i, DateString = _date, Day = _day, DutyDate = _StartDate.Date, DutyTimeString = shiftStartTimeString, DutyTime = shiftStartTime, WorkMin = workMin }); _StartDate = _StartDate.AddDays(1); } Expression <Func <RosterApplication, bool> > SpecificEntries = c => c.RotaAppID == _RotaAppID; RosterApplication rosterApp = RosterApplicationService.GetIndexSpecific(SpecificEntries).First(); rosterApp.DateEnded = _StartDate.AddDays(-1); RosterApplicationService.PostEdit(rosterApp); return(_objmodel); } catch (Exception ex) { return(_objmodel); } }
//Work Times calculation controller private void ProcessDailyAttendance(DailyAttendance _attData, string Remarks) { try { DailyAttendance attendanceRecord = _attData; Employee employee = attendanceRecord.Employee; List <ShiftChangedEmp> _shiftEmpCh = new List <ShiftChangedEmp>(); Expression <Func <ShiftChangedEmp, bool> > SpecificEntries = aa => aa.EmpID == _attData.EmpID; _shiftEmpCh = ShiftChangedEmpRepo.FindBy(SpecificEntries); List <Shift> shifts = new List <Shift>(); Expression <Func <Shift, bool> > SpecificEntries2 = aa => aa.PShiftID == _attData.Employee.ShiftID; shifts = ShiftRepo.FindBy(SpecificEntries2); List <ShiftChanged> cshifts = new List <ShiftChanged>(); Expression <Func <ShiftChanged, bool> > SpecificEntries3 = aa => aa.ShiftID == _attData.Employee.ShiftID; cshifts = ShiftChangedRepo.FindBy(SpecificEntries3); //Employee employee = _attData.Employee; if (_attData.StatusLeave == true) { _attData.ShifMin = 0; } //If TimeIn and TimeOut are not null, then calculate other Atributes if (_attData.TimeIn != null && _attData.TimeOut != null) { Shift _shift = ATAssistant.GetEmployeeChangedShift(_attData.Employee, _shiftEmpCh.Where(aa => aa.EmpID == _attData.EmpID).ToList(), _attData.AttDate.Value, shifts); MyShift shift = ATAssistant.GetEmployeeShift(_shift); if (_attData.StatusHL == true) { _attData.ShifMin = ATAssistant.CalculateShiftMinutes(shift, _attData.AttDate.Value.DayOfWeek); _attData.ShifMin = (short)(_attData.ShifMin / 2); } //If TimeIn = TimeOut then calculate according to DutyCode if (_attData.TimeIn == _attData.TimeOut) { CalculateInEqualToOut(_attData); } else { if (_attData.DutyTime == new TimeSpan(0, 0, 0)) { ATWorkMinCalculator.CalculateOpenShiftTimes(_attData, shift, _attData.Employee.OTPolicy); } ATWorkMinCalculator.CalculateShiftTimes(_attData, shift, _attData.Employee.OTPolicy); } } else { CalculateInEqualToOut(_attData); } } catch (Exception ex) { } if (Remarks != "") { _attData.Remarks = _attData.Remarks + "[" + Remarks + "]"; } DailyAttendanceRepo.Edit(_attData); DailyAttendanceRepo.Save(); }
public VMOvertimeApprovalChild GetConveretedOTList(VMOvertimeApprovalChild vmOvertimeApprovalChild, VHR_EmployeeProfile employee, MonthData monthData, PayrollPeriod payrollPeriod) { vmOvertimeApprovalChild.EmpID = employee.PEmployeeID; vmOvertimeApprovalChild.EmpNo = employee.OEmpID; vmOvertimeApprovalChild.EmployeeName = employee.EmployeeName; vmOvertimeApprovalChild.OvertimePolicyID = employee.OTPolicyID; vmOvertimeApprovalChild.OvertimePolicyName = employee.OTPolicyName; vmOvertimeApprovalChild.EncashableSingleOT = ATAssistant.GetTimeHours(monthData.EncashbaleSingleOT); vmOvertimeApprovalChild.EncashableDoubleOT = ATAssistant.GetTimeHours(monthData.EncashbaleDoubleOT); vmOvertimeApprovalChild.CPLConvertedOT = ATAssistant.GetTimeHours(monthData.CPLConversionOT); vmOvertimeApprovalChild.NormalOT = ATAssistant.GetTimeHours(monthData.TNOT); vmOvertimeApprovalChild.RestOT = ATAssistant.GetTimeHours(monthData.TROT); vmOvertimeApprovalChild.GZOT = ATAssistant.GetTimeHours(monthData.TGZOT); vmOvertimeApprovalChild.CPLConvertedOTDays = monthData.CPLConvertedDays; vmOvertimeApprovalChild.PayrollPeriodID = payrollPeriod.PPayrollPeriodID; vmOvertimeApprovalChild.PayrollPeriodName = payrollPeriod.PRName; vmOvertimeApprovalChild.StatusID = monthData.MonthDataStageID; return(vmOvertimeApprovalChild); }
public static void CalculateShiftTimes(DailyAttendance attendanceRecord, MyShift shift, OTPolicy otPolicy) { try { attendanceRecord.TimeIn = attendanceRecord.TimeIn.Value.Trim(TimeSpan.TicksPerMinute); attendanceRecord.TimeOut = attendanceRecord.TimeOut.Value.Trim(TimeSpan.TicksPerMinute); // Break start and End Times DateTime ts = attendanceRecord.TimeIn.Value.Date + new TimeSpan(13, 0, 0); DateTime te = attendanceRecord.TimeIn.Value.Date + new TimeSpan(14, 0, 0); //Calculate Difference between Times #region --- For Time Difference Calculations-- TimeSpan mins = new TimeSpan(); if (shift.CalDiffOnly == true) { TimeSpan?min4 = new TimeSpan(); TimeSpan?min5 = new TimeSpan(); TimeSpan min1 = new TimeSpan(); TimeSpan min2 = new TimeSpan(); TimeSpan min3 = new TimeSpan(); if (attendanceRecord.Tout0 != null && attendanceRecord.Tin0 != null) { attendanceRecord.Tin0 = attendanceRecord.Tin0.Value.Trim(TimeSpan.TicksPerMinute); attendanceRecord.Tout0 = attendanceRecord.Tout0.Value.Trim(TimeSpan.TicksPerMinute); min1 = (TimeSpan)(attendanceRecord.Tout0 - attendanceRecord.Tin0); } if (attendanceRecord.Tout1 != null && attendanceRecord.Tin1 != null) { attendanceRecord.Tin1 = attendanceRecord.Tin1.Value.Trim(TimeSpan.TicksPerMinute); attendanceRecord.Tout1 = attendanceRecord.Tout1.Value.Trim(TimeSpan.TicksPerMinute); min2 = (TimeSpan)(attendanceRecord.Tout1 - attendanceRecord.Tin1); } if (attendanceRecord.Tout2 != null && attendanceRecord.Tin2 != null) { min3 = (TimeSpan)(attendanceRecord.Tout2 - attendanceRecord.Tin2); } mins = min1 + min2 + min3; if (min4 != null) { mins = mins + (TimeSpan)min4; } if (min5 != null) { mins = mins + (TimeSpan)min5; } } else { mins = (TimeSpan)(attendanceRecord.TimeOut - attendanceRecord.TimeIn); } #endregion double _workHours = mins.TotalHours; attendanceRecord.WorkMin = (short)(mins.TotalMinutes); if (attendanceRecord.WorkMin > 0) { if (attendanceRecord.Remarks != null) { attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[Absent]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[Manual]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LI]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[M]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[N-OT]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LO]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LO]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EI]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EO]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[R-OT]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[G-OT]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[HA]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[DO]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[GZ]", ""); } else { attendanceRecord.Remarks = ""; } if (attendanceRecord.StatusMN == true) { attendanceRecord.Remarks = "[M]" + attendanceRecord.Remarks; } //Check if GZ holiday then place all WorkMin in GZOTMin if (attendanceRecord.StatusGZ == true && attendanceRecord.DutyCode == "G") { #region -- GZ Calculation-- if (otPolicy.CalculateGZOT == true) { if (otPolicy.PerDayGOTLimitHour >= _workHours) { int hour = (int)(mins.TotalMinutes / 60); int min = hour * 60; int remainingmin = (int)mins.TotalMinutes - min; if (remainingmin >= otPolicy.MinMinutesForOneHour) { attendanceRecord.GZOTMin = (short)((hour + 1) * 60); } else { attendanceRecord.GZOTMin = (short)((hour) * 60); } } else { int policyOTLimitMin = (int)(otPolicy.PerDayGOTLimitHour * 60.0); attendanceRecord.GZOTMin = (short)policyOTLimitMin; } } else { attendanceRecord.WorkMin = 0; attendanceRecord.ExtraMin = (short)mins.TotalMinutes; } if (attendanceRecord.GZOTMin > 0) { attendanceRecord.StatusGZOT = true; attendanceRecord.Remarks = attendanceRecord.Remarks + "[G-OT]"; } #endregion } //if Rest day then place all WorkMin in OTMin else if (attendanceRecord.StatusDO == true && attendanceRecord.DutyCode == "R") { #region -- Rest Calculation -- if (otPolicy.CalculateRestOT == true) { if (otPolicy.PerDayROTLimitHour >= _workHours) { if (mins.TotalMinutes < otPolicy.MinMinutesForOneHour) { attendanceRecord.OTMin = 0; } else if (attendanceRecord.OTMin >= otPolicy.MinMinutesForOneHour && attendanceRecord.OTMin <= 61) { attendanceRecord.OTMin = 60; } else { int hour = (int)(mins.TotalMinutes / 60); int min = hour * 60; int remainingmin = (int)mins.TotalMinutes - min; if (remainingmin >= otPolicy.MinMinutesForOneHour) { attendanceRecord.OTMin = (short)((hour + 1) * 60); } else { attendanceRecord.OTMin = (short)((hour) * 60); } } } else if (otPolicy.PerDayROTLimitHour == 0) { int hour = (int)(mins.TotalMinutes / 60); int min = hour * 60; int remainingmin = (int)mins.TotalMinutes - min; if (remainingmin >= otPolicy.MinMinutesForOneHour) { attendanceRecord.OTMin = (short)((hour + 1) * 60); } else { attendanceRecord.OTMin = (short)((hour) * 60); } } else { int policyOTLimitMin = (int)(otPolicy.PerDayROTLimitHour * 60.0); attendanceRecord.OTMin = (short)policyOTLimitMin; } } else { attendanceRecord.WorkMin = 0; attendanceRecord.ExtraMin = (short)mins.TotalMinutes; } if (attendanceRecord.OTMin > 0) { attendanceRecord.StatusOT = true; attendanceRecord.Remarks = attendanceRecord.Remarks + "[R-OT]"; } #endregion } else { attendanceRecord.StatusAB = false; attendanceRecord.StatusP = true; attendanceRecord.ExtraMin = 0; #region -- Margins-- //Calculate Late IN, Compare margin with Shift Late In if (attendanceRecord.TimeIn.Value.TimeOfDay > attendanceRecord.DutyTime) { TimeSpan lateMinsSpan = (TimeSpan)(attendanceRecord.TimeIn.Value.TimeOfDay - attendanceRecord.DutyTime); if (lateMinsSpan.Minutes > shift.LateIn) { attendanceRecord.LateIn = (short)lateMinsSpan.TotalMinutes; attendanceRecord.StatusLI = true; attendanceRecord.EarlyIn = 0; attendanceRecord.Remarks = attendanceRecord.Remarks + "[LI]"; } else { attendanceRecord.StatusLI = null; attendanceRecord.LateIn = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LI]", ""); } } else { attendanceRecord.StatusLI = null; attendanceRecord.LateIn = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LI]", ""); } //Calculate Early In, Compare margin with Shift Early In if (attendanceRecord.TimeIn.Value.TimeOfDay < attendanceRecord.DutyTime) { TimeSpan EarlyInMinsSpan = (TimeSpan)(attendanceRecord.DutyTime - attendanceRecord.TimeIn.Value.TimeOfDay); if (EarlyInMinsSpan.TotalMinutes > shift.EarlyIn) { attendanceRecord.EarlyIn = (short)EarlyInMinsSpan.TotalMinutes; attendanceRecord.StatusEI = true; attendanceRecord.LateIn = 0; attendanceRecord.Remarks = attendanceRecord.Remarks + "[EI]"; } else { attendanceRecord.StatusEI = null; attendanceRecord.EarlyIn = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EI]", ""); } } else { attendanceRecord.StatusEI = null; attendanceRecord.EarlyIn = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EI]", ""); } // CalculateShiftEndTime = ShiftStart + DutyHours DateTime shiftEnd = ATAssistant.CalculateShiftEndTimeWithAttData(attendanceRecord.AttDate.Value, attendanceRecord.DutyTime.Value, (short)(attendanceRecord.ShifMin + attendanceRecord.BreakMin)); //Calculate Early Out, Compare margin with Shift Early Out if (attendanceRecord.TimeOut < shiftEnd) { TimeSpan EarlyOutMinsSpan = (TimeSpan)(shiftEnd - attendanceRecord.TimeOut); if (EarlyOutMinsSpan.TotalMinutes > shift.EarlyOut) { attendanceRecord.EarlyOut = (short)EarlyOutMinsSpan.TotalMinutes; attendanceRecord.StatusEO = true; attendanceRecord.LateOut = 0; attendanceRecord.Remarks = attendanceRecord.Remarks + "[EO]"; } else { attendanceRecord.StatusEO = null; attendanceRecord.EarlyOut = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EO]", ""); } } else { attendanceRecord.StatusEO = null; attendanceRecord.EarlyOut = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EO]", ""); } //Calculate Late Out, Compare margin with Shift Late Out if (attendanceRecord.TimeOut > shiftEnd) { TimeSpan LateOutMinsSpan = (TimeSpan)(attendanceRecord.TimeOut - shiftEnd); if (LateOutMinsSpan.TotalMinutes > shift.LateOut) { attendanceRecord.LateOut = (short)LateOutMinsSpan.TotalMinutes; // Late Out cannot have an early out, In case of poll at multiple times before and after shiftend attendanceRecord.EarlyOut = 0; attendanceRecord.StatusLO = true; attendanceRecord.Remarks = attendanceRecord.Remarks + "[LO]"; } else { attendanceRecord.StatusLO = null; attendanceRecord.LateOut = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LO]", ""); } } else { attendanceRecord.StatusLO = null; attendanceRecord.LateOut = 0; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LO]", ""); } #endregion if (otPolicy.CalculateNOT == true && attendanceRecord.LateOut > 0) { attendanceRecord.OTMin = (short)attendanceRecord.LateOut; } else if (otPolicy.CalculateNOT == false) { if (attendanceRecord.LateOut > 0) { attendanceRecord.ExtraMin = (short)(attendanceRecord.LateOut + attendanceRecord.ExtraMin); } if (attendanceRecord.EarlyIn > 0) { attendanceRecord.ExtraMin = (short)(attendanceRecord.EarlyIn + attendanceRecord.ExtraMin); } } #region -- Shift Things //Subtract EarlyIn and LateOut from Work Minutes if (shift.SubtractEIFromWork == true) { if (attendanceRecord.EarlyIn != null && attendanceRecord.EarlyIn > shift.EarlyIn) { attendanceRecord.WorkMin = (short)(attendanceRecord.WorkMin - attendanceRecord.EarlyIn); } } if (shift.SubtractOTFromWork == true) { if (attendanceRecord.LateOut != null && attendanceRecord.LateOut > shift.LateOut) { attendanceRecord.WorkMin = (short)(attendanceRecord.WorkMin - attendanceRecord.LateOut); } } if (shift.AddEIInOT == true && otPolicy.CalculateNOT == true) { if (attendanceRecord.EarlyIn != null) { if (attendanceRecord.OTMin != null) { attendanceRecord.OTMin = (short)(attendanceRecord.OTMin + attendanceRecord.EarlyIn); } else { if (attendanceRecord.EarlyIn != null && attendanceRecord.EarlyIn > shift.OverTimeMin) { attendanceRecord.OTMin = (short)attendanceRecord.EarlyIn; } } } } // Deduct break if (attendanceRecord.DutyCode == "D") { //Normal if (attendanceRecord.TimeIn != null && attendanceRecord.TimeOut != null) { if (attendanceRecord.TimeIn < ts && attendanceRecord.TimeOut > te) { attendanceRecord.WorkMin = (short)(attendanceRecord.WorkMin - attendanceRecord.BreakMin); } else { if (attendanceRecord.TotalShortMin > 0) { attendanceRecord.TotalShortMin = (short)(attendanceRecord.TotalShortMin + attendanceRecord.BreakMin); } } } } //RoundOff Work Minutes //if (shift.RoundOffWorkMin == true) //{ // if (attendanceRecord.LateOut != null || attendanceRecord.EarlyIn != null) // { // if (attendanceRecord.WorkMin > (attendanceRecord.ShifMin - shift.LateIn) && (attendanceRecord.WorkMin <= ((attendanceRecord.ShifMin + attendanceRecord.BreakMin) + 2))) // { // attendanceRecord.WorkMin = (short)(attendanceRecord.ShifMin); // } // } //} #endregion #region -- OT Calculation -- if ((attendanceRecord.StatusGZ != true || attendanceRecord.StatusDO != true)) { if (attendanceRecord.OTMin != null) { if (otPolicy.CalculateNOT == true) { float otHour = (float)(attendanceRecord.OTMin / 60.0); if (otPolicy.PerDayOTLimitHour >= otHour) { if (otPolicy.MinMinutesForOneHour == 0) { attendanceRecord.OTMin = (short)attendanceRecord.OTMin; } else { if (attendanceRecord.OTMin < otPolicy.MinMinutesForOneHour) { attendanceRecord.OTMin = 0; } else if (attendanceRecord.OTMin >= otPolicy.MinMinutesForOneHour && attendanceRecord.OTMin <= 61) { attendanceRecord.OTMin = 60; } else { if (attendanceRecord.OTMin != null) { int hour = (int)(attendanceRecord.OTMin / 60); int min = hour * 60; int remainingmin = (int)attendanceRecord.OTMin - min; if (remainingmin >= otPolicy.MinMinutesForOneHour) { attendanceRecord.OTMin = (short)((hour + 1) * 60); } else { attendanceRecord.OTMin = (short)min; } } } } } else { int policyOTLimitMin = (int)(otPolicy.PerDayOTLimitHour * 60.0); attendanceRecord.OTMin = (short)policyOTLimitMin; } } else { attendanceRecord.WorkMin = (short)mins.TotalMinutes; } if (attendanceRecord.OTMin > 0) { attendanceRecord.StatusOT = true; attendanceRecord.Remarks = attendanceRecord.Remarks + "[N-OT]"; } } } #endregion #region --- Half Absent and Short Time --- if (attendanceRecord.StatusHL == true) { attendanceRecord.TotalShortMin = 0; attendanceRecord.EarlyOut = 0; attendanceRecord.LateIn = 0; attendanceRecord.LateOut = 0; attendanceRecord.OTMin = 0; attendanceRecord.ExtraMin = 0; attendanceRecord.TotalShortMin = 0; attendanceRecord.StatusLI = false; attendanceRecord.StatusEO = false; attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LI]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[EO]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[N-OT]", ""); attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[LO]", ""); attendanceRecord.PDays = 0.5; attendanceRecord.AbDays = 0; attendanceRecord.LeaveDays = 0.5; // update if lateout } else { attendanceRecord.PDays = 1; attendanceRecord.AbDays = 0; attendanceRecord.LeaveDays = 0; short totalshortMin = 0; if (attendanceRecord.LateIn > 0) { totalshortMin = (short)attendanceRecord.LateIn; } if (attendanceRecord.EarlyOut > 0) { totalshortMin = (short)(totalshortMin + attendanceRecord.EarlyOut); } attendanceRecord.TotalShortMin = totalshortMin; int marginForST = 10; if (shift.LateIn > 0) { marginForST = shift.LateIn; } if (attendanceRecord.WorkMin < (attendanceRecord.ShifMin - marginForST)) { attendanceRecord.TotalShortMin = (Int16)(attendanceRecord.TotalShortMin + (attendanceRecord.ShifMin - (attendanceRecord.WorkMin + totalshortMin))); } if (otPolicy.CalculateNOT == true) { if (attendanceRecord.OTMin > 0) { if (attendanceRecord.TotalShortMin > 0) { attendanceRecord.ActualOT = (short)(attendanceRecord.OTMin - attendanceRecord.TotalShortMin); } } } } #endregion #region -- Mark Absent -- //Mark Absent if less than 4 hours if (attendanceRecord.AttDate.Value.DayOfWeek != DayOfWeek.Friday && attendanceRecord.StatusDO != true && attendanceRecord.StatusGZ != true) { if (attendanceRecord.StatusHL != true) { short MinShiftMin = (short)shift.MinHrs; if (attendanceRecord.WorkMin < MinShiftMin) { attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[Absent]", ""); attendanceRecord.StatusAB = true; attendanceRecord.StatusP = false; attendanceRecord.PDays = 0; attendanceRecord.AbDays = 1; attendanceRecord.LeaveDays = 0; attendanceRecord.Remarks = attendanceRecord.Remarks + "[Absent]"; } else { attendanceRecord.StatusAB = false; attendanceRecord.StatusP = true; if (attendanceRecord.StatusHL == true) { attendanceRecord.PDays = 0.5; attendanceRecord.AbDays = 0; attendanceRecord.LeaveDays = 0.5; } else { attendanceRecord.PDays = 1; attendanceRecord.AbDays = 0; attendanceRecord.LeaveDays = 0; } attendanceRecord.Remarks = attendanceRecord.Remarks.Replace("[Absent]", ""); } } } #endregion //RoundOff Work Minutes if (shift.RoundOffWorkMin == true) { if (attendanceRecord.WorkMin >= (attendanceRecord.ShifMin - shift.LateIn) && (attendanceRecord.WorkMin <= ((attendanceRecord.ShifMin) + shift.LateIn))) { attendanceRecord.WorkMin = (short)(attendanceRecord.ShifMin); } if (attendanceRecord.WorkMin > 0 && attendanceRecord.StatusHL != true) { //if (attendanceRecord.ShifMin <= attendanceRecord.WorkMin + attendanceRecord.TotalShortMin) //{ // attendanceRecord.WorkMin = attendanceRecord.ShifMin; //} } if (attendanceRecord.WorkMin > 0 && attendanceRecord.StatusHL == true) { //attendanceRecord.WorkMin = (short)(attendanceRecord.ShifMin); } } } #region -- Break for GZ, Rest and Normal Day //GZ Break if (attendanceRecord.DutyCode == "G") { if (attendanceRecord.TimeIn != null && attendanceRecord.TimeOut != null) { if (attendanceRecord.TimeIn < ts && attendanceRecord.TimeOut > te) { if (attendanceRecord.GZOTMin > 0) { attendanceRecord.GZOTMin = (short)(attendanceRecord.GZOTMin - attendanceRecord.BreakMin); } if (attendanceRecord.ExtraMin > 0) { attendanceRecord.ExtraMin = (short)(attendanceRecord.ExtraMin - attendanceRecord.BreakMin); } } } } //Rest else if (attendanceRecord.DutyCode == "R") { if (attendanceRecord.TimeIn != null && attendanceRecord.TimeOut != null) { if (attendanceRecord.TimeIn < ts && attendanceRecord.TimeOut > te) { if (attendanceRecord.OTMin > 0) { attendanceRecord.OTMin = (short)(attendanceRecord.OTMin - attendanceRecord.BreakMin); } if (attendanceRecord.ExtraMin > 0) { attendanceRecord.ExtraMin = (short)(attendanceRecord.ExtraMin - attendanceRecord.BreakMin); } } } } #endregion } } catch (Exception ex) { } }
public VMEditMonthlyAttendance GetMonthlyAttendanceAttributes(List <VAT_MonthlySummary> MonthlyAttendance, int PayrollID) { VMEditMonthlyAttendance entries = new VMEditMonthlyAttendance(); List <EditMonthlyAttendanceList> list = new List <EditMonthlyAttendanceList>(); int count = 1; foreach (var item in MonthlyAttendance) { EditMonthlyAttendanceList eal = new EditMonthlyAttendanceList(); eal.EmployeeID = (int)item.EmployeeID; eal.No = count; count++; eal.EmpNo = item.OEmpID; eal.EmpName = item.EmployeeName; eal.JobTitleName = item.JobTitleName; eal.TotalDays = 0; eal.PaidDays = 0; eal.AbsentDays = 0; eal.RestDays = (float)item.RestDays; eal.LeaveDays = (float)item.LeaveDays; if (item.AbsentDays != null) { eal.AbsentDays = (float)item.AbsentDays; } if (item.WorkDays != null) { eal.PaidDays = (float)item.WorkDays; } if (item.TotalDays != null) { eal.TotalDays = (float)item.TotalDays; } if (item.WOPLeavesDays != null) { eal.LWOPDays = (float)item.WOPLeavesDays; } //if (item.TNOT != null) //{ // eal.NOT = ATAssistant.GetTimeHours(item.TNOT); //} if (item.EncashbaleSingleOT != null) { eal.SingleEncashableOT = ATAssistant.GetTimeHours(item.EncashbaleSingleOT); } //if (item.TROT != null) //{ // eal.ROT = ATAssistant.GetTimeHours(item.TROT); //} if (item.EncashbaleDoubleOT != null) { eal.DoubleEncashableOT = ATAssistant.GetTimeHours(item.EncashbaleDoubleOT); } //if (item.TGZOT != null) //{ // eal.GOT = ATAssistant.GetTimeHours(item.TGZOT); //} if (item.CPLConversionOT != null) { eal.CPLOT = ATAssistant.GetTimeHours(item.CPLConversionOT); } //if (item.TotalOT != null) //{ // eal.TotalOT = ATAssistant.GetTimeHours(item.TotalOT); //} if (item.Remarks == null) { eal.Remarks = ""; } else { eal.Remarks = item.Remarks; } list.Add(eal); } //list.Add(GetTotalCount(list)); // entries.Locations = locs; entries.MonthlyList = list.OrderBy(aa => aa.EmployeeID).ToList(); entries.Count = list.Count; entries.PayrolPeriodID = PayrollID; //entries.PayrollName = PRName; return(entries); }