Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Periods to retirement
- // rate: interest rate per period on savings
- // payment: amount invested per period
- // target: desired dividend per period
- // returns: minimum periods until period return on savings is greater than target
- function PTR(rate, payment, target, period) {
- var periods = 0;
- var savings = 0;
- if(!period) {
- period = 1;
- }
- while(savings * rate < target) {
- periods += period;
- savings += rate * savings + payment;
- }
- return periods;
- }
- // Savings at retirement
- // rate: interest rate per period on savings
- // payment: amount invested per period
- // target: desired dividend per period
- // returns: minimum savings for dividend to be greater than target
- function SAR(rate, payment, target) {
- var savings = 0;
- while(savings * rate < target) {
- savings += rate * savings + payment;
- }
- return savings;
- }
- // Periods to accrue
- // rate: interest rate per period on savings
- // payment: amount invested per period
- // target: desired dividend per period
- // returns: minimum number of periods before target return per period is met
- function PTA(rate, payment, target) {
- var periods = 0;
- var savings = 0;
- while(savings < target) {
- periods++;
- savings += rate * savings + payment;
- }
- return periods;
- }
- // Federal tax
- // gross: gross income
- // status: "single"/"married"/"separate"
- // allowances: number of allowances you have
- function FT(gross, status, allowances) {
- var tax_rates = {
- "single" : [[0, 9225, .1], [9225, 37450, .15], [37450, 90750, .25], [90750, 189300, .28], [189300, 411500, .33]],
- "married" : [[0, 18450, .1], [18450, 74900, .15], [74900, 151200, .25], [151200, 230450, .28], [230450, 441500, .33]],
- "separate" : [[0, 9225, .1], [9225, 37450, .15], [37450, 75600, .25], [75600, 115225, .28], [115225, 205750, .33]]
- }[status];
- gross = gross - allowances * 4050 - tax_rates[0][1];
- var total_tax = 0;
- for(i in tax_rates) {
- if(gross > tax_rates[i][0]) {
- if(gross <= tax_rates[i][1]) {
- total_tax += tax_rates[i][2] * (gross - tax_rates[i][0]);
- } else {
- total_tax += tax_rates[i][2] * (tax_rates[i][1] - tax_rates[i][0]);
- }
- } else {
- break;
- }
- }
- return total_tax ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement