Exemplo n.º 1
0
        public void BonusAllocationCalculation_CalculateBonusAllocation_ReturnBonusAllocation()
        {
            var allocation = new Allocation();
            var employee   = new HrEmployee();
            var payroll    = new Payroll();
            var bonusPool  = new BonusPool();

            employee.Salary            = 50000;
            payroll.TotalCostToCompany = 1000000;
            bonusPool.BonusPoolAmount  = 1000;

            var result = allocation.BonusAllocationCalculation(employee, payroll, bonusPool);

            Assert.AreEqual(result, 50);
        }
        public ActionResult Calculate(BonusPoolCalculatorModel model)
        {
            int        selectedEmployeeId = model.SelectedEmployeeId;
            int        totalBonusPool     = model.BonusPoolAmount;
            HrEmployee hrEmployee         = (HrEmployee)db.HrEmployees.FirstOrDefault(item => item.ID == selectedEmployeeId);

            Payroll payroll = new Payroll();

            payroll.AllEmployees       = getEmployees();
            payroll.TotalCostToCompany = payroll.PayrollCostTocompany(payroll.AllEmployees);

            BonusPool bonusPool = new BonusPool();

            bonusPool.BonusPoolAmount = totalBonusPool;

            BonusPoolCalculatorResultModel result = new BonusPoolCalculatorResultModel();
            Allocation allocation = new Allocation();

            result.hrEmployee          = hrEmployee;
            result.bonusPoolAllocation = allocation.BonusAllocationCalculation(hrEmployee, payroll, bonusPool);
            return(View(result));
        }