var Calculators = Calculators || {};
Calculators.planning = Calculators.planning || {};

Calculators.planning.FlexibleSpendingAccount = function FlexibleSpendingAccount(pay, stateAndLocalWithholdingRate, shelteredContributionRate, filingStatus, payPeriod, numberOfAllowances, childcare, medical, dental, drug, otherFSA) {
	this.pay = new Calculators.type.Money(pay);
	this.stateAndLocalWithholdingRate = new Calculators.type.Rate(stateAndLocalWithholdingRate);
	this.shelteredContributionRate = new Calculators.type.Rate(shelteredContributionRate);
	this.filingStatus = filingStatus;
	this.payPeriod = new Number(payPeriod);
	this.numberOfAllowances = new Number(numberOfAllowances);
	this.childcare = new Calculators.type.Money(childcare);
	this.medical = new Calculators.type.Money(medical);
	this.dental = new Calculators.type.Money(dental);
	this.drug = new Calculators.type.Money(drug);
	this.otherFSA = new Calculators.type.Money(otherFSA);
	this.totalFSA = this.childcare.add(this.medical).add(this.dental).add(this.drug).add(this.otherFSA);
	
	
	this.paycheckWithoutFSA = new Calculators.planning.GrossToNetPaycheck(this.pay, 0, this.shelteredContributionRate, 0, this.payPeriod, this.filingStatus, this.numberOfAllowances, 0, 0, this.stateAndLocalWithholdingRate);
	
	this.paycheckWithFSA = new Calculators.planning.GrossToNetPaycheck(this.pay.subtract(this.totalFSA), 0, 0, this.shelteredContributionRate.getAmount() * this.pay.getAmount(), this.payPeriod, this.filingStatus, this.numberOfAllowances, 0, 0, this.stateAndLocalWithholdingRate);	
	
	this.getTotalFSA = function() {
		return this.totalFSA;
	}
	
	this.getWithholding = function() {
		return this.paycheckWithoutFSA.getFederalWithholding();
	}
	
	this.getWithholdingFSA = function() {
		return this.paycheckWithFSA.getFederalWithholding();
	}
	
	this.getOASDI = function() {
		return this.paycheckWithoutFSA.getOASDI();
	}
	
	this.getOASDIFSA = function() {
		return this.paycheckWithFSA.getOASDI();
	}
	
	this.getMedicare = function() {
		return this.paycheckWithoutFSA.getMedicare();
	}
	
	this.getMedicareFSA = function() {
		return this.paycheckWithFSA.getMedicare();
	}
	
	this.getSavings = function() {
		return this.getNetPayFSA().subtract(this.getNetPay());
	}
	
	this.getStateAndLocalWithholding = function() {
		return this.paycheckWithoutFSA.getStateAndLocalWithholding();
	}
	
	this.getStateAndLocalWithholdingFSA = function() {
		return this.paycheckWithFSA.getStateAndLocalWithholding();
	}	
	
	this.getShelteredContributions = function() {
		return this.paycheckWithoutFSA.getTotalPreTaxDeductions();
	}
	
	this.getShelteredContributionsFSA = function() {
		return this.paycheckWithFSA.getTotalPreTaxDeductions();
	}
	
	this.getNetPay = function() {
		return this.paycheckWithoutFSA.getNet().subtract(this.totalFSA);
	}
	
	this.getNetPayFSA = function() {
		return this.paycheckWithFSA.getNet();
	}	
}