Quiet@Manipulate[

Column[
{
Grid[{
calculate[k,K,i*0.01/f,i2*0.01/f,f,initialDeposit,isDue,threshold];
{Style[message,Red,16]},

{"hraniční částka",
"",
Style[threshold,Blue],
"Kč"},

{"úrok z hraniční částky",
ToString[i]<>" % p.a. × "<>ToString@threshold,
thresholdInterest,
"Kč"},

{"plateb celkem",
"",
InterestChangePoint,
""},

{},

{Style["Stav "<>ToString@mesageChartBeforeThreshold,Bold,16]},
{"počet provedených plateb",
"",
InterestChangePoint,
""},

{"naspořená částka",
"("<>ToString@InterestChangePoint<>" × "<>ToString@N@K<>", vč. úroků při "<>ToString[i]<>" % p.a."<>")",
InterestChangePointPV,
"Kč"},
{"přebytek nad hraniční částkou",
"",InterestChangePointPVOver,
"Kč"},

{},

{Style["Stav po dosažení hraniční částky",Bold,16]},
{"počet provedených plateb",
"",
paymentsAfterThreshold,
""},

{"přebytek zúročený do konce spoření",
"(složený úrok "<>ToString[i2]<>" % p.a.)",
Style[InterestChangePointPVOverFV,Blue],
"Kč"},

{"úložka vč. úroku z hraniční částky",
ToString[K]<>"+ "<> ToString@thresholdInterest,
N[K+thresholdInterest],
"Kč"},

{"naspořená částka",
ToString[k*f-InterestChangePoint]<>" plateb "<>ToString[K+thresholdInterest]<>" při "<>ToString@i2<>" % p.a.",
Style[afterThresholdFV,Blue],
"Kč"},

{},

{Style["Celkem naspořeno",Bold,Blue,16],
"",
Style[ToString@total,Bold,Blue,16],
"Kč"
},

{},
{Style["Vývoj zůstatku během spoření",Bold,16]},
{"do dosažení hraniční částky","po dosažení hraniční částky"},

{plot1,plot2}
(*,{accountValuesBeforeThreshold,accountValuesAfterThreshold}*)
},
Alignment->Left
(*Frame->All,*)
],
""
}],

Style["Dvoupásmové spoření",Bold],

Delimiter,

{{isDue,False,"typ spoření:"},{False->"předlhůtní",True->"polhůtní"}},
{{K,3000,"úložka [Kč]"}, 1,5000,100,Appearance->"Labeled", AppearanceElements->None},
{{initialDeposit,0,"počáteční stav [Kč]"}, 0,10^5,1000,Appearance->"Labeled", AppearanceElements->None},
{{i,1.4,"nom. úrok. míra (p.a.) do hraniční částky [%]"}, 0.5,20,1,Appearance->"Labeled",AppearanceElements->None},
{{i2,0.8,"nom. úrok. míra (p.a.) nad hraniční částku [%]"}, 0.1,10,0.1,Appearance->"Labeled",AppearanceElements->None},
{{f,12,"frekvence úročení"}, {1->"rok",2->"půlrok",4->"čtvrtletí",12->"měsíc"},AppearanceElements->None,ControlType->PopupMenu},
{{k,5,"doba spoření [v letech]"}, 1,20,1,Appearance->"Labeled",AppearanceElements->None},
{{threshold,100000,"hraniční částka [Kč]"}, 1,3*10^5,1,Appearance->"Labeled",AppearanceElements->None},

{InterestChangePoint,ControlType->None},
{InterestChangePointPV,ControlType->None},
{InterestChangePointPVOver,ControlType->None},
{InterestChangePointPVOverFV,ControlType->None},
{thresholdInterest,ControlType->None},
{message,ControlType->None},
{thresholdReached,ControlType->None},
{afterThresholdFV,ControlType->None},
{total,ControlType->None},
{paymentsAfterThreshold,ControlType->None},
{accountValuesBeforeThreshold,ControlType->None},
{accountValuesAfterThreshold,ControlType->None},
{mesageChartBeforeThreshold,ControlType->None},
{plot1,ControlType->None},
{plot2,ControlType->None},

Initialization:>(

calculate[k_,K_,i_,i2_,f_,initialDeposit_,isDue_,threshold_]:=(
InterestChangePoint=Ceiling@getInterestChangePoint[k,K,i,f,initialDeposit,isDue,threshold];

If[InterestChangePoint>k*f,
thresholdReached=False;
message="Hraniční částky nelze\nběhem spoření dosáhnout!",
thresholdReached=True;
message=""];

If[thresholdReached==False,
(* threshold not reached *)
mesageChartBeforeThreshold="před dosažením hraniční částky";
InterestChangePoint=f*k;
InterestChangePointPV=AnnuityLongterm[f*k,K,i,f,initialDeposit,isDue];
total=InterestChangePointPV;
InterestChangePointPVOver=0;
InterestChangePointPVOverFV=0;
thresholdInterest=threshold*i;
afterThresholdFV=0;
paymentsAfterThreshold=0;
accountValuesBeforeThreshold=Table[AnnuityLongterm[j,K,i,f,initialDeposit,isDue],{j,1,f*k}];
accountValuesAfterThreshold={};(*Table[0,{j,0,f*k}];*)
,

(* threshold reached *)
mesageChartBeforeThreshold="při dosažení hraniční částky";
InterestChangePointPV=AnnuityLongterm[InterestChangePoint,K,i,f,initialDeposit,isDue];
accountValuesBeforeThreshold=Table[AnnuityLongterm[j,K,i,f,initialDeposit,isDue],{j,1,InterestChangePoint}]; 
InterestChangePointPVOver=InterestChangePointPV-threshold;
paymentsAfterThreshold=f*k-InterestChangePoint;
InterestChangePointPVOverFV=InterestChangePointPVOver*((1+i2)^(paymentsAfterThreshold));
thresholdInterest=threshold*i;
afterThresholdFV=AnnuityLongterm[(f*k-InterestChangePoint),K+thresholdInterest,i2,f,initialDeposit,isDue];


accountValuesAfterThreshold=Table[
threshold
+InterestChangePointPVOver*(1+i2)^j
+AnnuityLongterm[j,K+thresholdInterest,i2,f,initialDeposit,isDue],
{j,0,f*k-InterestChangePoint}];

total=threshold+afterThresholdFV+InterestChangePointPVOverFV;
];

plot1=ListPlot[accountValuesBeforeThreshold,
Filling->Axis,
ImageSize->Medium,
PlotStyle->{PointSize->Large},
PlotRange->{{0,InterestChangePoint},{0,total}},
GridLines->{None,{threshold}},
GridLinesStyle->Red,
PlotTheme->{"HeightGrid","PastelColor"}];

If[paymentsAfterThreshold==0,
plot2=ListPlot[{},
ImageSize->Medium,
PlotStyle->{PointSize->Large},
GridLines->{None,{threshold}},
PlotRange->{{f*k,f*k+10},{0,total}},
GridLinesStyle->Red
],
plot2=ListPlot[accountValuesAfterThreshold,
Filling->Axis,
ImageSize->Medium,
PlotStyle->{PointSize->Large,Darker@Green},
DataRange->{InterestChangePoint,f*k+1},
PlotRange->{{InterestChangePoint,f*k},{0,total}},
GridLines->{None,{threshold}},
GridLinesStyle->Red,
PlotTheme->{"HeightGrid","PastelColor"}
]];
);

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

getInterestChangePoint[k_,K_,i_,f_,initialDeposit_,isDue_,threshold_]:=(
x/.Quiet@Solve[{AnnuityLongterm[x,K,i,f,initialDeposit,isDue]==threshold},x,Reals][[1]]
);
),
SynchronousInitialization->False,
AppearanceElements->"ResetButton",
SaveDefinitions->True,
ContinuousAction->False,
ControlPlacement->Left
]