diff --git a/RetirementCalculator/MainWindow.xaml b/RetirementCalculator/MainWindow.xaml
index 850fe0e..4df2f2d 100644
--- a/RetirementCalculator/MainWindow.xaml
+++ b/RetirementCalculator/MainWindow.xaml
@@ -13,6 +13,7 @@
+
@@ -22,6 +23,9 @@
+
+
+
@@ -31,10 +35,14 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/RetirementCalculator/MainWindowModel.cs b/RetirementCalculator/MainWindowModel.cs
index 1eb64d5..a1b00c6 100644
--- a/RetirementCalculator/MainWindowModel.cs
+++ b/RetirementCalculator/MainWindowModel.cs
@@ -16,8 +16,11 @@ namespace RetirementCalculator
private FilingStatus _status;
private PayInformation _payInfo;
private DeductionInformation _deductionInfo;
+ private string _output;
private ICommand _doDebug;
+ private ICommand _doCalculate;
+ private ICommand _doAnalyze;
public int SelectedPeriodIndex
{
@@ -115,12 +118,27 @@ namespace RetirementCalculator
get { return _deductionInfo.RetirementPercentage; }
set { _deductionInfo.RetirementPercentage = value; OnPropertyChanged(nameof(RetirementContribution)); }
}
+ public string Output
+ {
+ get { return _output; }
+ set { SetProperty(ref _output, value, nameof(Output)); }
+ }
public ICommand DoDebug
{
get { return _doDebug; }
set { SetProperty(ref _doDebug, value, nameof(DoDebug)); }
}
+ public ICommand DoCalculate
+ {
+ get { return _doCalculate; }
+ set { SetProperty(ref _doCalculate, value, nameof(DoCalculate)); }
+ }
+ public ICommand DoAnalyze
+ {
+ get { return _doAnalyze; }
+ set { SetProperty(ref _doAnalyze, value, nameof(DoAnalyze)); }
+ }
public MainWindowModel()
{
@@ -130,7 +148,10 @@ namespace RetirementCalculator
_filingStatuses = new();
_payInfo = new();
_deductionInfo = new();
+ _output = string.Empty;
_doDebug = new RelayCommand(Placeholder);
+ _doCalculate = new RelayCommand(Placeholder);
+ _doAnalyze = new RelayCommand(Placeholder);
}
private void Placeholder(object obj)
diff --git a/RetirementCalculator/MainWindowViewModel.cs b/RetirementCalculator/MainWindowViewModel.cs
index 029b4e0..2f229f9 100644
--- a/RetirementCalculator/MainWindowViewModel.cs
+++ b/RetirementCalculator/MainWindowViewModel.cs
@@ -41,11 +41,14 @@ namespace RetirementCalculator
];
PayInfo = new();
DeductionInfo = new();
+ Output = string.Empty;
}
private void InitializeCommands()
{
DoDebug = new RelayCommand(DebugDo);
+ DoCalculate = new RelayCommand(CalculateDo);
+ DoAnalyze = new RelayCommand(AnalyzeDo);
}
private void DebugDo(object obj)
@@ -103,5 +106,107 @@ namespace RetirementCalculator
th
));
}
+
+ private void CalculateDo(object obj)
+ {
+ FederalTax ft = new(Status);
+ TaxRates ot = new();
+ string MessageFormat =
+ "Federal Taxes: {0:0.00}\n" +
+ "State Taxes: {1:0.00}\n" +
+ "Local Taxes: {2:0.00}\n" +
+ "Social Security: {3:0.00}\n" +
+ "Medicare: {4:0.00}\n" +
+ "Total Taxes: {5:0.00}\n\n" +
+ "Retirement Contribution: {6:0.00}\n\n" +
+ "Takehome: {7:0.00}";
+ double fed = ft.CalculateTax(PayInfo, DeductionInfo);
+ double state = ot.CalculateStateTax(PayInfo, DeductionInfo);
+ double local = ot.CalculateLocalTax(PayInfo, DeductionInfo);
+ double ss = ot.CalculateSocialSecurityTax(PayInfo, DeductionInfo);
+ double med = ot.CalculateMedicareTax(PayInfo, DeductionInfo);
+ double tot = fed + state + local + ss + med;
+ double PayPeriods = 1;
+ switch (PayInfo.Period)
+ {
+ case PayPeriod.Annually:
+ PayPeriods = 1;
+ break;
+ case PayPeriod.Monthly:
+ PayPeriods = 12;
+ break;
+ case PayPeriod.TwiceMonthly:
+ PayPeriods = 24;
+ break;
+ case PayPeriod.EveryOtherWeek:
+ PayPeriods = 26;
+ break;
+ case PayPeriod.EveryWeek:
+ PayPeriods = 52;
+ break;
+ default:
+ PayPeriods = 1;
+ break;
+ }
+ double gp = (PayInfo.Salary / PayPeriods);
+ double ret = gp * DeductionInfo.RetirementPercentage;
+ double th = gp - tot - ret - DeductionInfo.PreTaxDeductions;
+ Output = string.Format(MessageFormat,
+ fed,
+ state,
+ local,
+ ss,
+ med,
+ tot,
+ ret,
+ th
+ );
+ }
+
+ private void AnalyzeDo(object obj)
+ {
+ FederalTax ft = new(Status);
+ TaxRates ot = new();
+ string LineFormat = "Retirement: {0:00}%, ${1:000.00} Taxes: ${2:000.00} Takehome: ${3:0000.00}\n";
+ string TempOutput = string.Empty;
+ double PayPeriods = 1;
+ switch (PayInfo.Period)
+ {
+ case PayPeriod.Annually:
+ PayPeriods = 1;
+ break;
+ case PayPeriod.Monthly:
+ PayPeriods = 12;
+ break;
+ case PayPeriod.TwiceMonthly:
+ PayPeriods = 24;
+ break;
+ case PayPeriod.EveryOtherWeek:
+ PayPeriods = 26;
+ break;
+ case PayPeriod.EveryWeek:
+ PayPeriods = 52;
+ break;
+ default:
+ PayPeriods = 1;
+ break;
+ }
+ for (int i = 0; i <= 25; i++)
+ {
+ DeductionInformation di = new() { PreTaxDeductions = DeductionInfo.PreTaxDeductions, PostTaxDeductions = DeductionInfo.PostTaxDeductions };
+ di.RetirementPercentage = Convert.ToDouble(i) / 100d;
+ double fed = ft.CalculateTax(PayInfo, di);
+ double state = ot.CalculateStateTax(PayInfo, di);
+ double local = ot.CalculateLocalTax(PayInfo, di);
+ double ss = ot.CalculateSocialSecurityTax(PayInfo, di);
+ double med = ot.CalculateMedicareTax(PayInfo, di);
+ double tot = fed + state + local + ss + med;
+ double gp = (PayInfo.Salary / PayPeriods);
+ double ret = gp * di.RetirementPercentage;
+ double th = gp - tot - ret - DeductionInfo.PreTaxDeductions;
+ TempOutput += string.Format(LineFormat, i, ret, tot, th);
+ }
+ Output = TempOutput;
+ }
}
}