public CalculationResult CalculateSalary(decimal salary, decimal bonus = 0) { if (salary < 1) { throw new Exception("Salary too low to calculate."); } var hoursAvailable = 40 * _weeksPerYear; var hoursOff = 8 * DaysOffPerYear; var hoursWorked = hoursAvailable - hoursOff; var hoursPaid = hoursAvailable; var taxableAmount = salary + bonus; var federalTax = TaxProfile.FixedBaseAmount + TaxProfile.TaxBracketRate * (taxableAmount - TaxProfile.TaxBracketThreshold); var employerTax = (TaxProfile.MedicareRate + TaxProfile.SocialSecurityRate) * taxableAmount; var employeeTax = federalTax + employerTax; var employerRetirement = Math.Min(BenefitsProfile.RetirementContributionRate, BenefitsProfile.RetirementMatchingContributionRate) * salary; var employeeRetirement = BenefitsProfile.RetirementContributionRate * salary; var result = new CalculationResult { ActualHoursWorked = hoursWorked, CashCompensation = taxableAmount, TaxesPaidByEmployer = employerTax, TaxesPaidByEmployee = employeeTax, RetirementContributionByEmployer = employerRetirement, RetirementContributionByEmployee = employeeRetirement, HealthAndDentalPaidByEmployer = BenefitsProfile.EmployerHealthAndDentalCostsPaid }; result.EquivalentContractRate = ContractRateRequired(result.TotalCompensation, result.ActualHoursWorked); result.EquivalentWageRate = WageRequired(result.TotalCompensation); return(result); }
public CalculationResult CalculateContractRate(decimal ratePerHour) { if (ratePerHour < 1) { throw new Exception("Rate too low to calculate."); } var hoursAvailable = 40 * _weeksPerYear; var hoursOff = 8 * DaysOffPerYear; var hoursWorked = hoursAvailable - hoursOff; var hoursPaid = hoursWorked; var totalMoneyPaid = hoursPaid * ratePerHour; var taxableAmount = totalMoneyPaid; var federalTax = TaxProfile.FixedBaseAmount + TaxProfile.TaxBracketRate * (taxableAmount - TaxProfile.TaxBracketThreshold); var employerTax = 0; var employeeTax = federalTax + 2 * (TaxProfile.MedicareRate + TaxProfile.SocialSecurityRate) * taxableAmount; var employerRetirement = 0; var employeeRetirement = BenefitsProfile.RetirementContributionRate * totalMoneyPaid; var result = new CalculationResult { ActualHoursWorked = 40 * _weeksPerYear - 8 * DaysOffPerYear, CashCompensation = taxableAmount, TaxesPaidByEmployer = employerTax, TaxesPaidByEmployee = employeeTax, RetirementContributionByEmployer = employerRetirement, RetirementContributionByEmployee = employeeRetirement, HealthAndDentalPaidByEmployer = 0 }; result.EquivalentSalary = SalaryRequired(result.TotalCompensation, 0); result.EquivalentWageRate = WageRequired(result.TotalCompensation); return(result); }