Example #1
0
        /// <summary>
        /// Returns State Withholding for Alabama, when provided with a non-negative value for Gross Wages, Federal Withholding and Dependent Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="federalWithholding"></param>
        /// <param name="filingStatus"></param>
        /// <param name="dependentAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, decimal federalWithholding, FilingStatus filingStatus = FilingStatus.Single, int dependentAllowances = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (federalWithholding < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(federalWithholding)} cannot be a negative number");
            }
            if (dependentAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(dependentAllowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            var annualWages = taxableWages;

            taxableWages -= frequency.CalculateAnnualized(federalWithholding);

            taxableWages -= GetStandardDeduction(filingStatus, annualWages);

            taxableWages -= GetPersonalAllowance(filingStatus);

            taxableWages -= GetDependentAllowance(annualWages, dependentAllowances);

            var taxWithheld = GetTaxWithholding(filingStatus, taxableWages);

            return(Math.Max(Decimal.Zero, frequency.CalculateDeannualized(taxWithheld)));
        }
Example #2
0
        /// <summary>
        /// Returns Indiana State Withholding when a non-negative value is given for gross wages, personal allowances and dependent allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="personalAllowances"></param>
        /// <param name="dependentAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int personalAllowances = 1, int dependentAllowances = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (personalAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number");
            }
            if (dependentAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(dependentAllowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetPersonalAllowance(personalAllowances);

            taxableWages -= GetDependentAllowance(dependentAllowances);

            var taxWithheld = GetTaxWithholding(taxableWages);

            return(Math.Max(0, frequency.CalculateDeannualized(taxWithheld)));
        }
Example #3
0
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int exemptions = 0)
        {
            var annualized_wages = frequency.CalculateAnnualized(grossWages);

            // G(P) - [$3,000 + (E1 x $930) + (E2 x $800)] = T

            // Gross Pay for Period * Number of pay periods per year - (3000 + Personal+Dependent Exemptions x 930 + Age 65 and Over & Blind Exemptions x $800)

            annualized_wages -= 3000;               // Standard Deduction

            annualized_wages -= (exemptions * 930); // Personal + Dependent Exemptions

            decimal annualized_taxes = 0;

            if (annualized_wages < 3000)
            {
                annualized_taxes = annualized_wages * 0.02m;
            }
            else if (annualized_wages < 5000)
            {
                annualized_taxes = 60 + (annualized_wages - 3000) * 0.03m;
            }
            else if (annualized_wages < 17000)
            {
                annualized_taxes = 120 + (annualized_wages - 5000) * 0.05m;
            }
            else
            {
                annualized_taxes = 720 + (annualized_wages - 17000) * 0.0575m;
            }

            return(frequency.CalculateDeannualized(annualized_taxes));
        }
Example #4
0
        /// <summary>
        /// Returns Hawaii State Withholding when provided with a non-negative value for Gross Wages and Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="allowances"></param>
        /// <param name="filingStatus"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int allowances = 0, FilingStatus filingStatus = FilingStatus.Single)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (allowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(allowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetAllowances(allowances);

            if (taxableWages <= 0)
            {
                return(0);
            }

            var selected_row = getTaxRateRow(taxableWages, filingStatus);

            var wageWithheld = selected_row.TaxBase + ((taxableWages - selected_row.Floor) * selected_row.Rate);

            return(frequency.CalculateDeannualized(Math.Max(0, wageWithheld)));
        }
Example #5
0
        /// <summary>
        /// Returns Lousiana State Withholding when given a non-negative value for Gross Wages, Personal Exemptions, and Dependents.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="filingStatus"></param>
        /// <param name="personalExemptions"></param>
        /// <param name="dependents"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int personalExemptions = 0, int dependents = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (personalExemptions < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalExemptions)} cannot be a negative number");
            }
            if (dependents < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(dependents)} cannot be a negative number");
            }

            var TaxableWages = frequency.CalculateAnnualized(grossWages);

            var rate = GetRate(filingStatus, personalExemptions);

            var deductions = GetDeductions(rate, personalExemptions, dependents);

            var withholding = Math.Max(0, GetWithholding(rate, TaxableWages, deductions));

            return(frequency.CalculateDeannualized(withholding));
        }
Example #6
0
        /// <summary>
        /// Returns Colorado State Withholding when given a non-negative value for Gross Wages and Personal Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="filingStatus"></param>
        /// <param name="personalAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int personalAllowances)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (personalAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetPersonalAllowance(personalAllowances);

            if (taxableWages <= 0)
            {
                return(0);
            }

            var taxRate     = GetTaxWithholding(filingStatus, taxableWages);
            var taxWithheld = taxRate.TaxBase + ((taxableWages - taxRate.StartingAmount) * taxRate.TaxRate);

            return(frequency.CalculateDeannualized(Math.Max(0, taxWithheld)).Round(decimals: 0));
        }
Example #7
0
        /// <summary>
        /// Returns Arkansas State Withholding when given a non-negative value for Gross Wages and Exemptions.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="exemptions"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int exemptions = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (exemptions < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(exemptions)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= StandardDeductionValue;
            if (taxableWages < roundingValue)
            {
                taxableWages = applyMidpoint(taxableWages);
            }

            if (taxableWages <= 0)
            {
                return(0);
            }

            var withholdingTable = getBracket(taxableWages);

            taxableWages  = (withholdingTable.Percentage * taxableWages) - withholdingTable.FlatAmount;
            taxableWages -= getExemptions(taxableWages, exemptions);

            return(Math.Max(Decimal.Zero, frequency.CalculateDeannualized(taxableWages)));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus = FilingStatus.Single, int personalAllowances = 1, int dependentAllowances = 0)
        {
            var taxableWages = frequency.CalculateAnnualized(grossWages);

            // Note: Tax exemptions should be handled before we get to this call

            // if (FilingStatus.Exempt == filingStatus) return Decimal.Zero;

            //Use these instructions to calculate employee withholding using the percentage method.

            //(1) Subtract the applicable standard deduction as indicated in column(1) - (3) of Table E.

            taxableWages -= GetStandardDeduction(filingStatus);

            //(2) Subtract from the amount arrived at in (1) the appropriate amount of personal allowance as set out in column(4) – (6) of Table E.

            taxableWages -= GetPersonalAllowance(filingStatus, personalAllowances);

            //(3) If employees claim dependents other than themselves and/or their spouses, subtract from the amount arrived at in (2) the appropriate dependent amount as set out in column(7) of Table E.

            taxableWages -= GetDependentAllowance(filingStatus, dependentAllowances);

            //(4) Determine the amount of tax to be withheld from the applicable payroll line in Tables F, G, or H.

            var selected_row = GetTaxWithholding(filingStatus, taxableWages);

            // Calculate the withholding from the percentages

            var taxWithheld = selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate);

            //(5) If zero exemption is claimed, subtract the standard deduction only.

            return(frequency.CalculateDeannualized(taxWithheld));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int exemptions = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (exemptions < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(exemptions)} cannot be a negative number");
            }

            var annualized_wages = frequency.CalculateAnnualized(grossWages);

            var taxedWages = annualized_wages * TaxRateA;

            var allowances = GetAllowances(filingStatus, exemptions);

            annualized_wages -= GetStandardDeduction(filingStatus);

            annualized_wages = annualized_wages * TaxRateB;

            var deduction = allowances - annualized_wages;

            var taxWithheld = taxedWages - deduction;

            return(frequency.CalculateDeannualized(Math.Max(taxWithheld, 0)));
        }
Example #10
0
        /// <summary>
        /// Returns Maine State Withholding when given a non-negative value for Gross Wages and Withholding Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="filingStatus"></param>
        /// <param name="withholdingAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus = FilingStatus.Single, int withholdingAllowances = 1)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (withholdingAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(withholdingAllowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            var annualWages = taxableWages;

            taxableWages -= GetWitholdingAllowance(withholdingAllowances);

            taxableWages -= GetStandardDeduction(filingStatus, annualWages);

            if (taxableWages > 0)
            {
                var selected_row = GetTaxWithholding(filingStatus, taxableWages);
                var taxWithheld  = selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate);
                return(frequency.CalculateDeannualized(taxWithheld));
            }
            else
            {
                return(0);
            }
        }
Example #11
0
        /// <summary>
        /// Returns Oregon State Withholding when given a non-negative value for Federal Withholding, Gross Wages and Personal Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="federalWithholding"></param>
        /// <param name="filingStatus"></param>
        /// <param name="personalAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, decimal federalWithholding, FilingStatus filingStatus = FilingStatus.Single, int personalAllowances = 1)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (federalWithholding < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(federalWithholding)} cannot be a negative number");
            }
            if (personalAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number");
            }


            var annualWages  = frequency.CalculateAnnualized(grossWages);
            var taxableWages = annualWages;

            taxableWages -= Math.Min(GetFederalLimit(filingStatus, annualWages), federalWithholding);
            taxableWages -= GetStandardDeduction(filingStatus, personalAllowances, annualWages);

            if (taxableWages <= 0)
            {
                return(0);
            }

            var selected_row = GetTaxWithholding(filingStatus, personalAllowances, annualWages);

            taxableWages = selected_row.TaxBase + ((taxableWages - selected_row.ExcessLimit) * selected_row.TaxRate);
            var taxWithheld = taxableWages - GetPersonalAllowance(filingStatus, personalAllowances, annualWages);

            return(frequency.CalculateDeannualized(Math.Max(0, taxWithheld)).Round(decimals: 0));
        }
Example #12
0
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus status = FilingStatus.Two_Earnings, int exemptions = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (exemptions < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(exemptions)} cannot be a negative number");
            }

            var annualized_wages = frequency.CalculateAnnualized(grossWages);

            annualized_wages -= (exemptions * ExemptionValue);

            var bracket =
                Brackets
                .Where(_ => _.Status == status)
                .Where(_ => _.Floor < annualized_wages)
                .Where(_ => _.Ceiling >= annualized_wages)
                .Single();

            var annualized_withholding = bracket.FlatAmount + bracket.Percentage * (annualized_wages - bracket.Floor);

            // Round to the nearest dollar

            return(frequency.CalculateDeannualized(annualized_withholding).Round(decimals: 0));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int basicAllowances = 0, int additionalAllowances = 0)
        {
            var annualized_wages = frequency.CalculateAnnualized(grossWages);

            //Step 1 Determine the wages paid for the payroll period.

            //Step 2 Figure your employee’s exemptions using the allowances claimed on Form IL-W - 4.

            //a Multiply the number of allowances your employee claimed on Form IL - W - 4, Line 1, by $2,175.

            annualized_wages -= (basicAllowances * 2175);

            //b Multiply the number of allowances your employee claimed on Form IL - W - 4, Line 2, by $1,000.

            annualized_wages -= (additionalAllowances * 1000);

            //c Add your answers from Step 2a and Step 2b.

            //d Divide the result of Step 2c by the number of pay periods from the table. The result is your employee’s exemptions.

            //Step 3 Subtract the exemptions from the wages paid.The result is the taxable amount.

            //Step 4 Multiply the taxable amount by 3.75 percent(.0375).You must withhold this amount.

            //Step 5 Add any additional amount from Form IL-W - 4, Line 3.This is the total amount you withhold.

            // Note, we handle additional withholding requested on the processing side

            var annualized_taxes = annualized_wages * 0.0375m;

            return(frequency.CalculateDeannualized(annualized_taxes));
        }
Example #14
0
        /// <summary>
        /// Returns Idaho State Withholding when given a non-negative value for gross wages and personal allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="filingStatus"></param>
        /// <param name="personalAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus = FilingStatus.Single, int personalAllowances = 1)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (personalAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetPersonalAllowance(personalAllowances);

            if (taxableWages <= 0)
            {
                return(0);
            }

            var selected_row = GetTaxWithholding(filingStatus, taxableWages);

            var taxWithheld = Math.Round(selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate), MidpointRounding.AwayFromZero);

            return(Math.Round(frequency.CalculateDeannualized(taxWithheld), MidpointRounding.AwayFromZero));
        }
Example #15
0
        /// <summary>
        /// Returns the State Withholding for Iowa when provided with a non-negative value for Gross Wages, Exemptions and Federal Withholding.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="FedWithholding"></param>
        /// <param name="exemptions"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, Decimal FedWithholding = 0, int exemptions = 0)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (exemptions < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(exemptions)} cannot be a negative number");
            }
            if (FedWithholding < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(FedWithholding)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= frequency.CalculateAnnualized(FedWithholding);

            taxableWages -= GetStandardDeduction(exemptions);

            var withheldWages = FindWithholding(taxableWages);

            withheldWages -= GetAllowances(exemptions);

            return(Math.Max(0, frequency.CalculateDeannualized(withheldWages)));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, WithholdingCode employeeCode, int exemptions = 1)
        {
            // Additional/Reduced Withholding handled outside of this calculation

            if (employeeCode == WithholdingCode.E)
            {
                return(0);
            }

            var annualizedSalary = frequency.CalculateAnnualized(grossWages);

            var taxableWages = annualizedSalary;

            taxableWages -= GetExemptionAmount(taxableWages, employeeCode, exemptions);
            if (taxableWages > 0)
            {
                var withHolding = GetTaxWithholding(employeeCode, taxableWages);

                taxableWages  = withHolding.TaxBase + ((taxableWages - withHolding.StartingAmount) * withHolding.TaxRate);
                taxableWages += CheckAddBack(employeeCode, annualizedSalary);
                taxableWages += GetTaxRecapture(employeeCode, annualizedSalary);
                var taxWithheld = taxableWages * (1 - GetPersonalTaxCredits(employeeCode, annualizedSalary));

                taxWithheld = frequency.CalculateDeannualized(taxWithheld);
                //taxWithheld += additionalWithholding;
                //taxWithheld -= reducedWithholding;
                return(Math.Max(taxWithheld, 0));
            }
            else
            {
                //taxableWages += additionalWithholding;
                //taxableWages -= reducedWithholding;
                return(Math.Max(taxableWages, 0));
            }
        }
Example #17
0
        /// <summary>
        /// Returns Missouri Withholding when given a non-negative value for Gross Wages, Federal Withholding and Personal Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="filingStatus"></param>
        /// <param name="federalWithholding"></param>
        /// <param name="personalAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, Decimal federalWithholding, int personalAllowances)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (personalAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number");
            }
            if (federalWithholding < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(federalWithholding)} cannot be a negative number");
            }

            var taxableWages   = frequency.CalculateAnnualized(grossWages);
            var fedWithholding = frequency.CalculateAnnualized(federalWithholding);

            taxableWages -= GetStandardDeduction(filingStatus);

            taxableWages -= GetPersonalAllowance(filingStatus, personalAllowances);

            taxableWages -= GetFederalWithholding(filingStatus, federalWithholding);

            var taxWithheld = GetTaxWithholding(filingStatus, taxableWages);

            return(frequency.CalculateDeannualized(Math.Max(0, taxWithheld)).Round(decimals: 0));
        }
Example #18
0
        /// <summary>
        /// Returns Ohio State Withholding when given a non-negative number for gross wages and exemptions.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="exemptions"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int exemptions)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (exemptions < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(exemptions)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetExemptions(exemptions);

            if (taxableWages <= 0)
            {
                return(0);
            }

            var selected_row = GetTaxWithholding(taxableWages);

            taxableWages = (selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate));

            var taxWithheld = frequency.CalculateDeannualized(Math.Max(0, taxableWages)) * TaxRate;

            return(taxWithheld.Round(decimals: 2));
        }
Example #19
0
        /// <summary>
        /// Returns Rhode Island State Withholding when given a non-negative values for Gross Wages and Personal Allowances.
        /// </summary>
        /// <param name="grossWages"></param>
        /// <param name="frequency"></param>
        /// <param name="personalAllowances"></param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when Negative Values entered.</exception>
        /// <returns></returns>
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int personalAllowances = 1)
        {
            if (grossWages < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(grossWages)} cannot be a negative number");
            }
            if (personalAllowances < Decimal.Zero)
            {
                throw new ArgumentOutOfRangeException($"{nameof(personalAllowances)} cannot be a negative number");
            }

            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetPersonalAllowance(taxableWages, personalAllowances);

            if (taxableWages <= 0)
            {
                return(0);
            }

            var selected_row = GetTaxWithholding(taxableWages);

            var taxWithheld = selected_row.TaxBase + ((taxableWages - selected_row.StartingAmount) * selected_row.TaxRate);

            return(frequency.CalculateDeannualized(taxWithheld));
        }
Example #20
0
        public void Utah_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus filingStatus, int personalAllowances, decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.UT, year: 2017) as Utah.TaxTable;

            var result = table.Calculate(grossWages, freq, filingStatus, personalAllowances);

            Assert.AreEqual(expected, result);
        }
        public void Missouri_2017_Checks_And_Balances(PayrollFrequency frequency, Decimal grossWages, FilingStatus filingStatus, decimal federalWithholding, int allowances, Decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.MO, year: 2017) as Missouri.TaxTable2017;

            var result = table.Calculate(grossWages, frequency, filingStatus, federalWithholding, allowances);

            Assert.AreEqual(expected, result);
        }
Example #22
0
        public void DEChecks_And_Balances(PayrollFrequency frequency, Decimal grossWages, Delaware.FilingStatus filingStatus, int allowances, Decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.DE, year: 2017) as Delaware.TaxTable;

            var result = table.Calculate(grossWages, frequency, filingStatus, allowances);

            Assert.AreEqual(expected, result);
        }
Example #23
0
        public void AR_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency frequency, int exemptions, decimal expected)
        {
            var taxTable = TaxTables.GetForState(StateOrProvince.AR, year: 2017) as Arkansas.TaxTable;

            var result = taxTable.Calculate(grossWages, frequency, exemptions);

            Assert.AreEqual(expected, result);
        }
        public void Checks_And_Balances(PayrollFrequency frequency, Decimal grossWages, int basicAllowances, int additionalAllowances, Decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.IL, year: 2016) as Illinois.TaxTable;

            var result = table.Calculate(grossWages, frequency, basicAllowances, additionalAllowances);

            Assert.AreEqual(expected, result);
        }
        public void Checks_And_Balances(decimal grossWages, PayrollFrequency freq, FilingStatus status, int personalAllowances, int dependentAllowances, decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.GA, year: 2016) as Georgia.TaxTable;

            var result = table.Calculate(grossWages, freq, status, personalAllowances, dependentAllowances);

            Assert.AreEqual(expected, result);
        }
Example #26
0
        public void Ohio_2017_TaxTable(decimal grossWages, PayrollFrequency freq, int exemptions, decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.OH, year: 2017) as Ohio.TaxTable2017;

            var result = table.Calculate(grossWages, freq, exemptions);

            Assert.AreEqual(expected, result);
        }
        public void California_2017_Checks_And_Balances(PayrollFrequency frequency, Decimal grossWages, FilingStatus status, int allowances, int deductions, Decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.CA, year: 2017) as California.TaxTable2017;

            var result = table.Calculate(grossWages, frequency, status, allowances, deductions);

            Assert.AreEqual(expected, result);
        }
        public void Oregon_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, decimal federalWithholding, FilingStatus filingStatus, int personalAllowances, decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.OR, year: 2017) as Oregon.TaxTable2017;

            var result = table.Calculate(grossWages, freq, federalWithholding, filingStatus, personalAllowances);

            Assert.AreEqual(expected, result);
        }
Example #29
0
        public void NewYorkTaxTable2017(decimal grossWages, PayrollFrequency freq, Region region, FilingStatus status, int personalAllowances, decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.NY, year: 2017) as NewYork.TaxTable;

            var result = table.Calculate(grossWages, freq, region, status, personalAllowances);

            Assert.AreEqual(expected, result);
        }
Example #30
0
        public void Kentucky_2017_Checks_And_Balances(decimal grossWages, PayrollFrequency freq, int exemptions, decimal expected)
        {
            var table = TaxTables.GetForState(StateOrProvince.KY, year: 2017) as Kentucky.TaxTable2017;

            var result = table.Calculate(grossWages, freq, exemptions);

            Assert.AreEqual(expected, result);
        }