Esempio n. 1
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)));
        }
Esempio n. 2
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));
        }
Esempio n. 3
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));
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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));
        }
        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));
        }
Esempio n. 7
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));
        }
Esempio n. 8
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));
        }
        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)));
        }
Esempio n. 10
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)));
        }
Esempio n. 11
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));
        }
Esempio n. 12
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)));
        }
        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));
            }
        }
Esempio n. 14
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));
        }
Esempio n. 15
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));
        }
Esempio n. 16
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)));
        }
Esempio n. 17
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)));
        }
Esempio n. 18
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));
        }
        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));
        }
Esempio n. 20
0
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int allowances = 0)
        {
            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");
            }

            // The MT Withholding Tables were last revisted 10-January 2005

            // The amount of tax you withhold from an employee’s pay depends upon three factors:
            // (1) the length of your payroll period,
            // (2) the employee’s gross pay, and
            // (3) the number of withholding allowances claimed on the withholding allowance certificate(W - 4)

            // Step 1: Calculate Taxable earnings "T" -> T = Gross Earnings for Period - ($1,900 x Number of allowances)
            // Step 2: Calculate Withholding Tax "W" -> W = A (Flat Amount) + (Percentage x (Taxable Earnings - Bottom of Bracket)

            Decimal annualized_wages = frequency.CalculateAnnualized(grossWages);

            Decimal taxable_earnings = annualized_wages - (AllowanceValue * allowances);

            Decimal flat_amount = 0, bracket_floor = 0, percentage = 0m;

            if (taxable_earnings < 7000)
            {
                flat_amount   = 0;
                bracket_floor = 0;
                percentage    = 0.018m;
            }
            else if (taxable_earnings < 15000)
            {
                flat_amount   = 126;
                bracket_floor = 7000;
                percentage    = 0.044m;
            }
            else if (taxable_earnings < 120000)
            {
                flat_amount   = 478;
                bracket_floor = 15000;
                percentage    = 0.06m;
            }
            else
            {
                flat_amount   = 6778;
                bracket_floor = 120000;
                percentage    = 0.066m;
            }

            Decimal annual_withholding = flat_amount + (percentage * (taxable_earnings - bracket_floor));

            // Round ALL to the nearest dollar

            return(frequency.CalculateDeannualized(annual_withholding).Round(decimals: 0));
        }
Esempio n. 21
0
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, int personalAllowances)
        {
            var taxableWages = frequency.CalculateAnnualized(grossWages);

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

            return(frequency.CalculateDeannualized(Math.Max(0, taxWithheld)).Round(decimals: 0));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus = FilingStatus.Single, int withholdingAllowances = 1, decimal nonresidentPercentage = 0.00m)
        {
            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetWitholdingAllowance(withholdingAllowances);

            var selected_row = GetTaxWithholding(filingStatus, taxableWages);

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

            if (nonresidentPercentage == 0.00m)
            {
                return(frequency.CalculateDeannualized(taxWithheld));
            }
            else
            {
                return(nonresidentPercentage * frequency.CalculateDeannualized(taxWithheld));
            }
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int allowances = 0, FilingStatus filingStatus = FilingStatus.Single)
        {
            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetAllowances(allowances);

            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)));
        }
Esempio n. 24
0
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int personalAllowances = 1, int dependentAllowances = 0)
        {
            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetPersonalAllowance(personalAllowances);

            taxableWages -= GetDependentAllowance(dependentAllowances);

            var taxWithheld = GetTaxWithholding(taxableWages);

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

            taxableWages -= GetPersonalAllowance(personalAllowances);

            var selected_row = GetTaxWithholding(filingStatus, taxableWages);

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

            return(frequency.CalculateDeannualized(taxWithheld));
        }
Esempio n. 26
0
        internal virtual Decimal Get_Exemption_Value(PayrollFrequency frequency, int number_of_exemptions)
        {
            switch (number_of_exemptions)
            {
            // "If an employee claims '0' exemptions, discontinue this step"

            case 0:
                return(Decimal.Zero);

            default:
                return(frequency.CalculateDeannualized((number_of_exemptions * Exemption_Value) + Exemption_Bonus));
            }
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, int exemptions)
        {
            var taxableWages = frequency.CalculateAnnualized(grossWages);

            taxableWages -= GetExemptions(exemptions);

            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));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, decimal federalWithholding, FilingStatus filingStatus = FilingStatus.Single, int personalAllowances = 1)
        {
            var annualWages  = frequency.CalculateAnnualized(grossWages);
            var taxableWages = annualWages;

            taxableWages -= Math.Min(GetFederalLimit(filingStatus, annualWages), federalWithholding);
            taxableWages -= GetStandardDeduction(filingStatus, personalAllowances, annualWages);
            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));
        }
Esempio n. 29
0
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus filingStatus, Decimal federalWithholding, int personalAllowances)
        {
            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));
        }
        public virtual Decimal Calculate(Decimal grossWages, PayrollFrequency frequency, FilingStatus taxStatus = FilingStatus.Single, int allowances = 0)
        {
            // Withholding Statuses: Single, Married, Head of Household

            var annualized_wages = frequency.CalculateAnnualized(grossWages);

            // The standard deduction is taken from the annualized wages before further reducing by the allowances values

            annualized_wages -= (allowances * AllowanceValue + StandardDeduction(taxStatus));

            // Multiply the annualized wages by the given tax rate and deannualize back for the period
            // Round off the final result of calculations to the nearest whole dollar

            return(frequency.CalculateDeannualized(annualized_wages * TaxRate).Round(decimals: 0));
        }