Commit 7c600a05 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fixed: Bug 24229 - Аргумент Coupon при вычислении функции DURATION может...

fixed: Bug 24229 - Аргумент Coupon при вычислении функции DURATION может принимать отрицательные значения

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56193 954022d7-b5bf-4e40-9824-e11837661b57
parent bc4da8ed
......@@ -336,6 +336,10 @@
coupD = getcoupdays(new Date( settlement ),new Date( maturity ),frequency,basis),
numCoup = getcoupnum(new Date( settlement ),new Date( maturity ),frequency);
if ( settlement >= maturity || basis < 0 || basis > 4 || ( frequency != 1 && frequency != 2 && frequency != 4 ) || yld < 0 || coupon < 0 ){
return "#NUM!";
}
var duration = 0, p = 0;
var dsc = coupD - dbc;
......@@ -4284,6 +4288,14 @@
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), _duration( new Date(Date.UTC(2008,0,1)), new Date(Date.UTC(2016,0,1)), 0.08, 0.09, 2, 1 ) );
oParser = new parserFormula( "DURATION(DATE(2008,1,1),DATE(2016,1,1),-0.08,0.09,2,1)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), _duration( new Date(Date.UTC(2008,0,1)), new Date(Date.UTC(2016,0,1)), -0.08, 0.09, 2, 1 ) );
oParser = new parserFormula( "DURATION(DATE(2008,1,1),DATE(2016,1,1),-0.08,0.09,5,1)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), _duration( new Date(Date.UTC(2008,0,1)), new Date(Date.UTC(2016,0,1)), -0.08, 0.09, 5, 1 ) );
} )
test( "Test: \"MDURATION\"", function () {
......
......@@ -2204,12 +2204,6 @@ cDURATION.prototype.Calculate = function ( arg ) {
if ( frequency instanceof cError ) return this.value = frequency;
if ( basis instanceof cError ) return this.value = basis;
if ( settlement.getValue() >= maturity.getValue() ||
basis.getValue() < 0 || basis.getValue() > 4 ||
( frequency.getValue() != 1 && frequency.getValue() != 2 && frequency.getValue() != 4 ) ||
yld.getValue() < 0 || coupon.getValue < 0 )
return this.value = new cError( cErrorType.not_numeric );
settlement = settlement.getValue();
maturity = maturity.getValue();
coupon = coupon.getValue();
......@@ -2217,6 +2211,10 @@ cDURATION.prototype.Calculate = function ( arg ) {
frequency = frequency.getValue();
basis = basis.getValue();
if ( settlement >= maturity || basis < 0 || basis > 4 || ( frequency != 1 && frequency != 2 && frequency != 4 ) || yld < 0 || coupon < 0 ){
return this.value = new cError( cErrorType.not_numeric );
}
var settl = Date.prototype.getDateFromExcel( settlement ),
matur = Date.prototype.getDateFromExcel( maturity );
......
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