Commit 611da77c authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

поправлен Bug 24229 для MDURATION

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56199 954022d7-b5bf-4e40-9824-e11837661b57
parent 51cadd60
...@@ -2887,12 +2887,6 @@ cMDURATION.prototype.Calculate = function ( arg ) { ...@@ -2887,12 +2887,6 @@ cMDURATION.prototype.Calculate = function ( arg ) {
if ( frequency instanceof cError ) return this.value = frequency; if ( frequency instanceof cError ) return this.value = frequency;
if ( basis instanceof cError ) return this.value = basis; 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(); settlement = settlement.getValue();
maturity = maturity.getValue(); maturity = maturity.getValue();
coupon = coupon.getValue(); coupon = coupon.getValue();
...@@ -2900,6 +2894,10 @@ cMDURATION.prototype.Calculate = function ( arg ) { ...@@ -2900,6 +2894,10 @@ cMDURATION.prototype.Calculate = function ( arg ) {
frequency = frequency.getValue(); frequency = frequency.getValue();
basis = basis.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 ), var settl = Date.prototype.getDateFromExcel( settlement ),
matur = Date.prototype.getDateFromExcel( maturity ); matur = Date.prototype.getDateFromExcel( maturity );
...@@ -3989,13 +3987,19 @@ cPMT.prototype.Calculate = function ( arg ) { ...@@ -3989,13 +3987,19 @@ cPMT.prototype.Calculate = function ( arg ) {
if ( type.getValue() != 1 && type.getValue() != 0 ) return this.value = new cError( cErrorType.not_numeric ); if ( type.getValue() != 1 && type.getValue() != 0 ) return this.value = new cError( cErrorType.not_numeric );
rate = rate.getValue();
nper = nper.getValue();
fv = fv.getValue();
type = type.getValue();
pv = pv.getValue();
var res; var res;
if ( rate.getValue() != 0 ) { if ( rate != 0 ) {
res = -1 * ( pv.getValue() * Math.pow( 1 + rate.getValue(), nper.getValue() ) + fv.getValue() ) / res = -1 * ( pv * Math.pow( 1 + rate, nper ) + fv ) /
( ( 1 + rate.getValue() * type.getValue() ) * ( Math.pow( (1 + rate.getValue()), nper.getValue() ) - 1 ) / rate.getValue() ); ( ( 1 + rate * type ) * ( Math.pow( (1 + rate), nper ) - 1 ) / rate );
} }
else { else {
res = -1 * ( pv.getValue() + fv.getValue() ) / nper.getValue(); res = -1 * ( pv + fv ) / nper;
} }
return this.value = new cNumber( res ); return this.value = new cNumber( res );
...@@ -5486,7 +5490,7 @@ cXNPV.prototype.Calculate = function ( arg ) { ...@@ -5486,7 +5490,7 @@ cXNPV.prototype.Calculate = function ( arg ) {
if ( vaTmp instanceof cError || daTmp instanceof cError ) if ( vaTmp instanceof cError || daTmp instanceof cError )
return new cError( cErrorType.not_numeric ); return new cError( cErrorType.not_numeric );
res += valueArray[i].getValue() / ( Math.pow( ( 1 + r ), ( dateArray[i].getValue() - d1.getValue() ) / 365 ) ) res += valueArray[i].getValue() / ( Math.pow( ( 1 + r ), ( dateArray[i].getValue() - d1.getValue() ) / 365 ) );
} }
return new cNumber( res ); return new cNumber( res );
......
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