Exemplo n.º 1
0
        public SalaryCalculationResult Calculate(SalaryCalculationEntry salaryCalculationEntry)
        {
            _logger.Info("叫用薪資計算服務");
            _logger.Debug("傳入值:{@salaryCalculationEntry}", salaryCalculationEntry);

            SalaryCalculationResult result = new SalaryCalculationResult();

            foreach (string moduleType in salaryCalculationEntry.ModuleTypes)
            {
                _logger.Info("準備取得模組" + moduleType);
                var module = _salaryCalculateModuleFactory.Create(moduleType);
                if (module != null)
                {
                    var moduleResult = module.Calculate(salaryCalculationEntry);
                    result = moduleResult;//todo:未處理細節
                }
                else
                {
                    _logger.Warn("無法取得模組" + moduleType);
                }
            }
            _logger.Info("計算完成");
            _logger.Debug("回傳值", result);
            return(result);
        }
Exemplo n.º 2
0
        private SalaryCalculationResult CalculateSalary(DateTime date, Person person)
        {
            var result = new SalaryCalculationResult();

            if (person.Staff.Count > 0)
            {
                foreach (var collaborator in person.Staff)
                {
                    var staffSalary = CalculateSalary(date, collaborator);

                    result.StaffSalarySum          += staffSalary.Salary;
                    result.LowLevelsStaffSalarySum += staffSalary.StaffSalarySum + staffSalary.LowLevelsStaffSalarySum;
                }
            }

            if (person.DateOfEmployment <= date)
            {
                result.Salary = person.Rate
                                + BountyCalculationRules.GetBonusForWorkExpirience(person.Position, person.DateOfEmployment, person.Rate, date)
                                + BountyCalculationRules.GetBonusForStaffSalary(person.Position, result.StaffSalarySum, result.StaffSalarySum + result.LowLevelsStaffSalarySum);
            }

            return(result);
        }