Manipulate[

If[age+t≥oneTimePaymentThreshold,
oneTimePaymentEnabled=True,
oneTimePaymentEnabled=False;
oneTimePayment=False;
tax=0];

If[oneTimePayment==False,tax=0];

calculateVariables[K,Kzam,i*0.01/12,t*12,tax*0.01,isDue];

Column[
{
Grid[{

{Style["Státní podpora",Bold],"","",NumberForm[subvention,{Infinity,2}]},

{},

{Style["Vklady účastníka, včetně podpory",Bold],"","",""},
{"bez úroků:","("<>ToString@K<>"+"<>ToString@NumberForm[subvention,{Infinity,2}]<>") × "<>ToString@t<>" × "<>ToString@12," =",NumberForm[KTotal,{Infinity,2}]},
{"s úroky:","složený úrok ("<>ToString@i<>" %) během "<>ToString@t<>" let","=",NumberForm[KTotalWithInterest,{Infinity,2}]},
{"úroky:",ToString@NumberForm[KTotalWithInterest,{Infinity,2}]<>" - "<>ToString@NumberForm[KTotal,{Infinity,2}],"=",Style[NumberForm[KTotalInterest,{Infinity,2}],Darker@Green]},

{},

{Style["Vklady zaměstnavatele",Bold],"","",""},
{"bez úroků:",ToString@Kzam<>" × "<>ToString@t<>" × "<>ToString@12," =",NumberForm[KzamTotal,{Infinity,2}]},
{"s úroky:","složený úrok ("<>ToString@i<>" %) během "<>ToString@t<>" let","=",NumberForm[KzamTotalWithInterest,{Infinity,2}]},
{"úroky:",ToString@NumberForm[KzamTotalWithInterest,{Infinity,2}]<>" - "<>ToString@NumberForm[KzamTotal,{Infinity,2}],"=",Style[NumberForm[KzamTotalInterest,{Infinity,2}],Darker@Green]},

{},

{Style["Vklady celkem",Bold],"","",""},
{"bez úroků:","","=",NumberForm[KzamTotal+KTotal,{Infinity,2}]},
{"s úroky:","","=",NumberForm[KzamTotalWithInterest+KTotalWithInterest,{Infinity,2}]},
{"úroky:","","=",Style[NumberForm[KzamTotalInterest+KTotalInterest,{Infinity,2}],Darker@Green]},

{},

{"Daň",ToString@NumberForm[KzamTotalInterest+KTotalInterest,{Infinity,2}]<>" × "<>ToString[NumberForm[tax,{Infinity,2}]]<>" %","=",Style[NumberForm[interestTax,{Infinity,2}],Red]},

{},

{Style["Naspořeno celkem",Blue,20],"","=",Style[ToString@NumberForm[KzamTotalWithInterest+KTotalWithInterest-interestTax,{Infinity,2}],Blue,20]},

{},

{"",PieChart[{
K*t*12,
Kzam*t*12,
subvention*t*12,
(AnnuityLongterm[t*12,K,i*0.01/12,isDue]-K*t*12)*(100-tax)*0.01,
(AnnuityLongterm[t*12,Kzam,i*0.01/12,isDue]-Kzam*t*12)*(100-tax)*0.01,
(AnnuityLongterm[t*12,subvention,i*0.01/12,isDue]-subvention*t*12)*(100-tax)*0.01
},
ChartLegends->{
"vklady účastníka",
"vklady zaměstnavatele",
"státní příspěvky",
"úroky z vkladů účastníka",
"úroky z vkladů zaměstnavatele",
"úroky ze státních příspěvků"
}
]}

},
Alignment->Right,
(*Frame->All,*)
ItemSize->Automatic]
},
Alignment->Center],

Style["Doplňkové penzijní spoření",Bold],

Delimiter,

"Vklady",
{{K,300,"měsíční vklady účastníka [Kč]"}, 100,2000,100,Appearance->"Labeled", AppearanceElements->None},
{{Kzam,0,"měsíční vklady zaměstnavatele [Kč]"}, 0,2000,100,Appearance->"Labeled", AppearanceElements->None},
{{t,40,"doba spoření [v letech]"}, 5,100,5,Appearance->"Labeled", AppearanceElements->None},

Delimiter,
"Zhodnocení",
{{i,2,"předpokládané zhodnocení spoření [%]"}, 1,10,0.5,Appearance->"Labeled", AppearanceElements->None},
{{tax,15,"daň z výnosů [%]"}, 0,25,1,Appearance->"Labeled", AppearanceElements->None},

Delimiter,
"Jednorázové vyrovnání a daň",
{{oneTimePayment,False,"jednorázové vyrovnání"},{True,False},Enabled->oneTimePaymentEnabled},
{{oneTimePaymentThreshold,60,"min. věk účastníka pro vyrovnání"}, 40,70,1,Appearance->"Labeled", AppearanceElements->None},

Delimiter,
"Další parametry",
{{isDue,False,"typ spoření"},{True->"předlhůtní",False->"polhůtní"}},
{{age,20,"věk účastníka na začátku spoření"}, 20,50,5,Appearance->"Labeled", AppearanceElements->None},

{subvention,ControlType->None},
{KTotal,ControlType->None},
{KTotalWithInterest,ControlType->None},
{KTotalInterest,ControlType->None},
{KzamTotal,ControlType->None},
{KzamTotalWithInterest,ControlType->None},
{KzamTotalInterest,ControlType->None},
{interestTotal,ControlType->None},
{interestTax,ControlType->None},
{totalNoInterest,ControlType->None},
{totalWithInterest,ControlType->None},
{totalAfterTax,ControlType->None},
{oneTimePaymentEnabled,ControlType->None},

Delimiter,

Initialization:>(
AnnuityLongterm[k_,K_,i_,isDue_]:=(
K*((1+i)^k-1)/(i)*If[isDue==True,(i+1),1]
);

getSubvention[K_]:=(
sub=0;
If[Between[K,{300,399}],sub=90+0.2*(K-300)];
If[Between[K,{400,499}],sub=110+0.2*(K-400)];
If[Between[K,{500,599}],sub=130+0.2*(K-500)];
If[Between[K,{600,699}],sub=150+0.2*(K-600)];
If[Between[K,{700,799}],sub=170+0.2*(K-700)];
If[Between[K,{800,899}],sub=190+0.2*(K-800)];
If[Between[K,{900,999}],sub=210+0.2*(K-900)];
If[K≥1000,sub=230];

Floor@sub
);

calculateVariables[K_,Kzam_,i_,t_,tax_,isDue_]:=(
subvention=getSubvention[K];

KTotal=t*(K+subvention);
KTotalWithInterest=AnnuityLongterm[t,K+subvention,i,isDue];
KTotalInterest=KTotalWithInterest-KTotal;

KzamTotal=Kzam*t;
KzamTotalWithInterest=AnnuityLongterm[t,Kzam,i,isDue];
KzamTotalInterest=KzamTotalWithInterest-KzamTotal;

interestTotal=KTotalInterest+KzamTotalInterest;
interestTax=interestTotal*tax;

totalNoInterest=KTotal+KzamTotal;
totalWithInterest=KzamTotalWithInterest+KTotalWithInterest;
totalAfterTax=totalWithInterest-interestTax;
);
),

AppearanceElements->"ResetButton",
ControlPlacement->Left,
ContinuousAction->False,
SaveDefinitions->True
]