Skip to content

Commit

Permalink
fix(formula): sum get error
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Jan 30, 2024
1 parent 85f368f commit 02886cc
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Big from 'big.js';

import { reverseCompareOperator } from '../../basics/calculate';
import { BooleanValue, ConcatenateType } from '../../basics/common';
import { ErrorType } from '../../basics/error-type';
import { ERROR_TYPE_SET, ErrorType } from '../../basics/error-type';
import { compareToken } from '../../basics/token';
import { compareWithWildcard, isWildcard } from '../utils/compare';
import { ceil, floor, pow, round } from '../utils/math-kit';
Expand Down Expand Up @@ -394,8 +394,10 @@ export class NumberValueObject extends BaseValueObject {
return valueObject.plus(this);
}
const object = this.plusBy(valueObject.getValue());

// = 1 + #NAME? gets #NAME?, = 1 + #VALUE! gets #VALUE!
if (object.isError()) {
return this;
return object;
}

return object;
Expand Down Expand Up @@ -463,6 +465,10 @@ export class NumberValueObject extends BaseValueObject {
override plusBy(value: string | number | boolean): BaseValueObject {
const currentValue = this.getValue();
if (typeof value === 'string') {
// = 1 + #NAME? gets #NAME?, = 1 + #VALUE! gets #VALUE!
if (ERROR_TYPE_SET.has(value as ErrorType)) {
return new ErrorValueObject(value as ErrorType);
}
return new ErrorValueObject(ErrorType.VALUE);
}
if (typeof value === 'number') {
Expand Down

0 comments on commit 02886cc

Please sign in to comment.