How to fix currency filter for (negative) values


#1

Example how currency filter works (Canvas 1.0.0):
HTML:

Page:

So instead of ($44,765) canvas shows -$44,765. That’s ok, but chances are client will prefer negative values to be shown in parentheses.

How to fix this:
As for me the easiest way is to change in a canvas application folder \webapps\ … \assets\js\lib.js these values:

to these ones:

Page after fix: :slight_smile:


#2

Hi @eugene,

This is not the recommended way to do it, hacking the js is not supported and will be overwritten next time you upgrade. If you want parenthesis on a dbr use: tm1-format-parenthesis

If you want to format a number you should write your own filter, they are very easy to create in Angular. The example below formats a number using accounting.js which is included in Canvas (the filter and the accounting.js library).

app.filter('formatNumber', function() {
	return function(number, decimals) {
		return accounting.formatNumber(number, decimals);
	};
});

#3

I googled that it was 1.3…1.4 Angular issue only, and other versions has parentheses in currency filter. Anyway I will try create my own filter as well.


#4

I found (parentheses) were in the currency filter in old angular versions. But it look not too hard to create new one filter. I will update this forum as only I create some awesome filter😎