コード例 #1
0
ファイル: AutoDeduction.cs プロジェクト: jansenzjh/Florence
        public static decimal LateAttendanceDeductedAmount(int employee, DateTime date, decimal dailySalary = 0, List <AutoDeduction> autoDeds = null, int lateMinutes = 0)
        {
            if (dailySalary == 0)
            {
                dailySalary = Salary.GetDailySalary(employee);
            }
            if (autoDeds == null)
            {
                autoDeds = AutoDeduction.GetAll();
            }
            if (lateMinutes == 0)
            {
                lateMinutes = Attendance.GetLateMinutes(employee, date);
            }

            decimal totalAmount = 0;

            foreach (var ad in autoDeds.OrderBy(x => x.LateMinutesTo).ToList())
            {
                if (lateMinutes >= ad.LateMinutesFrom && lateMinutes < ad.LateMinutesTo)
                {
                    totalAmount = GetDeductionAmountByType(ad.LateAmountType, dailySalary, ad.Amount);
                }
            }
            return(totalAmount);
        }
コード例 #2
0
ファイル: AutoDeduction.cs プロジェクト: jansenzjh/Florence
        public static SalaryItem GetDeductionAmountDaily(int employee,
                                                         DateTime date,
                                                         decimal dailySalary           = 0,
                                                         List <AutoDeduction> autoDeds = null,
                                                         int lateMinutes = 0)
        {
            //Init data if need
            if (dailySalary == 0)
            {
                dailySalary = Salary.GetDailySalary(employee);
            }
            if (autoDeds == null)
            {
                autoDeds = AutoDeduction.GetAll();
            }
            if (lateMinutes == 0)
            {
                lateMinutes = Attendance.GetLateMinutes(employee, date);
            }

            var     ded         = autoDeds.FirstOrDefault();
            decimal totalAmount = 0;

            //Get the amount based on the lated minutes
            if (ded.ForAbsence && lateMinutes > Convert.ToInt32(RegularWorkingHours.FullDay) * 60)
            {
                totalAmount = GetDeductionAmountByType(ded.AbsenceAmountType, dailySalary, ded.AbsenceAmount);
            }
            else if (ded.ForHalfDayLeave && lateMinutes > Convert.ToInt32(RegularWorkingHours.HalfDay) * 60)
            {
                totalAmount = GetDeductionAmountByType(ded.HalfDayLeaveAmountType, dailySalary, ded.HalfDayLeaveAmount);
            }
            else if (ded.ForLateAttendance)
            {
                totalAmount = LateAttendanceDeductedAmount(employee, date, dailySalary, autoDeds, lateMinutes);
            }

            //Return model with all data it needs
            var deduct = new SalaryItem()
            {
                Amount                 = totalAmount,
                CreatedAt              = DateTime.Now,
                CreatedBy              = 1,
                Employee               = employee,
                IsRecurring            = false,
                RecurringCyclePerMonth = 0,
                SalaryItemType         = "Deductions",
                Title       = string.Format("Auto Deductions for Employee {0} on {1}", Employee.GetName(employee), DateTime.Today.ToShortDateString()),
                Description = string.Format("{0}: Late {1} Minutes, deducted {2}", date.ToShortDateString(), lateMinutes, totalAmount)
            };

            return(deduct);
        }
コード例 #3
0
ファイル: AutoOvertime.cs プロジェクト: jansenzjh/Florence
        public static Overtime GetOvertimeAmountDaily(
            int employee,
            DateTime date,
            decimal dailySalary         = 0,
            List <AutoOvertime> autoOts = null,
            int otMinutes = 0)
        {
            decimal totalAmount = 0;
            var     punchout    = new DateTime();

            //Init data if need
            if (dailySalary == 0)
            {
                dailySalary = Salary.GetDailySalary(employee);
            }
            if (autoOts == null)
            {
                autoOts = AutoOvertime.GetAll();
            }
            if (otMinutes == 0)
            {
                otMinutes = Attendance.GetOvertimeMinutes(employee, date, ref punchout);
            }

            foreach (AutoOvertime ot in autoOts.OrderBy(x => x.MinutesTo).ToList())
            {
                if (ot.MinutesFrom >= otMinutes && ot.MinutesTo < otMinutes)
                {
                    totalAmount = GetOvertimeAmountByType(ot.OvertimeAmountType, dailySalary, ot.Amount);
                }
            }

            var ovtm = new Overtime()
            {
                Amount                 = totalAmount,
                CreatedAt              = DateTime.Now,
                CreatedBy              = 1,
                Employee               = employee,
                IsRecurring            = false,
                OvertimeHours          = otMinutes % 60 + 1,
                TimeIn                 = punchout,
                TimeOut                = punchout.AddMinutes(otMinutes * -1),
                RecurringCyclePerMonth = 0,
                Title       = string.Format("Auto Overtime for Employee {0} on {1}", Employee.GetName(employee), DateTime.Today.ToShortDateString()),
                Description = string.Format("{0}: OT {1} Minutes, Added {2}", date.ToShortDateString(), otMinutes, totalAmount)
            };

            return(ovtm);
        }
コード例 #4
0
ファイル: AutoOvertime.cs プロジェクト: jansenzjh/Florence
        public static decimal GetOvertimeAmount(int employee, DateTime fromDate, DateTime toDate)
        {
            var     dailySalary = Salary.GetDailySalary(employee);
            var     autoOts     = AutoOvertime.GetAll();
            var     ded         = autoOts.FirstOrDefault();
            decimal totalAmount = 0;

            //Loop between date range to add deduction day by day
            var tempDate = fromDate;

            while (tempDate < toDate)
            {
                totalAmount += GetOvertimeAmountDaily(employee, tempDate, dailySalary, autoOts).Amount;
                tempDate.AddDays(1);
            }
            return(totalAmount);
        }
コード例 #5
0
ファイル: AutoOvertime.cs プロジェクト: jansenzjh/Florence
        private List <Overtime> _ProcessAutoOvertime(int employee, DateTime fromDate, DateTime toDate)
        {
            var dailySalary      = Salary.GetDailySalary(employee);
            var autoOts          = AutoOvertime.GetAll();
            var ded              = autoOts.FirstOrDefault();
            var autoOvertimeList = new List <Overtime>();

            //Loop between date range to add deduction day by day
            var tempDate = fromDate;

            while (tempDate < toDate)
            {
                var otModel = GetOvertimeAmountDaily(employee, tempDate, dailySalary, autoOts);
                autoOvertimeList.Add(otModel);
                //Insert into Deduction Table
                otModel.Insert();
                //Next day
                tempDate.AddDays(1);
            }
            return(autoOvertimeList);
        }
コード例 #6
0
ファイル: AutoDeduction.cs プロジェクト: jansenzjh/Florence
        private List <SalaryItem> _ProcessAutoDeduction(int employee, DateTime fromDate, DateTime toDate)
        {
            //AutoDeduction.GetAutoDeductionAmount(employee, fromDate, toDate, true);
            var dailySalary    = Salary.GetDailySalary(employee);
            var autoDeds       = AutoDeduction.GetAll();
            var ded            = autoDeds.FirstOrDefault();
            var autoDeductList = new List <SalaryItem>();

            //Loop between date range to add deduction day by day
            var tempDate = fromDate;

            while (tempDate < toDate)
            {
                var deductModel = GetDeductionAmountDaily(employee, tempDate, dailySalary, autoDeds);
                autoDeductList.Add(deductModel);
                //Insert into Deduction Table
                deductModel.Insert();
                //Next day
                tempDate.AddDays(1);
            }
            return(autoDeductList);
        }