Accurate Mortgage APR Calculation (Incl. PMI &amp; FHA MI)

I am in need of a script that can accurately calculate the Annual Percentage Rate of a mortgage loan.

More specifically, the script needs to be able to configure Private Mortgage Insurance (PMI) or FHA Mortgage Insurance (MI). PMI is the same amount each month, however, it is discontinued once the loan balance drops below 80% of the property value. Therefore, an amortization table needs to be created to determine the payment number in which PMI is no longer required. For example, if after the 67th payment, the loan loan balance is less than 80% of the property value, and the PMI payment is $120 per month, then $8040 in total PMI payments needs to be added to the cost of the loan and calculated into the APR.

For FHA MI, my understanding is that MI is charged for the life of the loan, but at a percentage of the loan balance. Therefore, an amortization table would be needed and then the MI percentage would be applied to the new monthly balance. Then, all MI payments would be added to find the total MI payments over the life of the loan.

Finally, I also need to be able to accurately calculate APR for an Adjustable Rate Mortgage, based on projected interest rate adjustments, and PMI or MI. Therefore, the script will need to account for the Index and Margin of the loan.

Looking for something similar to: [url removed, login to view]

Also, looking for script only that will enter calculated number into a form field with a button onClick command.