public decimal ComputeTax(int payrollId, EmployeeInfo employeeInfo, decimal totalTaxableIncome, FrequencyType taxFrequency)
        {
            var taxDeduction   = _deductionService.GetByName(TAX_DEDUCTION_NAME);
            var noOfDependents =
                employeeInfo.Dependents > MAX_DEPENDENT ? MAX_DEPENDENT : employeeInfo.Dependents;

            var taxAmount = _taxService.ComputeTax(taxFrequency, noOfDependents, totalTaxableIncome);

            //Create deductions
            if (taxAmount > 0)
            {
                var employeePayrollDeduction = new EmployeePayrollDeduction
                {
                    EmployeeId        = employeeInfo.EmployeeId,
                    DeductionId       = taxDeduction.DeductionId,
                    Amount            = taxAmount,
                    DeductionDate     = new DateTime(),
                    EmployeePayrollId = payrollId
                };

                _employeePayrollDeductionRepository.Add(employeePayrollDeduction);
            }

            return(taxAmount);
        }
Пример #2
0
        public void ComputeTaxMonthlyLevel1()
        {
            Initialize();

            var frequency = FrequencyType.Monthly;

            //No Tax
            decimal taxAmount1 = 4000;
            var     tax1       = _taxService.ComputeTax(frequency, 0, taxAmount1);

            Assert.AreEqual(0, tax1);

            //No Tax
            decimal taxAmount2 = 4166;
            var     tax2       = _taxService.ComputeTax(frequency, 0, taxAmount2);

            Assert.AreEqual(0, tax2);

            //No Tax
            decimal taxAmount3 = 4167;
            var     tax3       = _taxService.ComputeTax(frequency, 0, taxAmount3);

            Assert.AreEqual(0, tax3);

            //With Tax
            decimal taxAmount4 = 4300;
            var     tax4       = _taxService.ComputeTax(frequency, 0, taxAmount4);

            Assert.AreEqual((decimal)6.6500, tax4);

            //With Tax
            decimal taxAmount5 = 4999.99M;
            var     tax5       = _taxService.ComputeTax(frequency, 0, taxAmount5);

            Assert.AreEqual((decimal)41.6495, tax5);
        }