Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(currencyFilter): add numbers after dot count parameter #3642

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions i18n/src/converter.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ function convertNumberData(dataObj, currencySymbols) {

if (currencySymbols[dataObj.DEF_CURRENCY_CODE]) {
numberFormats.CURRENCY_SYM = currencySymbols[dataObj.DEF_CURRENCY_CODE][1];
numberFormats.DEFAULT_PRECISION = (currencySymbols[dataObj.DEF_CURRENCY_CODE][0] === 0) ? 0 : 2;
} else {
if (dataObj.DEF_CURRENCY_CODE == 'MTL') {
numberFormats.CURRENCY_SYM = '₤'; //for some reason this is missing in closure
@@ -29,6 +30,7 @@ function convertNumberData(dataObj, currencySymbols) {
var code = numberFormats.CURRENCY_SYM = dataObj.DEF_CURRENCY_CODE;
console.log(code +' has no currency symbol in closure, used ' + code + ' instead!');
}
numberFormats.DEFAULT_PRECISION = 2;
}
return numberFormats;
}
7 changes: 5 additions & 2 deletions src/ng/filter/filters.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
*
* @param {number} amount Input to filter.
* @param {string=} symbol Currency symbol or identifier to be displayed.
* @param {number=} number of digits after dot after rounding.
* @returns {string} Formatted number.
*
*
@@ -44,9 +45,11 @@
currencyFilter.$inject = ['$locale'];
function currencyFilter($locale) {
var formats = $locale.NUMBER_FORMATS;
return function(amount, currencySymbol){
return function(amount, currencySymbol, meanNumbers){
meanNumbers = isNumber(meanNumbers) ? meanNumbers : formats.DEFAULT_PRECISION;
meanNumbers = meanNumbers || 2;
if (isUndefined(currencySymbol)) currencySymbol = formats.CURRENCY_SYM;
return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, 2).
return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, meanNumbers).
replace(/\u00A4/g, currencySymbol);
};
}
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_af-na.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_af-za.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_af.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "R",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_am-et.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "Birr",
"DECIMAL_SEP": ".",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ",",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_am.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "Birr",
"DECIMAL_SEP": ".",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ",",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-001.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-ae.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-bh.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-dz.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-eg.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-iq.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-jo.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-kw.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-lb.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-ly.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-ma.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-om.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-qa.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-sa.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-sd.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-sy.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-tn.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar-ye.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ar.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u00a3",
"DECIMAL_SEP": "\u066b",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u066c",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_bg-bg.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "lev",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_bg.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "lev",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_bn-bd.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u09f3",
"DECIMAL_SEP": ".",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ",",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_bn-in.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u09f3",
"DECIMAL_SEP": ".",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ",",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_bn.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u09f3",
"DECIMAL_SEP": ".",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ",",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ca-ad.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ca-es.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_ca.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_cs-cz.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "K\u010d",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_cs.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "K\u010d",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "\u00a0",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_da-dk.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "kr",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_da.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "kr",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de-at.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de-be.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de-ch.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "CHF",
"DECIMAL_SEP": ".",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": "'",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de-de.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de-li.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de-lu.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_de.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_el-cy.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
1 change: 1 addition & 0 deletions src/ngLocale/angular-locale_el-gr.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ $provide.value("$locale", {
"NUMBER_FORMATS": {
"CURRENCY_SYM": "\u20ac",
"DECIMAL_SEP": ",",
"DEFAULT_PRECISION": 2,
"GROUP_SEP": ".",
"PATTERNS": [
{
Loading