handsontable / handsontable/hyperformula

Should formulas support arg percentages with quotes?

Open
#874 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Impact: Medium
Dominant language
TypeScript
Stars
2.8k
Forks
171
Avg merge
1d 22h
Merged PRs (30d)
7

Description

Description

Here's the RRI function:

    'RRI': {
      method: 'rri',
      parameters: [
        {argumentType: ArgumentTypes.NUMBER, greaterThan: 0},
        {argumentType: ArgumentTypes.NUMBER},
        {argumentType: ArgumentTypes.NUMBER},
      ],
      returnNumberType: NumberType.NUMBER_PERCENT
    },

ArgumentTypes.NUMBER means percentages will not work such as =RRI("2%",3,1).

They should be ArgumentTypes.ANY. However runFunction will not work then as it doesn't parse percentages properly, so a custom one such as sum() does is needed I think.

it('should calculate the correct value with correct arguments and defaults', () => {
    const [engine] = HyperFormula.buildFromArray([
      ['=RRI("1%", 2, 1)', '=RRI(2, 1, 2)', '=RRI(0.1, 2, 1)'],
      ['=RRI(1, -1, -1)', '=RRI(1, -1, 1)', '=RRI(1, 1, -1)'],
    ]);
    expect(engine.getCellValue(adr('A1'))).toBeCloseTo(-1);
  });

Fails.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the RRI function definition and its ArgumentTypes.NUMBER parameters, then trace runFunction and the custom sum() handling mentioned in the issue. Use the provided RRI test case as the regression test; done means quoted percentage arguments such as "2%" calculate correctly without breaking the existing numeric cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.