openexchangerates / accounting.js

A lightweight JavaScript library for number, money and currency formatting - fully localisable, zero dependencies.
http://openexchangerates.github.io/accounting.js
MIT License
4.95k stars 532 forks source link

Unformat makes bracket-notation negatives become positives #30

Closed wjcrowcroft closed 12 years ago

wjcrowcroft commented 12 years ago

Not so much a 'bug' as a 'huh?'

If you're formatting negative values with brackets, which is common in financial and accounting scenarios, accounting.unformat should recognise them. Currently:

accounting.unformat( "GBP (53,180.08)" ) // 5318008 (should be -5318008)

But this could definitely get confusing for people if not done properly and requires a pretty solid regular expression and good documentation, otherwise it'll become one of those things that people constantly say "Hey man wtf" because they weren't aware of that behaviour.

wjcrowcroft commented 12 years ago

fixed in latest version