mindee 1.0.4 → 1.0.9

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 (48) hide show
  1. package/.nyc_output/f57ba3bc-1777-4ecc-81e1-230327c2a401.json +1 -0
  2. package/.nyc_output/processinfo/f57ba3bc-1777-4ecc-81e1-230327c2a401.json +1 -0
  3. package/.nyc_output/processinfo/index.json +1 -0
  4. package/CHANGELOG.md +42 -8
  5. package/README.md +1 -1
  6. package/coverage/coverage.json +1 -0
  7. package/coverage/lcov-report/base.css +224 -0
  8. package/coverage/lcov-report/block-navigation.js +79 -0
  9. package/coverage/lcov-report/favicon.png +0 -0
  10. package/coverage/lcov-report/index.html +171 -0
  11. package/coverage/lcov-report/prettify.css +1 -0
  12. package/coverage/lcov-report/prettify.js +2 -0
  13. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  14. package/coverage/lcov-report/sorter.js +170 -0
  15. package/coverage/lcov.info +1595 -0
  16. package/coverage.lcov +1595 -0
  17. package/examples/documents/invoices/credit_note.pdf +899 -1
  18. package/examples/invoice.js +17 -0
  19. package/lib/api/financialDocument.js +3 -3
  20. package/lib/api/invoice.js +18 -3
  21. package/lib/api/receipt.js +3 -3
  22. package/lib/api/request.js +7 -3
  23. package/lib/inputs.js +78 -24
  24. package/mindee/api/financialDocument.js +45 -0
  25. package/mindee/api/index.js +5 -0
  26. package/mindee/api/invoice.js +53 -0
  27. package/mindee/api/object.js +82 -0
  28. package/mindee/api/receipt.js +39 -0
  29. package/mindee/api/request.js +67 -0
  30. package/mindee/api/response.js +62 -0
  31. package/mindee/documents/document.js +69 -0
  32. package/mindee/documents/fields/amount.js +25 -0
  33. package/mindee/documents/fields/date.js +29 -0
  34. package/mindee/documents/fields/field.js +89 -0
  35. package/mindee/documents/fields/index.js +7 -0
  36. package/mindee/documents/fields/locale.js +30 -0
  37. package/mindee/documents/fields/orientation.js +24 -0
  38. package/mindee/documents/fields/paymentDetails.js +52 -0
  39. package/mindee/documents/fields/tax.js +47 -0
  40. package/mindee/documents/financialDocument.js +204 -0
  41. package/mindee/documents/index.js +5 -0
  42. package/mindee/documents/invoice.js +395 -0
  43. package/mindee/documents/receipt.js +272 -0
  44. package/mindee/errors/handler.js +16 -0
  45. package/mindee/index.js +36 -0
  46. package/mindee/inputs.js +155 -0
  47. package/mindee/logger.js +33 -0
  48. package/package.json +6 -2
@@ -0,0 +1,69 @@
1
+ const fs = require("fs").promises;
2
+
3
+ class Document {
4
+ /**
5
+ * Takes a list of Documents and return one Document where
6
+ * each field is set with the maximum probability field
7
+ * @param {Input} inputFile - input file given to parse the document
8
+ */
9
+ constructor(inputFile = undefined) {
10
+ this.filepath = undefined;
11
+ this.filename = undefined;
12
+ this.fileExtension = undefined;
13
+
14
+ if (inputFile != undefined) {
15
+ this.filepath = inputFile.filepath;
16
+ this.filename = inputFile.filename;
17
+ this.fileExtension = inputFile.fileExtension;
18
+ }
19
+ this.checklist = {};
20
+ }
21
+
22
+ clone() {
23
+ return JSON.parse(JSON.stringify(this));
24
+ }
25
+
26
+ /** return true if all checklist of the document if true */
27
+ checkAll() {
28
+ return this.checklist.every((item) => item == true);
29
+ }
30
+
31
+ /** Export document into a JSON file */
32
+ async dump(path) {
33
+ return await fs.writeFile(path, JSON.stringify(Object.entries(this)));
34
+ }
35
+
36
+ /** Create a Document from a JSON file */
37
+ static async load(path) {
38
+ const file = fs.readFile(path);
39
+ const args = JSON.parse(file);
40
+ return new Document({ reconsctruted: true, ...args });
41
+ }
42
+
43
+ /**
44
+ * Takes a list of Documents and return one Document where
45
+ * each field is set with the maximum probability field
46
+ * @param {Array<Document>} documents - A list of Documents
47
+ */
48
+ static mergePages(documents) {
49
+ const finalDocument = documents[0].clone();
50
+ const attributes = Object.getOwnPropertyNames(finalDocument);
51
+ for (const document of documents) {
52
+ for (const attribute of attributes) {
53
+ if (Array.isArray(document?.[attribute])) {
54
+ finalDocument[attribute] = finalDocument[attribute]?.length
55
+ ? finalDocument[attribute]
56
+ : document?.[attribute];
57
+ } else if (
58
+ document?.[attribute]?.probability >
59
+ finalDocument[attribute].probability
60
+ ) {
61
+ finalDocument[attribute] = document?.[attribute];
62
+ }
63
+ }
64
+ }
65
+ return finalDocument;
66
+ }
67
+ }
68
+
69
+ module.exports = Document;
@@ -0,0 +1,25 @@
1
+ const Field = require("./field");
2
+
3
+ class Amount extends 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
+ */
10
+ constructor({
11
+ prediction,
12
+ valueKey = "amount",
13
+ reconstructed = false,
14
+ pageNumber = 0,
15
+ }) {
16
+ super({ prediction, valueKey, reconstructed, pageNumber });
17
+ this.value = +parseFloat(prediction[valueKey]).toFixed(3);
18
+ if (isNaN(this.value)) {
19
+ this.value = undefined;
20
+ this.probability = 0;
21
+ }
22
+ }
23
+ }
24
+
25
+ module.exports = Amount;
@@ -0,0 +1,29 @@
1
+ const Field = require("./field");
2
+
3
+ class DateField extends 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
+ */
10
+ constructor({
11
+ prediction,
12
+ valueKey = "iso",
13
+ reconstructed = false,
14
+ pageNumber = 0,
15
+ }) {
16
+ super({ prediction, valueKey, reconstructed, pageNumber });
17
+ this.dateObject = new Date(this.value);
18
+ if (
19
+ !(this.dateObject instanceof Date) ||
20
+ isNaN(this.dateObject.valueOf())
21
+ ) {
22
+ this.dateObject = undefined;
23
+ this.probability = 0.0;
24
+ this.value = undefined;
25
+ }
26
+ }
27
+ }
28
+
29
+ module.exports = DateField;
@@ -0,0 +1,89 @@
1
+ class Field {
2
+ /**
3
+ * @param {Object} prediction - Prediction object from HTTP response
4
+ * @param {String} valueKey - Key to use in the prediction dict
5
+ * @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
6
+ * @param {Integer} pageNumber - Page number for multi pages pdf
7
+ * @param {Array<String>} extraFields - Extra fields to get from the prediction and to set as attribute of the Field
8
+ */
9
+ constructor({
10
+ prediction,
11
+ valueKey = "value",
12
+ reconstructed = false,
13
+ extraFields,
14
+ pageNumber,
15
+ }) {
16
+ this.pageNumber = pageNumber;
17
+ this.reconstructed = reconstructed;
18
+ this.value = undefined;
19
+ this.probability = 0.0;
20
+ this.bbox = [];
21
+ if (valueKey in prediction && prediction[valueKey] !== "N/A") {
22
+ this.value = prediction[valueKey];
23
+ if (prediction.probability) this.probability = prediction.probability;
24
+ if (prediction.segmentation)
25
+ this.bbox = prediction.segmentation.bounding_box || [];
26
+ if (extraFields) {
27
+ for (const fieldName of extraFields) {
28
+ this[fieldName] = prediction[fieldName];
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ compare(other) {
35
+ if (this.value == null && other.value == null) return true;
36
+ else if (this.value == null || other.value == null) return false;
37
+ else {
38
+ if (typeof this.value == "string") {
39
+ return this.value.toLowerCase() === other.value.toLowerCase();
40
+ } else {
41
+ return this.value === other.value;
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ @param {Array<Field>} array1 - first Array of Fields
48
+ @param {Array<Field>} array2 - second Array of Fields
49
+ @param {String} attr - Attribute to compare
50
+ @returns {Boolean} - true if all elements in array1 exist in array2 and vice-versa, false otherwise
51
+ */
52
+ static compareArrays(array1, array2, attr = "value") {
53
+ const list1 = array1.map((item) => item[attr]);
54
+ const list2 = array2.map((item) => item[attr]);
55
+ if (list1.length !== list2.length) return false;
56
+ for (const item1 of list1) {
57
+ if (!list2.includes(item1)) return false;
58
+ }
59
+ return true;
60
+ }
61
+
62
+ /**
63
+ * @param {Array<Field>} array - Array of Fields
64
+ * @returns {Number} product of all the fields probaility
65
+ */
66
+ static arrayProbability(array) {
67
+ let total = 1.0;
68
+ for (const field of array) {
69
+ total *= field.probability;
70
+ if (isNaN(total)) return 0.0;
71
+ }
72
+ return total;
73
+ }
74
+
75
+ /**
76
+ * @param {Array<Field>} array - Array of Fields
77
+ * @returns {Number} Sum of all the Fields values in the array
78
+ */
79
+ static arraySum(array) {
80
+ let total = 0;
81
+ for (const field of array) {
82
+ total += field.value;
83
+ if (isNaN(total)) return 0.0;
84
+ }
85
+ return total;
86
+ }
87
+ }
88
+
89
+ module.exports = Field;
@@ -0,0 +1,7 @@
1
+ exports.field = require("./field");
2
+ exports.date = require("./date");
3
+ exports.amount = require("./amount");
4
+ exports.locale = require("./locale");
5
+ exports.orientation = require("./orientation");
6
+ exports.paymentDetails = require("./paymentDetails");
7
+ exports.tax = require("./tax.js");
@@ -0,0 +1,30 @@
1
+ const Field = require("./field");
2
+
3
+ class Locale extends 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
+ */
10
+ constructor({
11
+ prediction,
12
+ valueKey = "value",
13
+ reconstructed = false,
14
+ pageNumber = 0,
15
+ }) {
16
+ super({ prediction, valueKey, reconstructed, pageNumber });
17
+
18
+ this.language = undefined;
19
+ this.country = undefined;
20
+ this.currency = undefined;
21
+ if ("language" in prediction && prediction.language !== "N/A")
22
+ this.language = prediction.language;
23
+ if ("country" in prediction && prediction.country !== "N/A")
24
+ this.country = prediction.country;
25
+ if ("currency" in prediction && prediction.currency !== "N/A")
26
+ this.currency = prediction.currency;
27
+ }
28
+ }
29
+
30
+ module.exports = Locale;
@@ -0,0 +1,24 @@
1
+ const Field = require("./field");
2
+
3
+ class Orientation extends 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
+ */
10
+ constructor({
11
+ prediction,
12
+ valueKey = "degrees",
13
+ reconstructed = false,
14
+ pageNumber = 0,
15
+ }) {
16
+ const orientations = [0, 90, 180, 270];
17
+ super({ prediction, valueKey, reconstructed, pageNumber });
18
+ this.value = parseInt(prediction[valueKey]);
19
+ if (isNaN(this.value)) this.probability = 0.0;
20
+ if (!orientations.includes(this.value)) this.value = 0;
21
+ }
22
+ }
23
+
24
+ module.exports = Orientation;
@@ -0,0 +1,52 @@
1
+ const Field = require("./field");
2
+
3
+ class PaymentDetails extends Field {
4
+ /**
5
+ * @param {Object} prediction - Prediction object from HTTP response
6
+ * @param {String} valueKey - Key to use in the prediction dict to get the iban
7
+ * @param {String} accountNumberKey - Key to use to get the account number in the prediction dict
8
+ * @param {String} ibanKey - Key to use to get the IBAN in the prediction dict
9
+ * @param {String} routingNumberKey - Key to use to get the routing number in the prediction dict
10
+ * @param {String} swiftKey - Key to use to get the SWIFT 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({
15
+ prediction,
16
+ valueKey = "iban",
17
+ accountNumberKey = "account_number",
18
+ ibanKey = "iban",
19
+ routingNumberKey = "routing_number",
20
+ swiftKey = "swift",
21
+ reconstructed = false,
22
+ pageNumber = 0,
23
+ }) {
24
+ super({ prediction, valueKey, reconstructed, pageNumber });
25
+
26
+ this.accountNumber = undefined;
27
+ this.iban = undefined;
28
+ this.routingNumber = undefined;
29
+ this.swift = undefined;
30
+
31
+ this.#setKey(prediction[accountNumberKey], "accountNumber");
32
+ this.#setKey(prediction[ibanKey], "iban");
33
+ this.#setKey(prediction[routingNumberKey], "routingNumber");
34
+ this.#setKey(prediction[swiftKey], "swift");
35
+ }
36
+
37
+ #setKey(value, key) {
38
+ if (typeof value === "string" && value !== "N/A") this[key] = value;
39
+ else this[key] = undefined;
40
+ }
41
+
42
+ toString() {
43
+ let str = "";
44
+ const keys = ["accountNumber", "iban", "routingNumber", "swift"];
45
+ for (const key of keys) {
46
+ if (this[key]) str += `${this[key]}; `;
47
+ }
48
+ return str;
49
+ }
50
+ }
51
+
52
+ module.exports = PaymentDetails;
@@ -0,0 +1,47 @@
1
+ const Field = require("./field");
2
+
3
+ class Tax extends Field {
4
+ /**
5
+ * @param {Object} prediction - Prediction object from HTTP response
6
+ * @param {String} valueKey - Key to use in the prediction dict to get the tax value
7
+ * @param {String} rateKey - Key to use to get the tax rate in the prediction dict
8
+ * @param {String} codeKey - Key to use to get the tax code 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({
13
+ prediction,
14
+ valueKey = "value",
15
+ rateKey = "rate",
16
+ codeKey = "code",
17
+ reconstructed = false,
18
+ pageNumber = 0,
19
+ }) {
20
+ super({ prediction, valueKey, reconstructed, pageNumber });
21
+
22
+ this.rate = parseFloat(prediction[rateKey]);
23
+ if (isNaN(this.rate)) this.rate = undefined;
24
+
25
+ this.code = prediction[codeKey]?.toString();
26
+ if (this.code === "N/A") this.code = undefined;
27
+
28
+ this.value = parseFloat(prediction[valueKey]);
29
+ if (isNaN(this.value)) {
30
+ this.value = undefined;
31
+ this.probability = 0.0;
32
+ }
33
+ }
34
+
35
+ toString() {
36
+ let str = "";
37
+ const keys = ["value", "rate", "code"];
38
+ for (const [i, key] of keys.entries()) {
39
+ const value = this[key] === undefined ? "_" : this[key].toString();
40
+ if (i < keys.length - 1) str += `${value}${key === "rate" ? "%" : ""}; `;
41
+ else str += value;
42
+ }
43
+ return str;
44
+ }
45
+ }
46
+
47
+ module.exports = Tax;
@@ -0,0 +1,204 @@
1
+ const Document = require("./document");
2
+ const Invoice = require("./invoice");
3
+ const Receipt = require("./receipt");
4
+ const Field = require("./fields").field;
5
+ const Date = require("./fields").date;
6
+ const Amount = require("./fields").amount;
7
+ const Locale = require("./fields").locale;
8
+ const Orientation = require("./fields").orientation;
9
+ const Tax = require("./fields").tax;
10
+
11
+ class FinancialDocument extends Document {
12
+ /**
13
+ * @param {Object} apiPrediction - Json parsed prediction from HTTP response
14
+ * @param {Input} input - Input object
15
+ * @param {Integer} pageNumber - Page number for multi pages pdf input
16
+ * @param {Object} locale - locale value for creating FinancialDocument object from scratch
17
+ * @param {Object} totalIncl - total tax included value for creating FinancialDocument object from scratch
18
+ * @param {Object} totalExcl - total tax excluded value for creating FinancialDocument object from scratch
19
+ * @param {Object} Date - date value for creating FinancialDocument object from scratch
20
+ * @param {Object} InvoiceNumber - Invoice number value for creating FinancialDocument object from scratch
21
+ * @param {Object} taxes - taxes value for creating FinancialDocument object from scratch
22
+ * @param {Object} merchantName - merchant name value for creating FinancialDocument object from scratch
23
+ * @param {Object} paymentDetails - payment details value for creating FinancialDocument object from scratch
24
+ * @param {Object} companyNumber - company number value for creating FinancialDocument object from scratch
25
+ * @param {Object} vatNumber - vat number value for creating FinancialDocument object from scratch
26
+ * @param {Object} orientation - orientation value for creating FinancialDocument object from scratch
27
+ * @param {Object} totalTax - total tax value for creating FinancialDocument object from scratch
28
+ * @param {Object} time - time value for creating FinancialDocument object from scratch
29
+ * @param {Object} pageNumber - pageNumber for multi pages pdf input
30
+ */
31
+ constructor({
32
+ apiPrediction = undefined,
33
+ inputFile = undefined,
34
+ locale = undefined,
35
+ totalIncl = undefined,
36
+ totalExcl = undefined,
37
+ date = undefined,
38
+ invoiceNumber = undefined,
39
+ dueDate = undefined,
40
+ taxes = undefined,
41
+ merchantName = undefined,
42
+ paymentDetails = undefined,
43
+ companyNumber = undefined,
44
+ vatNumber = undefined,
45
+ orientation = undefined,
46
+ totalTax = undefined,
47
+ time = undefined,
48
+ pageNumber = 0,
49
+ }) {
50
+ super(inputFile);
51
+ if (apiPrediction === undefined) {
52
+ this.#initFromScratch({
53
+ locale,
54
+ totalIncl,
55
+ totalExcl,
56
+ date,
57
+ invoiceNumber,
58
+ dueDate,
59
+ taxes,
60
+ merchantName,
61
+ paymentDetails,
62
+ companyNumber,
63
+ vatNumber,
64
+ orientation,
65
+ pageNumber,
66
+ totalTax,
67
+ time,
68
+ });
69
+ } else {
70
+ this.#initFromApiPrediction(apiPrediction, inputFile, pageNumber);
71
+ }
72
+ this.#checklist();
73
+ }
74
+
75
+ #initFromScratch({
76
+ locale,
77
+ totalIncl,
78
+ totalExcl,
79
+ totalTax,
80
+ date,
81
+ invoiceNumber,
82
+ dueDate,
83
+ taxes,
84
+ paymentDetails,
85
+ companyNumber,
86
+ vatNumber,
87
+ orientation,
88
+ pageNumber,
89
+ merchantName,
90
+ time,
91
+ }) {
92
+ const constructPrediction = function (item) {
93
+ return { prediction: { value: item }, valueKey: "value", pageNumber };
94
+ };
95
+ this.locale = new Locale(constructPrediction(locale));
96
+ this.totalIncl = new Amount(constructPrediction(totalIncl));
97
+ this.totalExcl = new Amount(constructPrediction(totalExcl));
98
+ this.totalTax = new Amount(constructPrediction(totalTax));
99
+ this.date = new Date(constructPrediction(date));
100
+ this.dueDate = new Date(constructPrediction(dueDate));
101
+ this.merchantName = new Field(constructPrediction(merchantName));
102
+ this.time = new Field(constructPrediction(time));
103
+ this.orientation = new Orientation(constructPrediction(orientation));
104
+ this.invoiceNumber = new Field(constructPrediction(invoiceNumber));
105
+ this.paymentDetails = new Field(constructPrediction(paymentDetails));
106
+ this.companyNumber = new Field(constructPrediction(companyNumber));
107
+ this.vatNumber = new Field(constructPrediction(vatNumber));
108
+ if (taxes !== undefined) {
109
+ this.taxes = [];
110
+ for (const t of taxes) {
111
+ this.taxes.push(
112
+ new Tax({
113
+ prediction: { value: t[0], rate: t[1] },
114
+ pageNumber,
115
+ valueKey: "value",
116
+ rateKey: "rate",
117
+ })
118
+ );
119
+ }
120
+ }
121
+ }
122
+
123
+ #initFromApiPrediction(apiPrediction, inputFile, pageNumber) {
124
+ if (Object.keys(apiPrediction).includes("invoice_number")) {
125
+ const invoice = new Invoice({ apiPrediction, inputFile, pageNumber });
126
+ Object.assign(this, invoice);
127
+ this.time = new Field({
128
+ prediction: { value: undefined, probability: 0.0 },
129
+ });
130
+ this.merchantName = new Field({
131
+ prediction: { value: undefined, probability: 0.0 },
132
+ });
133
+ } else {
134
+ const receipt = new Receipt({ apiPrediction, inputFile, pageNumber });
135
+ Object.assign(this, receipt);
136
+ this.invoiceDate = new Field({
137
+ prediction: { value: undefined, probability: 0.0 },
138
+ });
139
+ this.invoiceNumber = new Field({
140
+ prediction: { value: undefined, probability: 0.0 },
141
+ });
142
+ this.dueDate = new Field({
143
+ prediction: { value: undefined, probability: 0.0 },
144
+ });
145
+ this.paymentDetails = new Field({
146
+ prediction: { value: undefined, probability: 0.0 },
147
+ });
148
+ this.companyNumber = new Field({
149
+ prediction: { value: undefined, probability: 0.0 },
150
+ });
151
+ }
152
+ }
153
+
154
+ toString() {
155
+ return `
156
+ -----Financial document-----
157
+ Filename: ${this.filename}
158
+ Total amount: ${this.totalIncl.value}
159
+ Date: ${this.date.value}
160
+ Merchant name: ${this.merchantName.value}
161
+ Total taxes: ${this.totalTax.value}
162
+ `;
163
+ }
164
+
165
+ #checklist() {
166
+ this.checklist = {
167
+ taxesMatchTotalIncl: this.#taxesMatchTotalIncl(),
168
+ };
169
+ }
170
+
171
+ #taxesMatchTotalIncl() {
172
+ // Check taxes and total include exist
173
+ if (this.taxes.length === 0 || this.totalIncl.value === undefined)
174
+ return false;
175
+
176
+ // Reconstruct totalIncl from taxes
177
+ let totalVat = 0;
178
+ let reconstructedTotal = 0;
179
+ this.taxes.forEach((tax) => {
180
+ if (tax.value === undefined || !tax.rate) return false;
181
+ totalVat += tax.value;
182
+ reconstructedTotal += tax.value + (100 * tax.value) / tax.rate;
183
+ });
184
+
185
+ // Sanity check
186
+ if (totalVat <= 0) return false;
187
+
188
+ // Crate epsilon
189
+ const eps = 1 / (100 * totalVat);
190
+
191
+ if (
192
+ this.totalIncl.value * (1 - eps) - 0.02 <= reconstructedTotal &&
193
+ reconstructedTotal <= this.totalIncl.value * (1 + eps) + 0.02
194
+ ) {
195
+ this.taxes = this.taxes.map((tax) => ({ ...tax, probability: 1.0 }));
196
+ this.totalTax.probability = 1.0;
197
+ this.totalIncl.probability = 1.0;
198
+ return true;
199
+ }
200
+ return false;
201
+ }
202
+ }
203
+
204
+ module.exports = FinancialDocument;
@@ -0,0 +1,5 @@
1
+ exports.fields = require("./fields");
2
+ exports.document = require("./document");
3
+ exports.receipt = require("./receipt");
4
+ exports.invoice = require("./invoice");
5
+ exports.financialDocument = require("./financialDocument");