Kaydet (Commit) e96d2593 authored tarafından Thomas Arnhold's avatar Thomas Arnhold

interpr: ZinsesZins is Compound Interest

There are many more, like ScZinsZ, ScLaufz, ScGetZw,...

And some I can't identify, because my financial vocabulary is limited:

nZr Zinsrate
nZzr Zinseszinsrate
nBw ?
nZw Zinswert
nRmz ?

and many many more ;)

Change-Id: I11c26a8d4519bbd1e8242d27d3815db2bc3fdecd
üst dcda4292
......@@ -682,7 +682,7 @@ void ScZZR();
bool RateIteration(double fNper, double fPayment, double fPv,
double fFv, double fPayType, double& fGuess);
void ScZins();
double ScGetZinsZ(double fZins, double fZr, double fZzr, double fBw,
double ScGetCompoundInterest(double fZins, double fZr, double fZzr, double fBw,
double fZw, double fF, double& fRmz);
void ScZinsZ();
void ScKapz();
......
......@@ -1708,27 +1708,27 @@ void ScInterpreter::ScZins()
PushDouble(fGuess);
}
double ScInterpreter::ScGetZinsZ(double fInterest, double fZr, double fZzr, double fBw,
double ScInterpreter::ScGetCompoundInterest(double fInterest, double fZr, double fZzr, double fBw,
double fZw, double fF, double& fRmz)
{
fRmz = ScGetRmz(fInterest, fZzr, fBw, fZw, fF); // fuer kapz auch bei fZr == 1
double fInterestZ;
double fCompoundInterest;
nFuncFmtType = NUMBERFORMAT_CURRENCY;
if (fZr == 1.0)
{
if (fF > 0.0)
fInterestZ = 0.0;
fCompoundInterest = 0.0;
else
fInterestZ = -fBw;
fCompoundInterest = -fBw;
}
else
{
if (fF > 0.0)
fInterestZ = ScGetZw(fInterest, fZr-2.0, fRmz, fBw, 1.0) - fRmz;
fCompoundInterest = ScGetZw(fInterest, fZr-2.0, fRmz, fBw, 1.0) - fRmz;
else
fInterestZ = ScGetZw(fInterest, fZr-1.0, fRmz, fBw, 0.0);
fCompoundInterest = ScGetZw(fInterest, fZr-1.0, fRmz, fBw, 0.0);
}
return fInterestZ * fInterest;
return fCompoundInterest * fInterest;
}
void ScInterpreter::ScZinsZ()
......@@ -1751,7 +1751,7 @@ void ScInterpreter::ScZinsZ()
else
{
double nRmz;
PushDouble(ScGetZinsZ(nInterest, nZr, nZzr, nBw, nZw, nFlag, nRmz));
PushDouble(ScGetCompoundInterest(nInterest, nZr, nZzr, nBw, nZw, nFlag, nRmz));
}
}
......@@ -1775,7 +1775,7 @@ void ScInterpreter::ScKapz()
else
{
double nRmz;
double nInterestz = ScGetZinsZ(nInterest, nZr, nZzr, nBw, nZw, nFlag, nRmz);
double nInterestz = ScGetCompoundInterest(nInterest, nZr, nZzr, nBw, nZw, nFlag, nRmz);
PushDouble(nRmz - nInterestz);
}
}
......@@ -1800,22 +1800,22 @@ void ScInterpreter::ScKumZinsZ()
sal_uLong nStart = (sal_uLong) fStart;
sal_uLong nEnd = (sal_uLong) fEnd ;
double fRmz = ScGetRmz(fInterest, fZzr, fBw, 0.0, fF);
double fInterestZ = 0.0;
double fCompoundInterest = 0.0;
if (nStart == 1)
{
if (fF <= 0.0)
fInterestZ = -fBw;
fCompoundInterest = -fBw;
nStart++;
}
for (sal_uLong i = nStart; i <= nEnd; i++)
{
if (fF > 0.0)
fInterestZ += ScGetZw(fInterest, (double)(i-2), fRmz, fBw, 1.0) - fRmz;
fCompoundInterest += ScGetZw(fInterest, (double)(i-2), fRmz, fBw, 1.0) - fRmz;
else
fInterestZ += ScGetZw(fInterest, (double)(i-1), fRmz, fBw, 0.0);
fCompoundInterest += ScGetZw(fInterest, (double)(i-1), fRmz, fBw, 0.0);
}
fInterestZ *= fInterest;
PushDouble(fInterestZ);
fCompoundInterest *= fInterest;
PushDouble(fCompoundInterest);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment