From e227b6516295c6954d24a8eb67d2f0c0475c32e9 Mon Sep 17 00:00:00 2001 From: Winfried Donkers Date: Wed, 22 Jun 2016 17:38:42 +0200 Subject: [PATCH] tdf#100523 Add constraints for AMORDEGRC function. Function returned different results than Excel does because of missing constraints. Change-Id: Iea8424a8429e0c48a19fe2818ca4be26c90afd32 Reviewed-on: https://gerrit.libreoffice.org/26571 Tested-by: Jenkins Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- scaddins/source/analysis/financial.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx index c51f4e984de8..8ad0ebb2ced9 100644 --- a/scaddins/source/analysis/financial.cxx +++ b/scaddins/source/analysis/financial.cxx @@ -27,7 +27,8 @@ double SAL_CALL AnalysisAddIn::getAmordegrc( const css::uno::Reference< css::bea double fCost, sal_Int32 nDate, sal_Int32 nFirstPer, double fRestVal, double fPer, double fRate, const css::uno::Any& rOB ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException, std::exception ) { - if( nDate > nFirstPer || fRate <= 0.0 || fRestVal > fCost ) + if( nDate > nFirstPer || fRate <= 0.0 || fRestVal > fCost || + fCost <= 0.0 || fRestVal < 0 || fPer < 0 ) throw css::lang::IllegalArgumentException(); double fRet = GetAmordegrc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, getDateMode( xOpt, rOB ) );