Not sure if this is exactly what you are looking for, however this explains in detail how it is done:

Net present value - Wikipedia, the free encyclopedia