ManishLSN / jquery-formatcurrency

Automatically exported from code.google.com/p/jquery-formatcurrency
GNU General Public License v3.0
0 stars 0 forks source link

Issue calling on asNumber on a negative format item #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  Add a negative number and call formatCurrency on it, shows up red and
in parentheses
2.  Try to convert it back to a number with asNumber
3.  Number comes back as positive instead of negative

What is the expected output? What do you see instead?
Expect if it was negative when formatCurrency was called, it should come
back as negative when asNumber is called on the same field

What version of the product are you using? On what operating system?
formatCurrency 1.2, FF 3.0.15, jquery 1.3.2

Please provide any additional information below.
Been trying to patch it myself, but haven't quite figured it out yet.

Original issue reported on code.google.com by keit...@gmail.com on 15 Dec 2009 at 2:34

GoogleCodeExporter commented 8 years ago
Not sure if it's the proper fix or a hack, but my preliminary testing suggests 
that a
solution is possible by adding

   [178] num = num.replace("(", "(-");

immediately before 

   [179] num = num.replace(settings.regex, '');

Original comment by chdr...@yahoo.com on 17 Dec 2009 at 3:14

GoogleCodeExporter commented 8 years ago
Seems to working for me so far, but I made an additional change so that it 
works for
both asNumber and toNumber.

I changed:

[154] var method = $(this).is('input, select, textarea') ? 'val' : 'html';
[155] $(this)[method]($(this)[method]().replace(settings.regex, ''));

to 

var method = $(this).is('input, select, textarea') ? 'val' : 'html';
var num = $(this)[method]();
num = num.replace("(", "(-");
num = num.replace(settings.regex, '');
$(this)[method](num);

Seems you would want to maybe make it part of the core regex statment, but 
seems to
be working so far.  Thanks for the help.

Original comment by keit...@gmail.com on 17 Dec 2009 at 7:05

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Just checked in Unit tests that prove this as valid.  Unfortunately my internet 
connection is spotty I'll resolve the issue shortly based on these tests.

Original comment by bdewe...@hotmail.com on 18 Dec 2009 at 3:39

GoogleCodeExporter commented 8 years ago
This has been fixed in the trunk an will be released with v1.3

Original comment by bdewe...@hotmail.com on 2 Jan 2010 at 4:11

GoogleCodeExporter commented 8 years ago
Leaving accepted until v1.3 is released

Original comment by bdewe...@hotmail.com on 2 Jan 2010 at 4:11

GoogleCodeExporter commented 8 years ago
released with v1.3

Original comment by bdewe...@hotmail.com on 2 Jan 2010 at 4:36