Example #1
0
        protected decimal TestShim(int year, StudentLoanPlan plan, decimal gross, PayPeriods periods)
        {
            if (CalculationEngine == null)
            {
                CalculationEngine = new StudentLoans();
                CalculationEngine.SetTaxYearSpecificsProvider(new JsonTaxYearSpecificProvider());
            }
            CalculationEngine.SetTaxYear(year);

            return(CalculationEngine.CalculateStudentLoanDeduction(plan, gross, periods).StudentLoanDeduction);
        }
        public StudentLoanCalculation CalculateStudentLoanDeduction(StudentLoanPlan plan, decimal gross, PayPeriods periods)
        {
            decimal threshold = 0, rate = 0, periodAdjustedThreshold, thresholdAdjustedGross, deduction;
            int     periodCnt     = 52;
            int     weeksInPeriod = 1;

            if (periods == PayPeriods.Monthly)
            {
                periodCnt = 12;
            }
            else
            {
                weeksInPeriod = (int)Math.Round((decimal)periodCnt / (int)periods);
            }

            switch (plan)
            {
            case StudentLoanPlan.Plan1:
                threshold = taxYearConfigurationData.Plan1StudentLoanThreshold;
                rate      = taxYearConfigurationData.Plan1StudentLoanRate;
                break;

            case StudentLoanPlan.Plan2:
                threshold = taxYearConfigurationData.Plan2StudentLoanThreshold;
                rate      = taxYearConfigurationData.Plan2StudentLoanRate;
                break;

            case StudentLoanPlan.Plan4:
                threshold = taxYearConfigurationData.Plan4StudentLoanThreshold;
                rate      = taxYearConfigurationData.Plan4StudentLoanRate;
                break;

            case StudentLoanPlan.PostGrad:
                threshold = taxYearConfigurationData.PostGradStudentLoanThreshold;
                rate      = taxYearConfigurationData.PostGradStudentLoanRate;
                break;
            }

            periodAdjustedThreshold = TaxMath.Truncate(((threshold * weeksInPeriod) / periodCnt), 2);
            thresholdAdjustedGross  = Math.Max(0, gross - periodAdjustedThreshold);
            deduction = Math.Floor(thresholdAdjustedGross * rate);

            return(new StudentLoanCalculation
            {
                Gross = gross,
                Threshold = threshold,
                Rate = rate,
                PeriodAdjustedThreshold = periodAdjustedThreshold,
                ThresholdAdjustedGross = thresholdAdjustedGross,
                StudentLoanDeduction = deduction
            });
        }
        public StudentLoanCalculationResult CalculateStudentLoanDeduction(StudentLoanPlan plan, decimal gross, PayPeriods periods)
        {
            decimal threshold = 0, rate = 0, periodAdjustedThreshold, thresholdAdjustedGross, deduction;
            int     periodCnt     = 52;
            int     weeksInPeriod = 1;

            if (periods == PayPeriods.Monthly)
            {
                periodCnt = 12;
            }
            else
            {
                weeksInPeriod = (int)Math.Round((decimal)periodCnt / (int)periods);
            }

            switch (plan)
            {
            case StudentLoanPlan.Plan1:
                threshold = TaxYearSpecificProvider.GetSpecificValue <decimal>(TaxYearSpecificValues.Plan1StudentLoanThreshold);
                rate      = TaxYearSpecificProvider.GetSpecificValue <decimal>(TaxYearSpecificValues.Plan1StudentLoanRate);
                break;

            case StudentLoanPlan.Plan2:
                threshold = TaxYearSpecificProvider.GetSpecificValue <decimal>(TaxYearSpecificValues.Plan2StudentLoanThreshold);
                rate      = TaxYearSpecificProvider.GetSpecificValue <decimal>(TaxYearSpecificValues.Plan2StudentLoanRate);
                break;
            }

            periodAdjustedThreshold = TaxMath.Truncate(((threshold * weeksInPeriod) / periodCnt), 2);
            thresholdAdjustedGross  = Math.Max(0, gross - periodAdjustedThreshold);
            deduction = Math.Floor(thresholdAdjustedGross * rate);

            return(new StudentLoanCalculationResult
            {
                Gross = gross,
                Threshold = threshold,
                Rate = rate,
                PeriodAdjustedThreshold = periodAdjustedThreshold,
                ThresholdAdjustedGross = thresholdAdjustedGross,
                StudentLoanDeduction = deduction
            });
        }
Example #4
0
        protected decimal TestShim(int year, StudentLoanPlan plan, decimal gross, PayPeriods periods)
        {
            var studentLoanCalculationEngine = studentLoanFactory.CreateStudentLoanCalculationEngine(year);

            return(studentLoanCalculationEngine.CalculateStudentLoanDeduction(plan, gross, periods).StudentLoanDeduction);
        }