@ashray.mehta/statement-converter 1.4.2 → 1.4.3
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.
- package/helpers/NumberUtil.d.ts +1 -0
- package/helpers/NumberUtil.js +12 -1
- package/package.json +1 -1
package/helpers/NumberUtil.d.ts
CHANGED
package/helpers/NumberUtil.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NumberUtil = void 0;
|
|
4
4
|
const multi_number_parse_1 = require("multi-number-parse");
|
|
5
5
|
class NumberUtil {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.commonSeparators = [",", "."];
|
|
8
|
+
}
|
|
6
9
|
parseNumber(text) {
|
|
7
10
|
if (!text) {
|
|
8
11
|
return undefined;
|
|
@@ -11,7 +14,15 @@ class NumberUtil {
|
|
|
11
14
|
if (!trimmedText) {
|
|
12
15
|
return undefined;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
// Remove additional separators as the library seems to fail if they're present. Eg: 2,00,000.00
|
|
18
|
+
var parsableText = trimmedText;
|
|
19
|
+
for (const separator of this.commonSeparators) {
|
|
20
|
+
if (trimmedText.split(separator).length > 2) {
|
|
21
|
+
parsableText = trimmedText.replace(separator, '');
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return (0, multi_number_parse_1.default)(parsableText);
|
|
15
26
|
}
|
|
16
27
|
}
|
|
17
28
|
exports.NumberUtil = NumberUtil;
|