Beispiel #1
0
        public override decimal Calculate(UserResultVM user, UserResult initialUserResult, DateTime startDate, DateTime endDate)
        {
            var baseRate = 0M;

            foreach (var userPosition in user.Positions)
            {
                var dateFrom = userPosition.StartDate > startDate ? userPosition.StartDate : startDate;
                var dateTo   = userPosition.EndDate.HasValue && userPosition.EndDate < endDate ? userPosition.EndDate.Value : endDate;

                var position   = initialUserResult.Positions.Where(p => p.Id == userPosition.PositionId).First();
                var calculator = CalculatorFactory.GetBaseRateCalculator(user, initialUserResult, position.RateTypeId);
                baseRate += calculator.Calculate(position.Rate, dateFrom, dateTo);
            }

            return(baseRate + Proceed(user, initialUserResult, startDate, endDate));
        }
        public override decimal Calculate(UserResultVM user, UserResult initialUserResult, DateTime startDate, DateTime endDate)
        {
            var baseRate = 0M;

            var userRuleIds = initialUserResult.UserRules.Where(ur => ur.UserId == user.Id).Select(ur => ur.RuleId);
            var rules       = initialUserResult.Rules.Where(r => userRuleIds.Contains(r.Id));

            foreach (var rule in rules)
            {
                var dateFrom = rule.StartDate > startDate ? rule.StartDate : startDate;
                var dateTo   = rule.EndDate.HasValue && rule.EndDate < endDate ? rule.EndDate.Value : endDate;

                var calculator = CalculatorFactory.GetRuleCalculator(user, initialUserResult, rule.RuleTypeId);
                baseRate += calculator.Calculate(rule.Bonus, dateFrom, dateTo);
            }

            return(baseRate + Proceed(user, initialUserResult, startDate, endDate));
        }
Beispiel #3
0
        public override decimal Calculate(UserResultVM user, UserResult initialUserResult, DateTime startDate, DateTime endDate)
        {
            var bonus = 0M;

            foreach (var userPosition in user.Positions)
            {
                var positionDateFrom = userPosition.StartDate > startDate ? userPosition.StartDate : startDate;
                var positionDateTo   = userPosition.EndDate.HasValue && userPosition.EndDate < endDate ? userPosition.EndDate.Value : endDate;

                foreach (var rule in GetRules(initialUserResult, userPosition.PositionId))
                {
                    var ruleDateFrom = rule.StartDate > positionDateFrom ? rule.StartDate : positionDateFrom;
                    var ruleDateTo   = rule.EndDate.HasValue && rule.EndDate < positionDateTo ? rule.EndDate.Value : positionDateTo;

                    var calculator = CalculatorFactory.GetRuleCalculator(user, initialUserResult, rule.RuleTypeId);
                    bonus += calculator.Calculate(rule.Bonus, ruleDateFrom, ruleDateTo);
                }
            }

            return(bonus + Proceed(user, initialUserResult, startDate, endDate));
        }
Beispiel #4
0
        public override decimal Calculate(UserResultVM user, UserResult initialUserResult, DateTime startDate, DateTime endDate)
        {
            var overtimeBonus = 0M;

            var holidays = initialUserResult.DaysOff.Select(doff => doff.Date);

            foreach (var userPosition in user.Positions)
            {
                var positionDateFrom = userPosition.StartDate > startDate ? userPosition.StartDate : startDate;
                var positionDateTo   = userPosition.EndDate.HasValue && userPosition.EndDate < endDate ? userPosition.EndDate.Value : endDate;

                var rateInfo      = initialUserResult.Positions.Where(p => p.Id == userPosition.PositionId).Select(p => new { p.RateTypeId, p.Rate }).First();
                var overtimeRatio = initialUserResult.OvertimeRatios.Where(or => or.RateTypeId == rateInfo.RateTypeId).Select(or => or.Ratio).First();

                var relevantTimeSheets = user.TimeSheets.Where(ts => ts.Date >= positionDateFrom && ts.Date <= positionDateTo);

                var calculator = CalculatorFactory.GetOvertimeCalculator(user, initialUserResult, rateInfo.RateTypeId);
                overtimeBonus += calculator.Calculate(rateInfo.Rate, overtimeRatio, userPosition.Hours, positionDateFrom, positionDateTo);
            }

            return(overtimeBonus + Proceed(user, initialUserResult, startDate, endDate));
        }