Skip to main content
Participant
January 31, 2024
Question

Retirement monthly calculation

  • January 31, 2024
  • 3 replies
  • 807 views

I am creating a formula for retirement in adobe acrobat but I am not getting correct results. 

=PMT(C17,C18,D16,-D13)

C17 is montly return rate
C18 is # of months until retirement
D16 is current savings
D13 is Amount needed in retirement 

var rate = Number(this.getField("C17").value);
var nper = Number(this.getField("C18").value);
var pv = Number(this.getField("D16").value);
var fv = -Number(this.getField("D13").value);

var pmt = (pv * rate) / (1 - Math.pow(1 + rate, -nper)) + (fv / Math.pow(1 + rate, nper));

if (this.getField("C17").value === "" || this.getField("C18").value === "")
event.value = "";
else
event.value = pmt;

3 replies

Participant
September 7, 2025

Yes, it’s definitely possible to calculate that. If you’re looking for a quick way, I’ve built a simple Fire Calculator tool that does the math automatically and shows results in an easy format. You can check it out here: 

InstantMDAuthor
Participant
February 1, 2024

I just noticed that I posted using my company account rather than my personal one. Could the administrators please delete my post? Thank you. @Thom Parker 

Thom Parker
Community Expert
Community Expert
January 31, 2024

What exactly are you getting for the results?  Why is it not correct?  Where is this code placed?

 

Just to clean up your code, in the if statement use "==" instead of "===".

However, this probably will not change your result. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
InstantMDAuthor
Participant
January 31, 2024

There is difference in result value. I have placed this code in D19 field in custom calculation script. 

Thom Parker
Community Expert
Community Expert
January 31, 2024

So some value is being calculated, just not the correct one? 

In this case you will need to debug your calculation script. 

 

To do this, copy the first 5 lines of your script to the console window. 

Break the calculation into individual parts, and run them individually to find the issue. 

 

Here's a video tutoial on using the console window. 

https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often