Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion accounting.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@
}

// Clean up number:
number = unformat(number);
if (symbol == "R$") {
number = unformat(number, decimal);
} else {
number = unformat(number);
}

// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
Expand Down
2 changes: 2 additions & 0 deletions tests/qunit/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $(document).ready(function() {
equals(accounting.unformat(1234567890), 1234567890, 'Returns same value when passed an integer');
equals(accounting.unformat("string"), 0, 'Returns 0 for a string with no numbers');
equals(accounting.unformat({joss:1}), 0, 'Returns 0 for object');
equals(accounting.unformat("30.612", "."), 30.612);

accounting.settings.number.decimal = ',';
equals(accounting.unformat("100,00"), 100, 'Uses decimal separator from settings');
Expand Down Expand Up @@ -48,6 +49,7 @@ $(document).ready(function() {
equals(accounting.formatMoney(-500000, "� ", 0), "� -500,000", 'negative values, custom params, works ok');
equals(accounting.formatMoney(5318008, { symbol: "GBP", format: "%v %s" }), "5,318,008.00 GBP", "`format` parameter is observed in string output");
equals(accounting.formatMoney(1000, { format: "test %v 123 %s test" }), "test 1,000.00 123 $ test", "`format` parameter is observed in string output, despite being rather strange");
equals(accounting.formatMoney('30.671', "R$ ", 0, ".", ","), "R$ 30.671", "`decimal` acts as thousands in formatting");

// Format param is an object:
var format = {
Expand Down