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 <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
Winfried Donkers
2016-06-22 17:38:42 +02:00
committed by Eike Rathke
parent 0ffe9eb48a
commit e227b65162

View File

@@ -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 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 ) 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(); throw css::lang::IllegalArgumentException();
double fRet = GetAmordegrc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, getDateMode( xOpt, rOB ) ); double fRet = GetAmordegrc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, getDateMode( xOpt, rOB ) );