ce icon indicating copy to clipboard operation
ce copied to clipboard

Mask problems with negative sign

Open marcosaso opened this issue 2 years ago • 2 comments

Hi guys,

Thanks for this great lib!!! There is a issue in the formulas when using a negative sign in a currency mask without RED.

Ex.: https://bossanova.uk/jspreadsheet/v4/examples/column-types { type: 'numeric', title:'Price', width:100, mask:'$ #.##,00', decimal:',' },

If you insert a negative value in any cell of "Price column" and try to calculate it in other cell, It will return a NaN value. Like this:

I inserted a new column (G) after the price column and calculeted "price value / 2" : G1 value = -F1/2 G2 value = -F2/2

Captura de Tela 2022-10-03 às 04 57 38

The issue is in the "parseNumber" function that doesn't accept a negative number as a valid number. The fix is in line that checked if number[0] is a valid number:

Captura de Tela 2022-10-03 às 04 49 32

If the Jspreadsheet's developers prefer, I can send a pull request. Regards,

Marcos

marcosaso avatar Oct 03 '22 08:10 marcosaso

Hi,

I think you can send a pull request 😊

Thanks

GBonnaire avatar Oct 18 '22 13:10 GBonnaire

Hi @GBonnaire,

I just did it. Sorry for the long time this took. Merry Christmas!

marcosaso avatar Dec 25 '22 05:12 marcosaso