Compound interest

Hello,

I need to design our invoice in a way that will automatically apply compound interest to balance that hasn’t been paid in full within the first 30 days (or whatever the due date is).

For example:

“Late payments are subjected to 20% interest compounded monthly.”

Using the compound calculator (http://www.calculatorsoup.com/calculators/financial/compound-interest-calculator.php) with the following values:

Initial balance: $100
Compound percentage: 20%
Number of months late: 4 months, which means 4/12 = 0.33 of a year

Total balance would be calculated as $106.76.

How do I go about adding this feature to the invoice template?

Thanks,

Devin