mindee 1.3.3 → 1.4.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.
- package/CHANGELOG.md +10 -0
- package/mindee/errors/handler.js +1 -1
- package/mindee/index.js +5 -2
- package/mindee/inputs.js +45 -22
- package/mindee/logger.js +8 -7
- package/package.json +13 -4
- package/.eslintrc +0 -24
- package/.mocharc.yaml +0 -2
- package/.nyc_output/f57ba3bc-1777-4ecc-81e1-230327c2a401.json +0 -1
- package/.nyc_output/processinfo/f57ba3bc-1777-4ecc-81e1-230327c2a401.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/.prettierrc +0 -4
- package/.tool-versions +0 -1
- package/CODE_OF_CONDUCT.md +0 -63
- package/CONTRIBUTING.md +0 -84
- package/ISSUE_TEMPLATE.md +0 -45
- package/PULL_REQUEST_TEMPLATE.md +0 -45
- package/babel.config.json +0 -10
- package/coverage/coverage.json +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -171
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov.info +0 -1595
- package/coverage.lcov +0 -1595
- package/dist/api/financialDocument.js +0 -51
- package/dist/api/index.js +0 -13
- package/dist/api/invoice.js +0 -59
- package/dist/api/object.js +0 -80
- package/dist/api/receipt.js +0 -45
- package/dist/api/request.js +0 -90
- package/dist/api/response.js +0 -91
- package/dist/documents/document.js +0 -80
- package/dist/documents/fields/amount.js +0 -21
- package/dist/documents/fields/date.js +0 -17
- package/dist/documents/fields/field.js +0 -85
- package/dist/documents/fields/index.js +0 -17
- package/dist/documents/fields/locale.js +0 -25
- package/dist/documents/fields/orientation.js +0 -22
- package/dist/documents/fields/paymentDetails.js +0 -50
- package/dist/documents/fields/tax.js +0 -42
- package/dist/documents/financialDocument.js +0 -216
- package/dist/documents/index.js +0 -13
- package/dist/documents/invoice.js +0 -361
- package/dist/documents/receipt.js +0 -231
- package/dist/errors/handler.js +0 -17
- package/dist/index.js +0 -23
- package/dist/inputs.js +0 -208
- package/dist/logger.js +0 -34
- package/examples/.env.example +0 -2
- package/examples/documents/invoices/credit_note.pdf +0 -900
- package/examples/documents/invoices/invoice.pdf +0 -0
- package/examples/documents/invoices/invoice_6p.pdf +0 -0
- package/examples/documents/receipts/receipt.jpg +0 -0
- package/examples/financialDocument.js +0 -32
- package/examples/invoice.js +0 -74
- package/examples/receipt.js +0 -45
- package/lib/api/financialDocument.js +0 -59
- package/lib/api/index.js +0 -7
- package/lib/api/invoice.js +0 -73
- package/lib/api/object.js +0 -90
- package/lib/api/receipt.js +0 -58
- package/lib/api/request.js +0 -84
- package/lib/api/response.js +0 -92
- package/lib/documents/document.js +0 -97
- package/lib/documents/fields/amount.js +0 -35
- package/lib/documents/fields/date.js +0 -36
- package/lib/documents/fields/field.js +0 -102
- package/lib/documents/fields/index.js +0 -9
- package/lib/documents/fields/locale.js +0 -35
- package/lib/documents/fields/orientation.js +0 -33
- package/lib/documents/fields/paymentDetails.js +0 -71
- package/lib/documents/fields/tax.js +0 -57
- package/lib/documents/financialDocument.js +0 -280
- package/lib/documents/index.js +0 -7
- package/lib/documents/invoice.js +0 -451
- package/lib/documents/receipt.js +0 -332
- package/lib/errors/handler.js +0 -19
- package/lib/index.js +0 -40
- package/lib/inputs.js +0 -190
- package/lib/logger.js +0 -52
|
@@ -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;
|