mindee 1.3.2 → 2.0.0

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.
Files changed (161) hide show
  1. package/CHANGELOG.md +47 -18
  2. package/README.md +43 -127
  3. package/bin/mindee +3 -0
  4. package/dist/package.json +70 -0
  5. package/dist/src/api/endpoint.d.ts +29 -0
  6. package/dist/src/api/endpoint.js +148 -0
  7. package/dist/src/api/index.d.ts +2 -0
  8. package/dist/src/api/index.js +18 -0
  9. package/dist/src/api/response.d.ts +52 -0
  10. package/dist/src/api/response.js +107 -0
  11. package/dist/src/cli.d.ts +1 -0
  12. package/dist/src/cli.js +117 -0
  13. package/dist/src/client.d.ts +48 -0
  14. package/dist/src/client.js +134 -0
  15. package/dist/src/constants.d.ts +13 -0
  16. package/dist/src/constants.js +54 -0
  17. package/dist/src/documents/custom.d.ts +14 -0
  18. package/dist/src/documents/custom.js +48 -0
  19. package/dist/src/documents/document.d.ts +38 -0
  20. package/dist/{documents → src/documents}/document.js +15 -35
  21. package/dist/src/documents/documentConfig.d.ts +44 -0
  22. package/dist/src/documents/documentConfig.js +121 -0
  23. package/dist/src/documents/financialDocument.d.ts +32 -0
  24. package/dist/src/documents/financialDocument.js +130 -0
  25. package/dist/src/documents/index.d.ts +12 -0
  26. package/dist/src/documents/index.js +20 -0
  27. package/dist/src/documents/invoice.d.ts +37 -0
  28. package/dist/src/documents/invoice.js +303 -0
  29. package/dist/src/documents/passport.d.ts +36 -0
  30. package/dist/src/documents/passport.js +218 -0
  31. package/dist/src/documents/receipt.d.ts +24 -0
  32. package/dist/src/documents/receipt.js +157 -0
  33. package/dist/src/errors/handler.d.ts +7 -0
  34. package/dist/{errors → src/errors}/handler.js +5 -4
  35. package/dist/src/fields/amount.d.ts +13 -0
  36. package/dist/{documents → src}/fields/amount.js +19 -6
  37. package/dist/src/fields/companyRegistration.d.ts +6 -0
  38. package/dist/src/fields/companyRegistration.js +11 -0
  39. package/dist/src/fields/customDocs.d.ts +42 -0
  40. package/dist/src/fields/customDocs.js +61 -0
  41. package/dist/src/fields/date.d.ts +12 -0
  42. package/dist/src/fields/date.js +25 -0
  43. package/dist/src/fields/field.d.ts +74 -0
  44. package/dist/{documents → src}/fields/field.js +48 -27
  45. package/dist/src/fields/fullText.d.ts +24 -0
  46. package/dist/src/fields/fullText.js +89 -0
  47. package/dist/src/fields/index.d.ts +11 -0
  48. package/dist/src/fields/index.js +27 -0
  49. package/dist/src/fields/locale.d.ts +13 -0
  50. package/dist/{documents → src}/fields/locale.js +20 -5
  51. package/dist/src/fields/orientation.d.ts +10 -0
  52. package/dist/{documents → src}/fields/orientation.js +5 -5
  53. package/dist/src/fields/paymentDetails.d.ts +31 -0
  54. package/dist/{documents → src}/fields/paymentDetails.js +14 -6
  55. package/dist/src/fields/tax.d.ts +30 -0
  56. package/dist/src/fields/tax.js +51 -0
  57. package/dist/src/geometry.d.ts +59 -0
  58. package/dist/src/geometry.js +113 -0
  59. package/dist/src/index.d.ts +2 -0
  60. package/dist/src/index.js +12 -0
  61. package/dist/src/inputs.d.ts +69 -0
  62. package/dist/src/inputs.js +223 -0
  63. package/dist/src/logger.d.ts +20 -0
  64. package/dist/src/logger.js +35 -0
  65. package/package.json +45 -26
  66. package/.eslintrc +0 -24
  67. package/.mocharc.yaml +0 -2
  68. package/.nyc_output/f57ba3bc-1777-4ecc-81e1-230327c2a401.json +0 -1
  69. package/.nyc_output/processinfo/f57ba3bc-1777-4ecc-81e1-230327c2a401.json +0 -1
  70. package/.nyc_output/processinfo/index.json +0 -1
  71. package/.prettierrc +0 -4
  72. package/.tool-versions +0 -1
  73. package/CODE_OF_CONDUCT.md +0 -63
  74. package/CONTRIBUTING.md +0 -84
  75. package/ISSUE_TEMPLATE.md +0 -45
  76. package/PULL_REQUEST_TEMPLATE.md +0 -45
  77. package/babel.config.json +0 -10
  78. package/coverage/coverage.json +0 -1
  79. package/coverage/lcov-report/base.css +0 -224
  80. package/coverage/lcov-report/block-navigation.js +0 -79
  81. package/coverage/lcov-report/favicon.png +0 -0
  82. package/coverage/lcov-report/index.html +0 -171
  83. package/coverage/lcov-report/prettify.css +0 -1
  84. package/coverage/lcov-report/prettify.js +0 -2
  85. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  86. package/coverage/lcov-report/sorter.js +0 -170
  87. package/coverage/lcov.info +0 -1595
  88. package/coverage.lcov +0 -1595
  89. package/dist/api/financialDocument.js +0 -51
  90. package/dist/api/index.js +0 -13
  91. package/dist/api/invoice.js +0 -59
  92. package/dist/api/object.js +0 -80
  93. package/dist/api/receipt.js +0 -45
  94. package/dist/api/request.js +0 -90
  95. package/dist/api/response.js +0 -91
  96. package/dist/documents/fields/date.js +0 -17
  97. package/dist/documents/fields/index.js +0 -17
  98. package/dist/documents/fields/tax.js +0 -42
  99. package/dist/documents/financialDocument.js +0 -216
  100. package/dist/documents/index.js +0 -13
  101. package/dist/documents/invoice.js +0 -361
  102. package/dist/documents/receipt.js +0 -231
  103. package/dist/index.js +0 -23
  104. package/dist/inputs.js +0 -208
  105. package/dist/logger.js +0 -34
  106. package/examples/.env.example +0 -2
  107. package/examples/documents/invoices/credit_note.pdf +0 -900
  108. package/examples/documents/invoices/invoice.pdf +0 -0
  109. package/examples/documents/invoices/invoice_6p.pdf +0 -0
  110. package/examples/documents/receipts/receipt.jpg +0 -0
  111. package/examples/financialDocument.js +0 -32
  112. package/examples/invoice.js +0 -74
  113. package/examples/receipt.js +0 -45
  114. package/lib/api/financialDocument.js +0 -59
  115. package/lib/api/index.js +0 -7
  116. package/lib/api/invoice.js +0 -73
  117. package/lib/api/object.js +0 -90
  118. package/lib/api/receipt.js +0 -58
  119. package/lib/api/request.js +0 -84
  120. package/lib/api/response.js +0 -92
  121. package/lib/documents/document.js +0 -97
  122. package/lib/documents/fields/amount.js +0 -35
  123. package/lib/documents/fields/date.js +0 -36
  124. package/lib/documents/fields/field.js +0 -102
  125. package/lib/documents/fields/index.js +0 -9
  126. package/lib/documents/fields/locale.js +0 -35
  127. package/lib/documents/fields/orientation.js +0 -33
  128. package/lib/documents/fields/paymentDetails.js +0 -71
  129. package/lib/documents/fields/tax.js +0 -57
  130. package/lib/documents/financialDocument.js +0 -280
  131. package/lib/documents/index.js +0 -7
  132. package/lib/documents/invoice.js +0 -451
  133. package/lib/documents/receipt.js +0 -332
  134. package/lib/errors/handler.js +0 -19
  135. package/lib/index.js +0 -40
  136. package/lib/inputs.js +0 -190
  137. package/lib/logger.js +0 -52
  138. package/mindee/api/financialDocument.js +0 -47
  139. package/mindee/api/index.js +0 -5
  140. package/mindee/api/invoice.js +0 -53
  141. package/mindee/api/object.js +0 -82
  142. package/mindee/api/receipt.js +0 -39
  143. package/mindee/api/request.js +0 -72
  144. package/mindee/api/response.js +0 -80
  145. package/mindee/documents/document.js +0 -69
  146. package/mindee/documents/fields/amount.js +0 -25
  147. package/mindee/documents/fields/date.js +0 -29
  148. package/mindee/documents/fields/field.js +0 -86
  149. package/mindee/documents/fields/index.js +0 -7
  150. package/mindee/documents/fields/locale.js +0 -30
  151. package/mindee/documents/fields/orientation.js +0 -24
  152. package/mindee/documents/fields/paymentDetails.js +0 -52
  153. package/mindee/documents/fields/tax.js +0 -47
  154. package/mindee/documents/financialDocument.js +0 -269
  155. package/mindee/documents/index.js +0 -5
  156. package/mindee/documents/invoice.js +0 -456
  157. package/mindee/documents/receipt.js +0 -287
  158. package/mindee/errors/handler.js +0 -16
  159. package/mindee/index.js +0 -36
  160. package/mindee/inputs.js +0 -158
  161. package/mindee/logger.js +0 -33
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
9
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
-
11
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
-
13
- var fs = require("fs").promises;
14
-
15
- class Document {
16
- /**
17
- * Takes a list of Documents and return one Document where
18
- * each field is set with the maximum probability field
19
- * @param {Input} inputFile - input file given to parse the document
20
- */
21
- constructor() {
22
- var inputFile = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
23
- this.filepath = undefined;
24
- this.filename = undefined;
25
- this.fileExtension = undefined;
26
-
27
- if (inputFile != undefined) {
28
- this.filepath = inputFile.filepath;
29
- this.filename = inputFile.filename;
30
- this.fileExtension = inputFile.fileExtension;
31
- }
32
-
33
- this.checklist = {};
34
- }
35
-
36
- clone() {
37
- return JSON.parse(JSON.stringify(this));
38
- }
39
- /** return true if all checklist of the document if true */
40
-
41
-
42
- checkAll() {
43
- return this.checklist.every(item => item == true);
44
- }
45
- /** Export document into a JSON file */
46
-
47
-
48
- dump(path) {
49
- var _this = this;
50
-
51
- return _asyncToGenerator(function* () {
52
- return yield fs.writeFile(path, JSON.stringify(Object.entries(_this)));
53
- })();
54
- }
55
- /** Create a Document from a JSON file */
56
-
57
-
58
- static load(path) {
59
- return _asyncToGenerator(function* () {
60
- var file = fs.readFile(path);
61
- var args = JSON.parse(file);
62
- return new Document(_objectSpread({
63
- reconsctruted: true
64
- }, args));
65
- })();
66
- }
67
- /**
68
- * Takes a list of Documents and return one Document where
69
- * each field is set with the maximum probability field
70
- * @param {Array<Document>} documents - A list of Documents
71
- */
72
-
73
-
74
- static mergePages(documents) {
75
- var finalDocument = documents[0].clone();
76
- var attributes = Object.getOwnPropertyNames(finalDocument);
77
-
78
- for (var document of documents) {
79
- for (var attribute of attributes) {
80
- var _document$attribute;
81
-
82
- if (Array.isArray(document === null || document === void 0 ? void 0 : document[attribute])) {
83
- var _finalDocument$attrib;
84
-
85
- finalDocument[attribute] = (_finalDocument$attrib = finalDocument[attribute]) !== null && _finalDocument$attrib !== void 0 && _finalDocument$attrib.length ? finalDocument[attribute] : document === null || document === void 0 ? void 0 : document[attribute];
86
- } else if ((document === null || document === void 0 ? void 0 : (_document$attribute = document[attribute]) === null || _document$attribute === void 0 ? void 0 : _document$attribute.probability) > finalDocument[attribute].probability) {
87
- finalDocument[attribute] = document === null || document === void 0 ? void 0 : document[attribute];
88
- }
89
- }
90
- }
91
-
92
- return finalDocument;
93
- }
94
-
95
- }
96
-
97
- module.exports = Document;
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- var Field = require("./field");
4
-
5
- class Amount extends Field {
6
- /**
7
- * @param {Object} prediction - Prediction object from HTTP response
8
- * @param {String} valueKey - Key to use in the prediction dict
9
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
10
- * @param {Integer} pageNumber - Page number for multi pages pdf
11
- */
12
- constructor(_ref) {
13
- var {
14
- prediction,
15
- valueKey = "amount",
16
- reconstructed = false,
17
- pageNumber = 0
18
- } = _ref;
19
- super({
20
- prediction,
21
- valueKey,
22
- reconstructed,
23
- pageNumber
24
- });
25
- this.value = +parseFloat(prediction[valueKey]).toFixed(3);
26
-
27
- if (isNaN(this.value)) {
28
- this.value = undefined;
29
- this.probability = 0;
30
- }
31
- }
32
-
33
- }
34
-
35
- module.exports = Amount;
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var Field = require("./field");
4
-
5
- class DateField extends Field {
6
- /**
7
- * @param {Object} prediction - Prediction object from HTTP response
8
- * @param {String} valueKey - Key to use in the prediction dict
9
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
10
- * @param {Integer} pageNumber - Page number for multi pages pdf
11
- */
12
- constructor(_ref) {
13
- var {
14
- prediction,
15
- valueKey = "iso",
16
- reconstructed = false,
17
- pageNumber = 0
18
- } = _ref;
19
- super({
20
- prediction,
21
- valueKey,
22
- reconstructed,
23
- pageNumber
24
- });
25
- this.dateObject = new Date(this.value);
26
-
27
- if (!(this.dateObject instanceof Date) || isNaN(this.dateObject.valueOf())) {
28
- this.dateObject = undefined;
29
- this.probability = 0.0;
30
- this.value = undefined;
31
- }
32
- }
33
-
34
- }
35
-
36
- module.exports = DateField;
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- class Field {
4
- /**
5
- * @param {Object} prediction - Prediction object from HTTP response
6
- * @param {String} valueKey - Key to use in the prediction dict
7
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
8
- * @param {Integer} pageNumber - Page number for multi pages pdf
9
- * @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
10
- */
11
- constructor(_ref) {
12
- var {
13
- prediction,
14
- valueKey = "value",
15
- reconstructed = false,
16
- extraFields,
17
- pageNumber
18
- } = _ref;
19
- this.pageNumber = pageNumber;
20
- this.reconstructed = reconstructed;
21
- this.value = undefined;
22
- this.probability = 0.0;
23
- this.bbox = [];
24
-
25
- if (valueKey in prediction && prediction[valueKey] !== null) {
26
- this.value = prediction[valueKey];
27
- if (prediction.probability) this.probability = prediction.probability;
28
- if (prediction.segmentation) this.bbox = prediction.segmentation.bounding_box || [];
29
-
30
- if (extraFields) {
31
- for (var fieldName of extraFields) {
32
- this[fieldName] = prediction[fieldName];
33
- }
34
- }
35
- }
36
- }
37
-
38
- compare(other) {
39
- if (this.value == null && other.value == null) return true;else if (this.value == null || other.value == null) return false;else {
40
- if (typeof this.value == "string") {
41
- return this.value.toLowerCase() === other.value.toLowerCase();
42
- } else {
43
- return this.value === other.value;
44
- }
45
- }
46
- }
47
- /**
48
- @param {Array<Field>} array1 - first Array of Fields
49
- @param {Array<Field>} array2 - second Array of Fields
50
- @param {String} attr - Attribute to compare
51
- @returns {Boolean} - true if all elements in array1 exist in array2 and vice-versa, false otherwise
52
- */
53
-
54
-
55
- static compareArrays(array1, array2) {
56
- var attr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "value";
57
- var list1 = array1.map(item => item[attr]);
58
- var list2 = array2.map(item => item[attr]);
59
- if (list1.length !== list2.length) return false;
60
-
61
- for (var item1 of list1) {
62
- if (!list2.includes(item1)) return false;
63
- }
64
-
65
- return true;
66
- }
67
- /**
68
- * @param {Array<Field>} array - Array of Fields
69
- * @returns {Number} product of all the fields probaility
70
- */
71
-
72
-
73
- static arrayProbability(array) {
74
- var total = 1.0;
75
-
76
- for (var field of array) {
77
- total *= field.probability;
78
- if (isNaN(total)) return 0.0;
79
- }
80
-
81
- return total;
82
- }
83
- /**
84
- * @param {Array<Field>} array - Array of Fields
85
- * @returns {Number} Sum of all the Fields values in the array
86
- */
87
-
88
-
89
- static arraySum(array) {
90
- var total = 0;
91
-
92
- for (var field of array) {
93
- total += field.value;
94
- if (isNaN(total)) return 0.0;
95
- }
96
-
97
- return total;
98
- }
99
-
100
- }
101
-
102
- module.exports = Field;
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- exports.field = require("./field");
4
- exports.date = require("./date");
5
- exports.amount = require("./amount");
6
- exports.locale = require("./locale");
7
- exports.orientation = require("./orientation");
8
- exports.paymentDetails = require("./paymentDetails");
9
- exports.tax = require("./tax.js");
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- var Field = require("./field");
4
-
5
- class Locale extends Field {
6
- /**
7
- * @param {Object} prediction - Prediction object from HTTP response
8
- * @param {String} valueKey - Key to use in the prediction dict
9
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
10
- * @param {Integer} pageNumber - Page number for multi pages pdf
11
- */
12
- constructor(_ref) {
13
- var {
14
- prediction,
15
- valueKey = "value",
16
- reconstructed = false,
17
- pageNumber = 0
18
- } = _ref;
19
- super({
20
- prediction,
21
- valueKey,
22
- reconstructed,
23
- pageNumber
24
- });
25
- this.language = undefined;
26
- this.country = undefined;
27
- this.currency = undefined;
28
- if ("language" in prediction && prediction.language !== "N/A") this.language = prediction.language;
29
- if ("country" in prediction && prediction.country !== "N/A") this.country = prediction.country;
30
- if ("currency" in prediction && prediction.currency !== "N/A") this.currency = prediction.currency;
31
- }
32
-
33
- }
34
-
35
- module.exports = Locale;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var Field = require("./field");
4
-
5
- class Orientation extends Field {
6
- /**
7
- * @param {Object} prediction - Prediction object from HTTP response
8
- * @param {String} valueKey - Key to use in the prediction dict
9
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
10
- * @param {Integer} pageNumber - Page number for multi pages pdf
11
- */
12
- constructor(_ref) {
13
- var {
14
- prediction,
15
- valueKey = "degrees",
16
- reconstructed = false,
17
- pageNumber = 0
18
- } = _ref;
19
- var orientations = [0, 90, 180, 270];
20
- super({
21
- prediction,
22
- valueKey,
23
- reconstructed,
24
- pageNumber
25
- });
26
- this.value = parseInt(prediction[valueKey]);
27
- if (isNaN(this.value)) this.probability = 0.0;
28
- if (!orientations.includes(this.value)) this.value = 0;
29
- }
30
-
31
- }
32
-
33
- module.exports = Orientation;
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
4
-
5
- var Field = require("./field");
6
-
7
- var _setKey = new WeakSet();
8
-
9
- class PaymentDetails extends Field {
10
- /**
11
- * @param {Object} prediction - Prediction object from HTTP response
12
- * @param {String} valueKey - Key to use in the prediction dict to get the iban
13
- * @param {String} accountNumberKey - Key to use to get the account number in the prediction dict
14
- * @param {String} ibanKey - Key to use to get the IBAN in the prediction dict
15
- * @param {String} routingNumberKey - Key to use to get the routing number in the prediction dict
16
- * @param {String} swiftKey - Key to use to get the SWIFT in the prediction dict
17
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
18
- * @param {Integer} pageNumber - Page number for multi pages pdf
19
- */
20
- constructor(_ref) {
21
- var {
22
- prediction,
23
- valueKey = "iban",
24
- accountNumberKey = "account_number",
25
- ibanKey = "iban",
26
- routingNumberKey = "routing_number",
27
- swiftKey = "swift",
28
- reconstructed = false,
29
- pageNumber = 0
30
- } = _ref;
31
- super({
32
- prediction,
33
- valueKey,
34
- reconstructed,
35
- pageNumber
36
- });
37
-
38
- _setKey.add(this);
39
-
40
- this.accountNumber = undefined;
41
- this.iban = undefined;
42
- this.routingNumber = undefined;
43
- this.swift = undefined;
44
-
45
- _classPrivateMethodGet(this, _setKey, _setKey2).call(this, prediction[accountNumberKey], "accountNumber");
46
-
47
- _classPrivateMethodGet(this, _setKey, _setKey2).call(this, prediction[ibanKey], "iban");
48
-
49
- _classPrivateMethodGet(this, _setKey, _setKey2).call(this, prediction[routingNumberKey], "routingNumber");
50
-
51
- _classPrivateMethodGet(this, _setKey, _setKey2).call(this, prediction[swiftKey], "swift");
52
- }
53
-
54
- toString() {
55
- var str = "";
56
- var keys = ["accountNumber", "iban", "routingNumber", "swift"];
57
-
58
- for (var key of keys) {
59
- if (this[key]) str += "".concat(this[key], "; ");
60
- }
61
-
62
- return str;
63
- }
64
-
65
- }
66
-
67
- var _setKey2 = function _setKey2(value, key) {
68
- if (typeof value === "string" && value !== "N/A") this[key] = value;else this[key] = undefined;
69
- };
70
-
71
- module.exports = PaymentDetails;
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- var Field = require("./field");
4
-
5
- class Tax extends Field {
6
- /**
7
- * @param {Object} prediction - Prediction object from HTTP response
8
- * @param {String} valueKey - Key to use in the prediction dict to get the tax value
9
- * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
10
- * @param {String} codeKey - Key to use to get the tax code in the prediction dict
11
- * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
12
- * @param {Integer} pageNumber - Page number for multi pages pdf
13
- */
14
- constructor(_ref) {
15
- var _prediction$codeKey;
16
-
17
- var {
18
- prediction,
19
- valueKey = "value",
20
- rateKey = "rate",
21
- codeKey = "code",
22
- reconstructed = false,
23
- pageNumber = 0
24
- } = _ref;
25
- super({
26
- prediction,
27
- valueKey,
28
- reconstructed,
29
- pageNumber
30
- });
31
- this.rate = parseFloat(prediction[rateKey]);
32
- if (isNaN(this.rate)) this.rate = undefined;
33
- this.code = (_prediction$codeKey = prediction[codeKey]) === null || _prediction$codeKey === void 0 ? void 0 : _prediction$codeKey.toString();
34
- if (this.code === "N/A") this.code = undefined;
35
- this.value = parseFloat(prediction[valueKey]);
36
-
37
- if (isNaN(this.value)) {
38
- this.value = undefined;
39
- this.probability = 0.0;
40
- }
41
- }
42
-
43
- toString() {
44
- var str = "";
45
- var keys = ["value", "rate", "code"];
46
-
47
- for (var [i, key] of keys.entries()) {
48
- var value = this[key] === undefined ? "_" : this[key].toString();
49
- if (i < keys.length - 1) str += "".concat(value).concat(key === "rate" ? "%" : "", "; ");else str += value;
50
- }
51
-
52
- return str;
53
- }
54
-
55
- }
56
-
57
- module.exports = Tax;