
if (Calculators == undefined) {
    var Calculators = {};
}
if (Calculators.planning == undefined) {
    Calculators.planning = {};
}
Calculators.planning.RothIRA = function RothIRA(contributions, workingRateOfReturn,
	retiredRateOfReturn, currentAge, retirementAge, yearsOfRetirement, 
	federalTaxRate, stateTaxRate, stateTaxDeducted, retiredTaxRate) {

	this.ira = new Calculators.planning.IRA(contributions, workingRateOfReturn,
	retiredRateOfReturn, currentAge, retirementAge, yearsOfRetirement, 
	federalTaxRate, stateTaxRate, stateTaxDeducted, retiredTaxRate);

	this.snapshots = [];
	
	this.getAnnualContributions = function() {
		return this.ira.getAnnualContributions();
	}
	
	this.getPreRetirementRateOfReturn = function() {
		return this.ira.getPreRetirementRateOfReturn();
	}
	
	this.getRetirementRateOfReturn = function() {
		return this.ira.getRetirementRateOfReturn();
	}
	
	this.getCurrentAge = function() {
		return this.ira.getCurrentAge();
	}
	
	this.getRetirementAge = function() {
		return this.ira.getRetirementAge();
	}
	
	this.getYearsUntilRetirement = function() {
		return this.ira.getYearsUntilRetirement();
	}
	
	this.getYearsOfRetirement = function() {
		return this.ira.getYearsOfRetirement();
	}
	
	this.getFederalTaxRate = function() {
		return this.ira.getFederalTaxRate();
	}
	
	this.getStateTaxRate = function() {
		return this.ira.getStateTaxRate();
	}
	
	this.getIncludeStateTax = function() {
		return this.ira.getIncludeStateTax();
	}
	
	this.getRetiredTaxRate = function() {
		return this.ira.getRetiredTaxRate();
	}

	this.getCombinedTaxRate = function() {
		return this.ira.getCombinedTaxRate();
	}
	
	this.getGrossPayNeededForContribution = function() {
		return this.ira.getGrossPayNeededForContribution();
	}
	
	this.getTaxSavings = function() {
		return new Calculators.type.Money(0.00);
	}
	
	this.getTotalAnnualContribution = function() {
		return this.ira.getAnnualContributions();
	}
	
	this.getTotalAccumulatedAtRetirement = function() {
		// -(FV((C12),B11,C16,0,0))
		var rateOfReturn = this.getPreRetirementRateOfReturn().getAmount();
		var years = this.getYearsUntilRetirement();
		var contributions = this.getTotalAnnualContribution().getAmount();
		
		var formula = new Calculators.math.Formulas();
		var value = formula.fv(rateOfReturn, years, contributions, 0, 0);
		return new Calculators.type.Money(-1 * value);
	}
	
	this.getRetirementMonthlyIncome = function() {
		// -(PMT(B23/12,B22*12,C17,0,0))
		var rate = this.getRetirementRateOfReturn().monthly();
		var months = this.getYearsOfRetirement() * 12;
		var total = this.getTotalAccumulatedAtRetirement().getAmount();
		
		var formula = new Calculators.math.Formulas();
		var value = formula.pmt(rate, months, total, 0, 0);
		return new Calculators.type.Money(-1 * value);
	}
	
	this.getRetirementMonthlyIncomeAfterTaxes = function() {
		// 
		return this.getRetirementMonthlyIncome();
	}
}
