Commit 6eefc236 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fixed:

Bug 25133 - Не рассчитывается формула когда аргумент задан именованным диапазоном
Bug 25152 - Некорректно рассчитывается формула YEARFRAC когда аргумент Basis=1

подправлены юнит тесты для DB


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57080 954022d7-b5bf-4e40-9824-e11837661b57
parent 843f4a1d
...@@ -480,7 +480,7 @@ parserHelper.prototype = { ...@@ -480,7 +480,7 @@ parserHelper.prototype = {
return false; return false;
}, },
isName:function ( formula, start_pos, wb ) { isName:function ( formula, start_pos, wb, ws ) {
if ( this instanceof parserHelper ) { if ( this instanceof parserHelper ) {
this._reset(); this._reset();
} }
...@@ -490,7 +490,7 @@ parserHelper.prototype = { ...@@ -490,7 +490,7 @@ parserHelper.prototype = {
if ( match != null || match != undefined ) { if ( match != null || match != undefined ) {
var name = match["name"]; var name = match["name"];
if ( name && name.length != 0 && wb.DefinedNames && wb.isDefinedNamesExists( name ) ) { if ( name && name.length != 0 && wb.DefinedNames && wb.isDefinedNamesExists( name, ws ? ws.getId() : null ) ) {
this.pCurrPos += name.length; this.pCurrPos += name.length;
this.operand_str = name; this.operand_str = name;
return [ true, name ]; return [ true, name ];
......
...@@ -4465,6 +4465,14 @@ ...@@ -4465,6 +4465,14 @@
function db( cost, salvage, life, period, month ){ function db( cost, salvage, life, period, month ){
if( cost == 0 || salvage == 0 ){
return 0;
}
if ( month < 1 || month > 12 || salvage <= 0 || life <= 0 || period < 0 || life + 1 < period || cost < 0 || cost < salvage ) {
return "#NUM!";
}
var nAbRate = 1 - Math.pow( salvage / cost, 1 / life ); var nAbRate = 1 - Math.pow( salvage / cost, 1 / life );
nAbRate = Math.floor( (nAbRate * 1000) + 0.5 ) / 1000; nAbRate = Math.floor( (nAbRate * 1000) + 0.5 ) / 1000;
var nErsteAbRate = cost * nAbRate * month / 12; var nErsteAbRate = cost * nAbRate * month / 12;
......
...@@ -37,7 +37,7 @@ function yearFrac( d1, d2, mode ) { ...@@ -37,7 +37,7 @@ function yearFrac( d1, d2, mode ) {
case DayCountBasis.UsPsa30_360: case DayCountBasis.UsPsa30_360:
return new cNumber( Math.abs( GetDiffDate360( date1, month1, year1, date2, month2, year2, true ) ) / 360 ); return new cNumber( Math.abs( GetDiffDate360( date1, month1, year1, date2, month2, year2, true ) ) / 360 );
case DayCountBasis.ActualActual: case DayCountBasis.ActualActual:
var yc = /*Math.abs*/( year2 - year1 ), var yc = Math.abs( year2 - year1 ),
sd = year1 > year2 ? new Date( d2 ) : new Date( d1 ), sd = year1 > year2 ? new Date( d2 ) : new Date( d1 ),
yearAverage = sd.isLeapYear() ? 366 : 365, dayDiff = /*Math.abs*/( d2 - d1 ); yearAverage = sd.isLeapYear() ? 366 : 365, dayDiff = /*Math.abs*/( d2 - d1 );
for ( var i = 0; i < yc; i++ ) { for ( var i = 0; i < yc; i++ ) {
...@@ -46,7 +46,7 @@ function yearFrac( d1, d2, mode ) { ...@@ -46,7 +46,7 @@ function yearFrac( d1, d2, mode ) {
} }
yearAverage /= (yc + 1); yearAverage /= (yc + 1);
dayDiff /= (yearAverage * c_msPerDay); dayDiff /= (yearAverage * c_msPerDay);
return new cNumber( dayDiff ); return new cNumber( Math.abs(dayDiff) );
case DayCountBasis.Actual360: case DayCountBasis.Actual360:
var dayDiff = Math.abs( d2 - d1 ); var dayDiff = Math.abs( d2 - d1 );
dayDiff /= (360 * c_msPerDay); dayDiff /= (360 * c_msPerDay);
......
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