home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 November / pcwk_11_98a.iso / Wtestowe / Money99 / money99.1 / dira / logic.js < prev    next >
Text File  |  1998-07-25  |  5KB  |  176 lines

  1. var sto = parent.data
  2.  
  3. var myJob = sto.empPlan1
  4. var myagi = sto.agi1
  5. var spouseJob = sto.empPlan2
  6. var spouseagi = sto.agi2
  7. var filingStatus = sto.status96
  8. var deduction = 0
  9. var spouseDeduction = 0
  10. var payment = 0
  11. var totalamount = 0
  12. var term = sto.yrs
  13. var irate = sto.rate
  14.  
  15. if ( myJob == 0 )
  16. {
  17.     if ( filingStatus == 'S' )
  18.     {
  19.         deduction = Math.min( myagi, 2000 )
  20.         deduction = Math.max( 0, deduction )
  21.     }
  22.     else if ( filingStatus == 'J' )
  23.     {
  24.         if ( spouseJob == 0 )
  25.         {
  26.             deduction = 4000
  27.         }
  28.         else
  29.         {
  30.             deduction = 4000 - ((myagi - 40000) / 2.5)
  31.             deduction = Math.min( myagi, deduction )
  32.             deduction = Math.max( 0, deduction )
  33.             deduction = Math.min( 4000, deduction )
  34.         }
  35.     }
  36.     else if ( filingStatus == 'X' )
  37.     {
  38.         deduction = Math.min( myagi, 2000 )
  39.         deduction = Math.max( 0, deduction )
  40.         deduction = Math.min( deduction, 2000 )
  41.         if ( spouseJob == 0 )
  42.         {
  43.             spouseDeduction = Math.min( 2000, spouseagi )
  44.         }
  45.         else
  46.         {
  47.             spousededuction = 2000 - (spouseagi / 5)
  48.             spouseDeduction = Math.min( spouseDeduction, spouseagi )
  49.         }
  50.         spouseDeduction = Math.max( 0, spouseDeduction )
  51.         spouseDeduction = Math.min( 2000, spouseDeduction )
  52.     }
  53. }
  54. else
  55. {
  56.     if ( filingStatus == 'S' )
  57.     {
  58.         deduction = 2000 - ((myagi - 25000) / 5)
  59.         deduction = Math.min( deduction, myagi )
  60.         deduction = Math.max( deduction, 0 )
  61.         deduction = Math.min( deduction, 2000 )
  62.     }
  63.     else if ( filingStatus == 'J' )
  64.     {
  65.         deduction = 4000 - ((myagi - 40000) / 2.5)
  66.         deduction = Math.min( deduction, myagi )
  67.         deduction = Math.max( deduction, 0 )
  68.         deduction = Math.min( deduction, 4000 )
  69.     }
  70.     else if ( filingStatus == 'X' )
  71.     {
  72.         if ( spouseJob == 0 )
  73.         {
  74.             spouseDeduction = Math.min( 2000, spouseagi )
  75.             spouseDeduction = Math.max( 0, spouseDeduction )
  76.         }
  77.         else
  78.         {
  79.             spousededuction = 2000 - (spouseagi / 5)
  80.             spouseDeduction = Math.min( spouseDeduction, spouseagi )
  81.             spouseDeduction = Math.max( 0, spouseDeduction )
  82.             spouseDeduction = Math.min( 2000, spouseDeduction )
  83.         }
  84.     }
  85. }
  86.  
  87.   // CALCULATE TOTAL SAVINGS
  88. payment = deduction
  89. if ( filingStatus == 'X' )
  90. {
  91.     payment = payment + spouseDeduction
  92. }
  93. if ( payment > 0 )
  94. {
  95.     rate = 1 + ( irate / 100 )
  96.     for ( var i = 0; i < term; i++ )
  97.     {
  98.         totalamount += payment
  99.         totalamount *= rate
  100.     }
  101. }
  102.  
  103.   // PREPARE FINAL TEXT
  104. var adviceStr = 'Given your AGI, tax filing and employment status, '
  105. var contributionBy = 'None'
  106. if ( filingStatus == 'S' )
  107. {    
  108.     if ( deduction > 0 )
  109.     {
  110.         contributionBy = "You"
  111.         adviceStr += "<b>you can contribute up to " + numToDollars( deduction ) + "</b> into a tax-deductible IRA."
  112.     }
  113.     else
  114.     {
  115.         adviceStr += "<b>you cannot take a deduction</b> for contributions to an IRA."
  116.     }
  117. }
  118. else if ( filingStatus == 'J' )
  119. {    
  120.     if ( deduction > 0 )
  121.     {
  122.         contributionBy = "You and Your Spouse"
  123.         adviceStr += "<b>you and your spouse can contribute up to " + numToDollars( deduction ) + "</b> into a tax-deductible IRA."
  124.     }
  125.     else
  126.     {
  127.         adviceStr += "<b>you and your spouse cannot take a deduction</b> for contributions to an IRA."
  128.     }
  129. }
  130. else if ( filingStatus == 'X' )
  131. {
  132.     if ( deduction > 0 )
  133.     {
  134.         if ( spouseDeduction > 0 )
  135.         {
  136.             contributionBy = "You and Your Spouse"
  137.             adviceStr += "<b>you can contribute up to " + numToDollars( deduction ) + "</b> into a tax-deductible IRA. "
  138.             adviceStr += "Likewise, <b>your spouse can contribute up to " + numToDollars( spouseDeduction ) + "</b>."
  139.         }
  140.         else
  141.         {
  142.             contributionBy = "You"
  143.             adviceStr += "<b>you can contribute up to " + numToDollars( deduction ) + "</b> into a tax-deductible IRA."
  144.             adviceStr += "  However, <b>your spouse cannot take a deduction</b> for contributions into an IRA."
  145.         }
  146.     }
  147.     else
  148.     {
  149.         if ( spouseDeduction > 0 )
  150.         {
  151.             contributionBy = "Spouse"
  152.             adviceStr += "<b>you cannot take a deduction</b> for contributions into a tax-deductible IRA,"
  153.             adviceStr += " but <b>your spouse can contribute up to " + numToDollars( spouseDeduction ) + "</b>."
  154.         }
  155.         else
  156.         {
  157.             adviceStr += "<b>neither you nor your spouse can take a deduction</b> for contributions into a tax-deductible IRA."
  158.         }
  159.     }
  160. }
  161.  
  162. var paymentstr = ''
  163. if ( payment > 0 )
  164. {
  165.     paymentstr = "<br><br>Based on your eligibility, the rate of return and the number of years you plan to contribute, "
  166.     if ( sto.status96 == 'S' )
  167.     {
  168.         paymentstr += "you will have " + numToDollars( totalamount ) + " in your IRA at the end of this period."
  169.     }
  170.     else
  171.     {
  172.         paymentstr += "you and your spouse will have " + numToDollars( totalamount ) + " in your IRA at the end of this period."
  173.     }
  174.     paymentstr += "  This assumes you will not withdraw any of your IRA funds before age 59 1/2.  If you withdraw before then, you will be subject to a 10 percent penalty, plus any monies withdrawn will be subject to taxes as regular income.  The number cited is before any taxes are assessed."
  175. }
  176.