makeapps-transformer 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,10 +92,19 @@ function generateTable(array, keys) {
92
92
  }
93
93
  function formatValue(item, result, value, currency = '') {
94
94
  switch (item) {
95
- case common_enum_1.default.Currency:
96
- result.text = isNaN(Number(value)) ? value : `${Number(value).toFixed(2)} ${currency}`;
95
+ case common_enum_1.default.Currency: {
96
+ const uVal = String(value || '').replace(/,/, '.');
97
+ if (!isNaN(Number(uVal))) {
98
+ const [, second = undefined] = uVal.split(/[,.]/);
99
+ const length = (second || '00').length;
100
+ result.text = `${Number(uVal).toFixed(length)} ${currency}`;
101
+ }
102
+ else {
103
+ result.text = value;
104
+ }
97
105
  result.alignment = common_enum_1.Position.RIGHT;
98
106
  break;
107
+ }
99
108
  case common_enum_1.default.CurrencyAbs:
100
109
  result.text = isNaN(Number(value))
101
110
  ? value
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "makeapps-transformer",
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
- "version": "1.0.4",
5
+ "version": "1.0.5",
6
6
  "scripts": {
7
7
  "build": "tsc"
8
8
  },
@@ -74,10 +74,19 @@ function formatValue(
74
74
  currency = ''
75
75
  ): void {
76
76
  switch (item) {
77
- case FormatTyp.Currency:
78
- result.text = isNaN(Number(value)) ? (value as string) : `${Number(value).toFixed(2)} ${currency}`;
77
+ case FormatTyp.Currency: {
78
+ const uVal = String(value || '').replace(/,/, '.');
79
+ if (!isNaN(Number(uVal))) {
80
+ const [, second = undefined] = uVal.split(/[,.]/);
81
+ const length = (second || '00').length;
82
+ result.text = `${Number(uVal).toFixed(length)} ${currency}`;
83
+ } else {
84
+ result.text = value as string;
85
+ }
86
+ // result.text = isNaN(Number(value)) ? (value as string) : `${Number(value).toFixed(2)} ${currency}`;
79
87
  result.alignment = Position.RIGHT;
80
88
  break;
89
+ }
81
90
  case FormatTyp.CurrencyAbs:
82
91
  result.text = isNaN(Number(value))
83
92
  ? (value as string)