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
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index eb24eb9..dc7de33 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -682,7 +682,7 @@
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();
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 512e756..1326c5f 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1708,27 +1708,27 @@
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 @@
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 @@
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 @@
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);
}
}
}