Skip to main content
Participant
Jan 31, 2024 12:43 PM UTC
Question

Retirement monthly calculation

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;

5 replies

Participant
Sep 7, 2025 12:06 PM UTC

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: 

Translate
InstantMDAuthor
Participant
Feb 1, 2024 6:50 AM UTC

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 

Translate
Thom Parker
Community Expert
Community Expert
Jan 31, 2024 5:39 PM UTC

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. 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
InstantMDAuthor
Participant
Jan 31, 2024 7:38 PM UTC

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

Translate
Thom Parker
Community Expert
Community Expert
Jan 31, 2024 7:59 PM UTC

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

 

 

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