scaddins/source/analysis/analysishelper.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
New commits: commit 2fd00e59ad6cf55c4fc621724de863947ef6dcf6 Author: Winfried Donkers <winfrieddonk...@libreoffice.org> Date: Thu Jul 7 08:16:21 2016 +0200 tdf#100528 follow up; filter nonsense results. With unrealistic depreciation rates (>100%), the caluculated amortisation value can be < 0. Although mathematically correct, financially this is nonsense. The patch returns 0.0 when the calculated amortisation values gets < 0.0. (Excel does the same.) Change-Id: I928bba647429ff6141abfdbd996d4562e31da746 Reviewed-on: https://gerrit.libreoffice.org/26996 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 9b17f04..992abfd 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -1042,12 +1042,16 @@ double GetAmorlinc( sal_Int32 nNullDate, double fCost, sal_Int32 nDate, sal_Int3 double f0Rate = GetYearFrac( nNullDate, nDate, nFirstPer, nBase ) * fRate * fCost; sal_uInt32 nNumOfFullPeriods = sal_uInt32( ( fCost - fRestVal - f0Rate) / fOneRate ); + double fResult = 0.0; if( nPer == 0 ) - return f0Rate; + fResult = f0Rate; else if( nPer <= nNumOfFullPeriods ) - return fOneRate; + fResult = fOneRate; else if( nPer == nNumOfFullPeriods + 1 ) - return fCostDelta - fOneRate * nNumOfFullPeriods - f0Rate; + fResult = fCostDelta - fOneRate * nNumOfFullPeriods - f0Rate; + + if ( fResult > 0.0 ) + return fResult; else return 0.0; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits