Ejemplo n.º 1
0
    protected void GenerateCompensationLeaveEntitlement(ArrayList empInfoList, DateTime PeriodFrom, DateTime PeriodTo)
    {
        foreach (EEmpPersonalInfo empInfo in empInfoList)
        {
            ArrayList compensationLeaveEntitleList = new ArrayList();

            DBFilter attendanceRecordFilter = new DBFilter();
            attendanceRecordFilter.add(new Match("EmpID", empInfo.EmpID));
            attendanceRecordFilter.add(new Match("AttendanceRecordDate", "<=", PeriodTo));
            attendanceRecordFilter.add(new Match("AttendanceRecordDate", ">=", PeriodFrom));
            //attendanceRecordFilter.add(new Match("AttendanceRecordActualOvertimeMins", ">", 0));
            attendanceRecordFilter.add("AttendanceRecordDate", true);

            ArrayList attendanceRecordList = EAttendanceRecord.db.select(dbConn, attendanceRecordFilter);

            EEmpPositionInfo currentEmpPosInfo     = null;
            EAttendancePlan  currentAttendancePlan = null;
            foreach (EAttendanceRecord attendanceRecord in attendanceRecordList)
            {
                if (currentEmpPosInfo != null)
                {
                    if (currentEmpPosInfo.EmpPosEffFr <= attendanceRecord.AttendanceRecordDate && (currentEmpPosInfo.EmpPosEffTo >= attendanceRecord.AttendanceRecordDate || currentEmpPosInfo.EmpPosEffTo.Ticks.Equals(0)))
                    {
                        currentEmpPosInfo     = null;
                        currentAttendancePlan = null;
                    }
                }
                if (currentEmpPosInfo == null)
                {
                    currentEmpPosInfo = AppUtils.GetLastPositionInfo(dbConn, attendanceRecord.AttendanceRecordDate, empInfo.EmpID);
                    EAttendancePlan attendancePlan = new EAttendancePlan();
                    attendancePlan.AttendancePlanID = currentEmpPosInfo.AttendancePlanID;
                    if (EAttendancePlan.db.select(dbConn, attendancePlan))
                    {
                        currentAttendancePlan = attendancePlan;
                    }
                }


                if (currentAttendancePlan != null)
                {
                    if (currentAttendancePlan.AttendancePlanOTGainAsCompensationLeaveEntitle && currentAttendancePlan.AttendancePlanOTMinsUnit > 0)
                    {
                        int actualMins = AppUtils.ApplyRoundingRule(attendanceRecord.AttendanceRecordActualOvertimeMins, currentAttendancePlan.AttendancePlanOTMinsRoundingRule, currentAttendancePlan.AttendancePlanOTMinsUnit);

                        ECompensationLeaveEntitle compLeaveEntitle = new ECompensationLeaveEntitle();
                        compLeaveEntitle.EmpID = empInfo.EmpID;
                        compLeaveEntitle.CompensationLeaveEntitleEffectiveDate   = attendanceRecord.AttendanceRecordDate;
                        compLeaveEntitle.CompensationLeaveEntitleClaimPeriodFrom = attendanceRecord.AttendanceRecordDate;
                        compLeaveEntitle.CompensationLeaveEntitleClaimPeriodTo   = attendanceRecord.AttendanceRecordDate;
                        compLeaveEntitle.CompensationLeaveEntitleHoursClaim      = actualMins / 60.0;
                        compLeaveEntitle.CompensationLeaveEntitleIsAutoGenerated = true;
                        compensationLeaveEntitleList.Add(compLeaveEntitle);
                    }
                }
            }
            SubmitCompensationLeaveEntitlementList(compensationLeaveEntitleList);
            //HROne.LeaveCalc.LeaveBalanceCalc leaaveBalCal = new HROne.LeaveCalc.LeaveBalanceCalc(dbConn, empInfo.EmpID);
            //leaaveBalCal.RecalculateAfter(PeriodFrom , ELeaveType.COMPENSATION_LEAVE_TYPE(dbConn).LeaveTypeID);
        }
    }