Commit 1bb5bc46 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov

fixed:

Bug 24833 - Функция SYD рассчитывает данные для отрицательных аргументов Salvage, Life, Per
Bug 24836 - Функция TBILLPRICE рассчитывает данные, когда Maturity позже Settlement более чем на год

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56779 954022d7-b5bf-4e40-9824-e11837661b57
parent bc42f40a
...@@ -5024,8 +5024,9 @@ cSYD.prototype.Calculate = function ( arg ) { ...@@ -5024,8 +5024,9 @@ cSYD.prototype.Calculate = function ( arg ) {
life = life.getValue(); life = life.getValue();
per = per.getValue(); per = per.getValue();
if ( life == 1 || life == 0 ) if ( life == 1 || life <= 0 || cost < 0 || salvage < 0 || per < 0 ){
return this.value = new cError( cErrorType.not_numeric ); return this.value = new cError( cErrorType.not_numeric );
}
var res = 2; var res = 2;
res *= cost - salvage; res *= cost - salvage;
...@@ -5172,24 +5173,26 @@ cTBILLPRICE.prototype.Calculate = function ( arg ) { ...@@ -5172,24 +5173,26 @@ cTBILLPRICE.prototype.Calculate = function ( arg ) {
if ( maturity instanceof cError ) return this.value = maturity; if ( maturity instanceof cError ) return this.value = maturity;
if ( discount instanceof cError ) return this.value = discount; if ( discount instanceof cError ) return this.value = discount;
var nMat = maturity.getValue(); settlement = Math.floor( settlement.getValue() );
nMat++; maturity = Math.floor( maturity.getValue() );
discount = discount.getValue();
var d1 = Date.prototype.getDateFromExcel( settlement.getValue() );
var d2 = Date.prototype.getDateFromExcel( nMat );
var fFraction = yearFrac( d1, d2, 0 );
if ( fFraction - Math.floor( fFraction ) == 0 ) if ( settlement >= maturity || discount <= 0 ){
return this.value = new cError( cErrorType.not_numeric ); return this.value = new cError( cErrorType.not_numeric );
}
var res = 100 * ( 1 - discount.getValue() * fFraction ); var d1 = Date.prototype.getDateFromExcel( settlement ),
d2 = Date.prototype.getDateFromExcel( maturity ),
d3 = new Date(d1);
if ( settlement.getValue() >= maturity.getValue() || discount.getValue() <= 0 ) d3.addYears(1);
if( d2 > d3 ){
return this.value = new cError( cErrorType.not_numeric ); return this.value = new cError( cErrorType.not_numeric );
}
this.value = new cNumber( res ); discount *= diffDate( d1, d2, DayCountBasis.ActualActual );
// this.value.numFormat = 9;
this.value = new cNumber( 100 * ( 1 - discount / 360 ) );
return this.value; return this.value;
}; };
......
...@@ -1684,6 +1684,7 @@ cTEXT.prototype.Calculate = function ( arg ) { ...@@ -1684,6 +1684,7 @@ cTEXT.prototype.Calculate = function ( arg ) {
} }
return this.value = new cString( text ); return this.value = new cString( text );
this.numFormat = this.formatType.noneFormat;
} }
cTEXT.prototype.getInfo = function () { cTEXT.prototype.getInfo = function () {
return { return {
......
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