since you seem to be interested in a programatic approach, instead of building a model for every situation have you thought about making a single cashflow model that can do almost all of this stuff?

eg, if t represents a period of your choosing (say, 1 month).
c(t) = cashflow at time t
i(t) = effective interest rate per period, between t and t+1
f(t) = fund value at time t

Then you have (if t=0 is the start of the contract):
f_0 = c_0
f_t = c_t  + f_{t-1}(1+i_{t-1})

it isn't challenging to make a computer program or even a spreadsheet that will start at t=0 and loop over as many future values as you want. its not hard to get present values and other items of interest either.


Then every time a client presents you with a "different" problem, you only need to change the definition of c(t) and i(t).

Since you appear to be a commercial/real world poster, i draw your attention to my signiture.