after firmware 10077.
Code:
// APR fees 2.0 by Salvo Micciché
// require firmware > 10077
export APR_pmt:=0;
export APR_net:=0;
export APR_apr:={0,0};
smenu();
calcPoints();
calcAmt();
pointFix();
EXPORT APR_fees()
// APR (TAEG) with fees (spese)
// Salvo Micciché 2015
BEGIN
smenu();
END;
calcPoints()
BEGIN
local pv, n, r, points, beg;
local pmt, net, apr;
input ({ {pv, [0], {15,15,1}},
{n, [0], {40,15,1}},{r,[0],{70,15,1}},
{points, [0], {15,15,2}},
{beg,0, {70,2,2}}
},
"APR (TAEG) rate",
{"PV", "N","i%","Points%","End"},
{"Present value (mortgage)", "Period (months)", "Interest rate%", "Points fees (%)",
"Begin or End" },
{0,0,0,0,0},
{10000, 360, 5, 1, 1} );
pmt:= Finance.TvmPMT(n,r, pv, 0, 12, 12, beg);
net:= pv - (pv * points/100);
apr:= Finance.TvmIPYR(n,net, pmt, 0, 12,12, beg);
RECT_P();
TEXTOUT_P("Monthly payment " + EVAL(pmt), 25,50);
TEXTOUT_P("Actual amount received " + EVAL(net), 25, 70);
TEXTOUT_P("Monthly rate " + ROUND(EVAL(apr/12),3) + "%", 25, 90);
TEXTOUT_P("APR (TAEG) " + ROUND(EVAL(apr),3) + "%", 25, 110);
TEXTOUT_P("Press ESC key to continue", 25, 130, 3, RGB(0,0,255));
WAIT;
sto(pmt, APR_pmt);
sto(net, APR_net);
sto({apr/12, apr}, APR_apr);
smenu();
END;
calcAmt()
BEGIN
local pv, n, r, amt, beg;
local pmt, net, apr;
input ({ {pv, [0], {15,15,1}},
{n, [0], {40,15,1}},{r,[0],{70,15,1}},
{amt, [0], {15,15,2}},
{beg,0, {70,2,2}}
},
"APR (TAEG) rate",
{"PV", "N","i%","Fix amount","End"},
{"Present value (mortgage)", "Period (months)", "Interest rate%", "Fix amount to pay",
"Begin or End" },
{0,0,0,0,0},
{10000, 360, 5, 500, 1} );
pmt:= Finance.TvmPMT(n,r, pv, 0, 12, 12, beg);
net:= pv - amt;
apr:= Finance.TvmIPYR(n,net, pmt, 0, 12,12, beg);
RECT_P();
TEXTOUT_P("Monthly payment " + EVAL(pmt), 25,50);
TEXTOUT_P("Actual amount received " + EVAL(net), 25, 70);
TEXTOUT_P("Monthly rate " + ROUND(EVAL(apr/12),3) + "%", 25, 90);
TEXTOUT_P("APR (TAEG) " + ROUND(EVAL(apr),3) + "%", 25, 110);
TEXTOUT_P("Press ESC key to continue", 25, 130, 3, RGB(0,0,255));
WAIT;
sto(pmt, APR_pmt);
sto(net, APR_net);
sto({apr/12, apr}, APR_apr);
smenu();
END;
pointFix()
BEGIN
local pv, n, r, points, amt, beg;
local pmt, net, apr;
input ({ {pv, [0], {15,15,1}},
{n, [0], {40,15,1}},{r,[0],{70,15,1}},
{points, [0], {15,15,2}},{amt, [0], {70,15,2}},
{beg,0, {70,2,3}}
},
"APR (TAEG) rate",
{"PV", "N","i%","Points%", "Fix amt", "End"},
{"Present value (mortgage)", "Period (months)", "Interest rate%", "Points fees (%)",
"Fix amount to pay", "Begin or End" },
{0,0,0,0,0,0},
{10000, 360, 5, 1, 500, 1} );
pmt:= Finance.TvmPMT(n,r, pv, 0, 12, 12, beg);
net:= pv - (pv * points/100) - amt;
apr:= Finance.TvmIPYR(n,net, pmt, 0, 12,12, beg);
RECT_P();
TEXTOUT_P("Monthly payment " + EVAL(pmt), 25,50);
TEXTOUT_P("Actual amount received " + EVAL(net), 25, 70);
TEXTOUT_P("Monthly rate " + ROUND(EVAL(apr/12),3) + "%", 25, 90);
TEXTOUT_P("APR (TAEG) " + ROUND(EVAL(apr),3) + "%", 25, 110);
TEXTOUT_P("Press ESC key to continue", 25, 130, 3, RGB(0,0,255));
WAIT;
sto(pmt, APR_pmt);
sto(net, APR_net);
sto({apr/12, apr}, APR_apr);
smenu();
END;
smenu()
BEGIN
local ch;
CHOOSE(ch, "APR (TAEG) with fees", "Fees: points %", "Fees: amount", "Fees: points + fix amount", "Quit");
CASE
IF ch==1 THEN calcPoints(); END;
IF ch==2 THEN calcAmt(); END;
IF ch==3 THEN pointFix(); END;
IF ch==4 THEN RETURN; END;
DEFAULT
END; // case
END;