@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.
@@ -1,3 +1,4 @@
1
1
  export declare class NumberUtil {
2
+ private readonly commonSeparators;
2
3
  parseNumber(text: string): Number;
3
4
  }
@@ -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
- return (0, multi_number_parse_1.default)(trimmedText);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ashray.mehta/statement-converter",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Library to convert statements from frequently used banks to QIF.",
5
5
  "main": "index.js",
6
6
  "scripts": {