## TVM Example

This is a similar reproduction to the included TVM template. This template demonstrates number types, lists, both defined and undefined defaults, separators with labels, and rows with and without formulas:

"Present Value" "" pv:tvmpv(n; rate; pmt; fv; pyr; cyr; timing) ::
"Future Value" "" fv:tvmfv(n; rate; pv; pmt; pyr; cyr; timing) ::
Payment "" pmt:tvmpmt(n; rate; pv; fv; pyr; cyr; timing) ::
"Interest/Yr%" "" rate:tvmi(n; pv; pmt; fv; pyr; cyr; timing) ::
Periods "" n:tvmn(rate; pv; pmt; fv; pyr; cyr; timing) ::
"Periods/Yr" 12 pyr ::
"Compounds/Yr" 12 cyr ::
"Payment Timing" L0;End;0;Begin;1 timing ::
Amortization ::
"Begin Period" 1 begin ::
"End Period" 1 end ::
"Interest Paid" "" totint:AmSumInt(begin; end; pv; fv; rate; pmt; n; pyr; cyr; timing; totintdecplaces) ::
"Principal Paid" "" totprn:AmSumPrn(begin; end; pv; fv; rate; pmt; n; pyr; cyr; timing; totprndecplaces) ::
"Payment Paid" "" totpmt:totint+totprn ::
"End Balance" "" endbal:AmEndBal(end; pv; fv; rate; pmt; n; pyr; cyr; timing; endbaldecplaces)

A few notes:

• While Present Value through Periods all used separate formulas, all of them could have used the same formula, such as pmt = tvmpmt(n; rate; pv; fv; pyr; cyr; timing). powerOne would have calculated pmt and solved for n, rate, pv, and fv. Using individual formulas means faster calculations.
• Interest Paid, Principal Paid and End Balance all use a special function called decplaces to round the result to it's currently set decimal places.
• All other functions are defined in the Math Function lists.

## Cash Flows Example

This is a partial reproduction of the cash flows template, demonstrating primarily the use of tables but also a separator without a label (third row).

"Cash Flows" T1 cf ::
"Interest/Yr%" "" rate ::
"Periods/Yr" 1 pyr ::
::
"Net Present Value" "" npv:CfoNPV(cf; rate/pyr) ::
"Internal Rate of Return%" "" irr:CfoIRR(cf)*pyr ::
"Net Future Value" "" nfv:CfoNFV(cf; rate/pyr)

## Date Conversion Example

This reproduction of the date conversion template demonstrates dates and special row element calMode:

calMode ::
"Date 1" D d1:d2 - dd ::
"Date 2" D d2:d1 + dd ::
"Days" "" days:ddays(d1;d2)

## Mortgages

"Mortgage" ::
"Price" "" price, 2, totint : pmt = -tvmpmt(years * timing; rate; price - down; 0; timing; type; 0) ::
"Down Payment" "" down, 2 ::
"Interest/Yr%" "" rate, 3, totint:pmt = -tvmpmt(years * timing; rate; price - down; 0; timing; type; 0) ::
"Years" 30 years, totint:tvmn(rate; -(price - down); pmt; 0; timing; type; 0) / timing ::
"Payment" "" pmt, 2, totint:-tvmpmt(years * timing; rate; price - down; 0; timing; type; 0) ::
"Payment Timing" "L12;Weekly;52;Bi-Weekly;26;2x/Month;24;Monthly;12;Quarterly;4;2x/Year;2;Yearly;1" timing ::

"Amortization" ::
"Begin Period" "1" begin ::
"End Period" "1" end ::
"Interest Paid" "" readonly totint, 2, totprn:AmSumInt(begin; end; price - down; 0; rate; -pmt; years*timing; timing; type; 0; totintdecplaces; true) ::
"Principal Paid" "" readonly noequals totprn, 2, totpmt : AmSumPrn(begin; end; price - down; 0; rate; -pmt; years*timing; timing; type; 0; totprndecplaces; true) ::
"Payment Paid" "" readonly noequals totpmt, 2, endbal: totint+totprn ::
"End Balance" "" readonly noequals endbal, 2, piti:AmEndBal(end; price - down; 0; rate; -pmt; years*timing; timing; type; 0; endbaldecplaces) ::

"PITI/Escrow" ::
"Insurance" 0 insurance, 2 ::
"PMI" 0 pmi, 2 ::
"Property Taxes" 0 taxes, 2 ::
"Tax Type" "L1;Tax/Year;1;Tax%;2;Tax1000;3" tax_type ::
"Other" 0 other, 2 ::
"PITI" "" readonly piti, 2, loan_amt: pmt + insurance/timing + pmi/timing + other/timing + choose(tax_type; taxes; price*(taxes/100); price/1000*taxes)/timing ::

"Summary/Analysis" ::
"Points%" 0 points, 3 ::
"Fees" 0 fees, 2 ::
"Loan Amount" "" readonly loan_amt, 2, down_perc: price - down ::
"Down Payment%" "" readonly noequals down_perc, 3, close_cost: down/price * 100 ::
"Closing Costs" "" readonly noequals close_cost, 2, piti_paid : down + fees + ((loan_amt + fees) * points%) ::
"Total PITI" "" readonly noequals piti_paid, 2, apr : round(piti;piti_paiddecplaces) * years * timing ::
"APR%" "" readonly noequals apr, 3 : if(price-close_cost == 0 || pmt == 0; 0; tvmi(years * timing; price - close_cost; -pmt; 0; timing; type; 0)) ::

## More Examples

Many of the templates Infinity Softworks provides bundled into powerOne or in the Library are available for review. Select the Edit button in the template to review its source.

You can also search our Get Satisfaction community site for more examples and code, some contributed by powerOne customers!