mindee 3.3.0 → 3.4.1
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 +14 -0
- package/README.md +6 -1
- package/package.json +19 -19
- package/src/api/index.d.ts +1 -1
- package/src/api/response.d.ts +3 -0
- package/src/client.d.ts +4 -4
- package/src/client.js +1 -1
- package/src/documents/{custom.d.ts → custom/customV1.d.ts} +4 -4
- package/src/documents/{custom.js → custom/customV1.js} +2 -2
- package/src/{fields/apiBuilder.d.ts → documents/custom/fields.d.ts} +8 -6
- package/src/{fields/apiBuilder.js → documents/custom/fields.js} +1 -1
- package/src/documents/document.d.ts +5 -5
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +2 -2
- package/src/documents/eu/licensePlate/licensePlateV1.js +3 -2
- package/src/documents/financialDocument/financialDocumentV1.d.ts +9 -9
- package/src/documents/financialDocument/financialDocumentV1.js +5 -5
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +4 -4
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +3 -3
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +4 -4
- package/src/documents/fr/carteVitale/carteVitaleV1.js +4 -3
- package/src/documents/fr/idCard/idCardV1.d.ts +9 -9
- package/src/documents/fr/idCard/idCardV1.js +8 -8
- package/src/documents/index.d.ts +1 -1
- package/src/documents/index.js +2 -2
- package/src/documents/invoice/invoiceLineItem.d.ts +2 -2
- package/src/documents/invoice/invoiceLineItem.js +2 -2
- package/src/documents/invoice/invoiceV3.d.ts +7 -7
- package/src/documents/invoice/invoiceV3.js +21 -21
- package/src/documents/invoice/invoiceV4.d.ts +8 -8
- package/src/documents/invoice/invoiceV4.js +18 -6
- package/src/documents/invoice/reconstruction.js +5 -4
- package/src/documents/passport/passportV1.d.ts +11 -11
- package/src/documents/passport/passportV1.js +16 -14
- package/src/documents/receipt/receiptV3.d.ts +4 -4
- package/src/documents/receipt/receiptV3.js +6 -7
- package/src/documents/receipt/receiptV4.d.ts +8 -4
- package/src/documents/receipt/receiptV4.js +14 -5
- package/src/documents/receipt/tax.d.ts +3 -3
- package/src/documents/receipt/tax.js +7 -7
- package/src/documents/shipping_container/shippingContainerV1.d.ts +4 -4
- package/src/documents/shipping_container/shippingContainerV1.js +4 -3
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +5 -5
- package/src/documents/us/bankCheck/bankCheckV1.js +4 -4
- package/src/fields/amount.d.ts +1 -1
- package/src/fields/amount.js +7 -4
- package/src/fields/base.d.ts +27 -0
- package/src/fields/base.js +53 -0
- package/src/fields/companyRegistration.d.ts +3 -1
- package/src/fields/date.d.ts +4 -1
- package/src/fields/date.js +16 -8
- package/src/fields/field.d.ts +8 -38
- package/src/fields/field.js +6 -53
- package/src/fields/fullText.d.ts +3 -3
- package/src/fields/fullText.js +4 -4
- package/src/fields/index.d.ts +3 -3
- package/src/fields/index.js +5 -8
- package/src/fields/locale.d.ts +13 -9
- package/src/fields/locale.js +4 -3
- package/src/fields/orientation.d.ts +3 -1
- package/src/fields/orientation.js +2 -2
- package/src/fields/paymentDetails.d.ts +4 -1
- package/src/fields/paymentDetails.js +26 -23
- package/src/fields/position.d.ts +2 -2
- package/src/fields/tax.d.ts +4 -3
- package/src/fields/tax.js +2 -2
- package/src/fields/text.d.ts +13 -0
- package/src/fields/text.js +10 -0
- package/src/geometry.d.ts +4 -5
- package/src/index.d.ts +4 -3
- package/src/index.js +5 -1
- package/src/inputs/sources.d.ts +4 -4
- package/src/inputs/sources.js +9 -9
|
@@ -12,6 +12,22 @@ const fields_1 = require("../../fields");
|
|
|
12
12
|
const checks_1 = require("./checks");
|
|
13
13
|
const reconstruction_1 = require("./reconstruction");
|
|
14
14
|
class InvoiceV3 extends document_1.Document {
|
|
15
|
+
/** The total amount without the tax value. */
|
|
16
|
+
get totalExcl() {
|
|
17
|
+
return this.totalNet;
|
|
18
|
+
}
|
|
19
|
+
/** The total amount without the tax value. */
|
|
20
|
+
set totalExcl(value) {
|
|
21
|
+
this.totalNet = value;
|
|
22
|
+
}
|
|
23
|
+
/** The total amount with tax included. */
|
|
24
|
+
get totalIncl() {
|
|
25
|
+
return this.totalAmount;
|
|
26
|
+
}
|
|
27
|
+
/** The total amount with tax included. */
|
|
28
|
+
set totalIncl(value) {
|
|
29
|
+
this.totalAmount = value;
|
|
30
|
+
}
|
|
15
31
|
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
16
32
|
super({
|
|
17
33
|
inputSource: inputSource,
|
|
@@ -33,22 +49,6 @@ class InvoiceV3 extends document_1.Document {
|
|
|
33
49
|
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_checklist).call(this);
|
|
34
50
|
__classPrivateFieldGet(this, _InvoiceV3_instances, "m", _InvoiceV3_reconstruct).call(this);
|
|
35
51
|
}
|
|
36
|
-
/** The total amount without the tax value. */
|
|
37
|
-
get totalExcl() {
|
|
38
|
-
return this.totalNet;
|
|
39
|
-
}
|
|
40
|
-
/** The total amount without the tax value. */
|
|
41
|
-
set totalExcl(value) {
|
|
42
|
-
this.totalNet = value;
|
|
43
|
-
}
|
|
44
|
-
/** The total amount with tax included. */
|
|
45
|
-
get totalIncl() {
|
|
46
|
-
return this.totalAmount;
|
|
47
|
-
}
|
|
48
|
-
/** The total amount with tax included. */
|
|
49
|
-
set totalIncl(value) {
|
|
50
|
-
this.totalAmount = value;
|
|
51
|
-
}
|
|
52
52
|
toString() {
|
|
53
53
|
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
54
54
|
const paymentDetails = this.paymentDetails
|
|
@@ -129,23 +129,23 @@ _InvoiceV3_instances = new WeakSet(), _InvoiceV3_initFromApiPrediction = functio
|
|
|
129
129
|
prediction: apiPrediction.due_date,
|
|
130
130
|
pageId: pageId,
|
|
131
131
|
});
|
|
132
|
-
this.invoiceNumber = new fields_1.
|
|
132
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
133
133
|
prediction: apiPrediction.invoice_number,
|
|
134
134
|
pageId: pageId,
|
|
135
135
|
});
|
|
136
|
-
this.supplier = new fields_1.
|
|
136
|
+
this.supplier = new fields_1.TextField({
|
|
137
137
|
prediction: apiPrediction.supplier,
|
|
138
138
|
pageId: pageId,
|
|
139
139
|
});
|
|
140
|
-
this.supplierAddress = new fields_1.
|
|
140
|
+
this.supplierAddress = new fields_1.TextField({
|
|
141
141
|
prediction: apiPrediction.supplier_address,
|
|
142
142
|
pageId: pageId,
|
|
143
143
|
});
|
|
144
|
-
this.customerName = new fields_1.
|
|
144
|
+
this.customerName = new fields_1.TextField({
|
|
145
145
|
prediction: apiPrediction.customer,
|
|
146
146
|
pageId: pageId,
|
|
147
147
|
});
|
|
148
|
-
this.customerAddress = new fields_1.
|
|
148
|
+
this.customerAddress = new fields_1.TextField({
|
|
149
149
|
prediction: apiPrediction.customer_address,
|
|
150
150
|
pageId: pageId,
|
|
151
151
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { TaxField, PaymentDetails, Locale, Amount,
|
|
2
|
+
import { TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration, BaseField } from "../../fields";
|
|
3
3
|
import { InvoiceLineItem } from "./invoiceLineItem";
|
|
4
4
|
export declare class InvoiceV4 extends Document {
|
|
5
5
|
#private;
|
|
@@ -7,32 +7,32 @@ export declare class InvoiceV4 extends Document {
|
|
|
7
7
|
locale: Locale;
|
|
8
8
|
/** The nature of the invoice. */
|
|
9
9
|
documentType: BaseField;
|
|
10
|
+
/** List of Reference numbers including PO number. */
|
|
11
|
+
referenceNumbers: TextField[];
|
|
10
12
|
/** The total amount with tax included. */
|
|
11
13
|
totalAmount: Amount;
|
|
12
14
|
/** The creation date of the invoice. */
|
|
13
15
|
date: DateField;
|
|
14
16
|
/** The due date of the invoice. */
|
|
15
17
|
dueDate: DateField;
|
|
16
|
-
/** The created time of the invoice */
|
|
17
|
-
time: Field;
|
|
18
18
|
/** The total tax. */
|
|
19
19
|
totalTax: Amount;
|
|
20
20
|
/** The total amount without the tax value. */
|
|
21
21
|
totalNet: Amount;
|
|
22
22
|
/** The supplier name. */
|
|
23
|
-
supplierName:
|
|
23
|
+
supplierName: TextField;
|
|
24
24
|
/** The supplier address. */
|
|
25
|
-
supplierAddress:
|
|
25
|
+
supplierAddress: TextField;
|
|
26
26
|
/** The payment information. */
|
|
27
27
|
supplierPaymentDetails: PaymentDetails[];
|
|
28
28
|
/** The supplier company regitration information. */
|
|
29
29
|
supplierCompanyRegistrations: CompanyRegistration[];
|
|
30
30
|
/** The invoice number. */
|
|
31
|
-
invoiceNumber:
|
|
31
|
+
invoiceNumber: TextField;
|
|
32
32
|
/** The name of the customer. */
|
|
33
|
-
customerName:
|
|
33
|
+
customerName: TextField;
|
|
34
34
|
/** The address of the customer. */
|
|
35
|
-
customerAddress:
|
|
35
|
+
customerAddress: TextField;
|
|
36
36
|
/** The company registration information for the customer. */
|
|
37
37
|
customerCompanyRegistrations: CompanyRegistration[];
|
|
38
38
|
/** The list of the taxes. */
|
|
@@ -22,6 +22,8 @@ class InvoiceV4 extends document_1.Document {
|
|
|
22
22
|
extras: extras,
|
|
23
23
|
});
|
|
24
24
|
_InvoiceV4_instances.add(this);
|
|
25
|
+
/** List of Reference numbers including PO number. */
|
|
26
|
+
this.referenceNumbers = [];
|
|
25
27
|
/** The payment information. */
|
|
26
28
|
this.supplierPaymentDetails = [];
|
|
27
29
|
/** The supplier company regitration information. */
|
|
@@ -38,6 +40,9 @@ class InvoiceV4 extends document_1.Document {
|
|
|
38
40
|
}
|
|
39
41
|
toString() {
|
|
40
42
|
const taxes = this.taxes.map((item) => item.toString()).join("\n ");
|
|
43
|
+
const referenceNumbers = this.referenceNumbers
|
|
44
|
+
.map((item) => item.toString())
|
|
45
|
+
.join(", ");
|
|
41
46
|
const paymentDetails = this.supplierPaymentDetails
|
|
42
47
|
.map((item) => item.toString())
|
|
43
48
|
.join("\n ");
|
|
@@ -50,13 +55,14 @@ class InvoiceV4 extends document_1.Document {
|
|
|
50
55
|
let lineItems = "\n";
|
|
51
56
|
if (this.lineItems.length > 0) {
|
|
52
57
|
lineItems =
|
|
53
|
-
"\n Code | QTY | Price | Amount | Tax (Rate)
|
|
58
|
+
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
54
59
|
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
55
60
|
}
|
|
56
61
|
const outStr = `----- Invoice V4 -----
|
|
57
62
|
Filename: ${this.filename}
|
|
58
63
|
Locale: ${this.locale}
|
|
59
64
|
Invoice number: ${this.invoiceNumber}
|
|
65
|
+
Reference numbers: ${referenceNumbers}
|
|
60
66
|
Invoice date: ${this.date}
|
|
61
67
|
Invoice due date: ${this.dueDate}
|
|
62
68
|
Supplier name: ${this.supplierName}
|
|
@@ -86,6 +92,12 @@ _InvoiceV4_instances = new WeakSet(), _InvoiceV4_initFromApiPrediction = functio
|
|
|
86
92
|
prediction: apiPrediction.document_type,
|
|
87
93
|
valueKey: "value",
|
|
88
94
|
});
|
|
95
|
+
this.referenceNumbers = apiPrediction.reference_numbers.map(function (prediction) {
|
|
96
|
+
return new fields_1.TextField({
|
|
97
|
+
prediction: prediction,
|
|
98
|
+
pageId: pageId,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
89
101
|
this.totalAmount = new fields_1.Amount({
|
|
90
102
|
prediction: apiPrediction.total_amount,
|
|
91
103
|
valueKey: "value",
|
|
@@ -123,23 +135,23 @@ _InvoiceV4_instances = new WeakSet(), _InvoiceV4_initFromApiPrediction = functio
|
|
|
123
135
|
prediction: apiPrediction.due_date,
|
|
124
136
|
pageId: pageId,
|
|
125
137
|
});
|
|
126
|
-
this.invoiceNumber = new fields_1.
|
|
138
|
+
this.invoiceNumber = new fields_1.TextField({
|
|
127
139
|
prediction: apiPrediction.invoice_number,
|
|
128
140
|
pageId: pageId,
|
|
129
141
|
});
|
|
130
|
-
this.supplierName = new fields_1.
|
|
142
|
+
this.supplierName = new fields_1.TextField({
|
|
131
143
|
prediction: apiPrediction.supplier_name,
|
|
132
144
|
pageId: pageId,
|
|
133
145
|
});
|
|
134
|
-
this.supplierAddress = new fields_1.
|
|
146
|
+
this.supplierAddress = new fields_1.TextField({
|
|
135
147
|
prediction: apiPrediction.supplier_address,
|
|
136
148
|
pageId: pageId,
|
|
137
149
|
});
|
|
138
|
-
this.customerName = new fields_1.
|
|
150
|
+
this.customerName = new fields_1.TextField({
|
|
139
151
|
prediction: apiPrediction.customer_name,
|
|
140
152
|
pageId: pageId,
|
|
141
153
|
});
|
|
142
|
-
this.customerAddress = new fields_1.
|
|
154
|
+
this.customerAddress = new fields_1.TextField({
|
|
143
155
|
prediction: apiPrediction.customer_address,
|
|
144
156
|
pageId: pageId,
|
|
145
157
|
});
|
|
@@ -8,7 +8,7 @@ function reconstructTotalTax(document) {
|
|
|
8
8
|
value: document.taxes.reduce((acc, tax) => {
|
|
9
9
|
return tax.value !== undefined ? acc + tax.value : acc;
|
|
10
10
|
}, 0),
|
|
11
|
-
confidence: fields_1.
|
|
11
|
+
confidence: fields_1.TextField.arrayConfidence(document.taxes),
|
|
12
12
|
};
|
|
13
13
|
if (totalTax.value > 0)
|
|
14
14
|
document.totalTax = new fields_1.Amount({
|
|
@@ -45,8 +45,8 @@ function reconstructTotalExcl(document) {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const totalExcl = {
|
|
48
|
-
value: document.totalAmount.value - fields_1.
|
|
49
|
-
confidence: fields_1.
|
|
48
|
+
value: document.totalAmount.value - fields_1.TextField.arraySum(document.taxes),
|
|
49
|
+
confidence: fields_1.TextField.arrayConfidence(document.taxes) *
|
|
50
50
|
document.totalAmount.confidence,
|
|
51
51
|
};
|
|
52
52
|
document.totalNet = new fields_1.Amount({
|
|
@@ -65,7 +65,8 @@ function reconstructTotalIncl(document) {
|
|
|
65
65
|
document.taxes.reduce((acc, tax) => {
|
|
66
66
|
return tax.value ? acc + tax.value : acc;
|
|
67
67
|
}, 0.0),
|
|
68
|
-
confidence: fields_1.
|
|
68
|
+
confidence: fields_1.TextField.arrayConfidence(document.taxes) *
|
|
69
|
+
document.totalNet.confidence,
|
|
69
70
|
};
|
|
70
71
|
document.totalAmount = new fields_1.Amount({
|
|
71
72
|
prediction: totalIncl,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import {
|
|
2
|
+
import { DateField, TextField } from "../../fields";
|
|
3
3
|
export declare class PassportV1 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** The country of issue. */
|
|
6
|
-
country:
|
|
6
|
+
country: TextField;
|
|
7
7
|
/** The passport number. */
|
|
8
|
-
idNumber:
|
|
8
|
+
idNumber: TextField;
|
|
9
9
|
/** The date of birth of the passport holder. */
|
|
10
10
|
birthDate: DateField;
|
|
11
11
|
/** The expiration date of the passport. */
|
|
@@ -13,21 +13,21 @@ export declare class PassportV1 extends Document {
|
|
|
13
13
|
/** The issuance date.*/
|
|
14
14
|
issuanceDate: DateField;
|
|
15
15
|
/** The place of birth of the passport holder. */
|
|
16
|
-
birthPlace:
|
|
16
|
+
birthPlace: TextField;
|
|
17
17
|
/** The sex or gender of the passport holder. */
|
|
18
|
-
gender:
|
|
18
|
+
gender: TextField;
|
|
19
19
|
/** The surname of the person. */
|
|
20
|
-
surname:
|
|
20
|
+
surname: TextField;
|
|
21
21
|
/** The value of the first mrz line. */
|
|
22
|
-
mrz1:
|
|
22
|
+
mrz1: TextField;
|
|
23
23
|
/** The value of the second mrz line. */
|
|
24
|
-
mrz2:
|
|
24
|
+
mrz2: TextField;
|
|
25
25
|
/** List of first (given) names of the passport holder. */
|
|
26
|
-
givenNames:
|
|
26
|
+
givenNames: TextField[];
|
|
27
27
|
/** The full name of the passport holder. */
|
|
28
|
-
fullName:
|
|
28
|
+
fullName: TextField;
|
|
29
29
|
/** All the mrz values combined. */
|
|
30
|
-
mrz:
|
|
30
|
+
mrz: TextField;
|
|
31
31
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
32
32
|
static convertMRZDateToDatetime(dateString: string): Date;
|
|
33
33
|
toString(): string;
|
|
@@ -32,7 +32,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.PassportV1 = void 0;
|
|
33
33
|
const document_1 = require("../document");
|
|
34
34
|
const fields_1 = require("../../fields");
|
|
35
|
-
// @ts-ignore
|
|
36
35
|
const MRZ = __importStar(require("mrz"));
|
|
37
36
|
class PassportV1 extends document_1.Document {
|
|
38
37
|
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
|
|
@@ -45,11 +44,11 @@ class PassportV1 extends document_1.Document {
|
|
|
45
44
|
_PassportV1_instances.add(this);
|
|
46
45
|
/** List of first (given) names of the passport holder. */
|
|
47
46
|
this.givenNames = [];
|
|
48
|
-
this.country = new fields_1.
|
|
47
|
+
this.country = new fields_1.TextField({
|
|
49
48
|
prediction: prediction.country,
|
|
50
49
|
pageId: pageId,
|
|
51
50
|
});
|
|
52
|
-
this.idNumber = new fields_1.
|
|
51
|
+
this.idNumber = new fields_1.TextField({
|
|
53
52
|
prediction: prediction.id_number,
|
|
54
53
|
pageId: pageId,
|
|
55
54
|
});
|
|
@@ -65,27 +64,27 @@ class PassportV1 extends document_1.Document {
|
|
|
65
64
|
prediction: prediction.issuance_date,
|
|
66
65
|
pageId: pageId,
|
|
67
66
|
});
|
|
68
|
-
this.birthPlace = new fields_1.
|
|
67
|
+
this.birthPlace = new fields_1.TextField({
|
|
69
68
|
prediction: prediction.birth_place,
|
|
70
69
|
pageId: pageId,
|
|
71
70
|
});
|
|
72
|
-
this.gender = new fields_1.
|
|
71
|
+
this.gender = new fields_1.TextField({
|
|
73
72
|
prediction: prediction.gender,
|
|
74
73
|
pageId: pageId,
|
|
75
74
|
});
|
|
76
|
-
this.surname = new fields_1.
|
|
75
|
+
this.surname = new fields_1.TextField({
|
|
77
76
|
prediction: prediction.surname,
|
|
78
77
|
pageId: pageId,
|
|
79
78
|
});
|
|
80
|
-
this.mrz1 = new fields_1.
|
|
79
|
+
this.mrz1 = new fields_1.TextField({
|
|
81
80
|
prediction: prediction.mrz1,
|
|
82
81
|
pageId: pageId,
|
|
83
82
|
});
|
|
84
|
-
this.mrz2 = new fields_1.
|
|
83
|
+
this.mrz2 = new fields_1.TextField({
|
|
85
84
|
prediction: prediction.mrz2,
|
|
86
85
|
pageId: pageId,
|
|
87
86
|
});
|
|
88
|
-
prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.
|
|
87
|
+
prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.TextField({
|
|
89
88
|
prediction: prediction,
|
|
90
89
|
pageId: pageId,
|
|
91
90
|
})));
|
|
@@ -101,7 +100,7 @@ class PassportV1 extends document_1.Document {
|
|
|
101
100
|
return new Date(year, month - 1, day, 0, 0, 0, 0);
|
|
102
101
|
}
|
|
103
102
|
toString() {
|
|
104
|
-
const outStr = `-----Passport
|
|
103
|
+
const outStr = `----- Passport V1 -----
|
|
105
104
|
Filename: ${this.filename}
|
|
106
105
|
Full name: ${this.fullName}
|
|
107
106
|
Given names: ${this.givenNames.map((name) => name.value).join(" ")}
|
|
@@ -179,9 +178,12 @@ MRZ: ${this.mrz}
|
|
|
179
178
|
this.givenNames[0].value) {
|
|
180
179
|
const fullName = {
|
|
181
180
|
value: `${this.givenNames[0].value} ${this.surname.value}`,
|
|
182
|
-
confidence: fields_1.
|
|
181
|
+
confidence: fields_1.TextField.arrayConfidence([
|
|
182
|
+
this.surname,
|
|
183
|
+
this.givenNames[0],
|
|
184
|
+
]),
|
|
183
185
|
};
|
|
184
|
-
return new fields_1.
|
|
186
|
+
return new fields_1.TextField({
|
|
185
187
|
prediction: fullName,
|
|
186
188
|
pageId: pageNumber,
|
|
187
189
|
reconstructed: true,
|
|
@@ -192,9 +194,9 @@ MRZ: ${this.mrz}
|
|
|
192
194
|
if (this.mrz1.value && this.mrz2.value) {
|
|
193
195
|
const mrz = {
|
|
194
196
|
value: `${this.mrz1.value}${this.mrz2.value}`,
|
|
195
|
-
confidence: fields_1.
|
|
197
|
+
confidence: fields_1.TextField.arrayConfidence([this.mrz1, this.mrz2]),
|
|
196
198
|
};
|
|
197
|
-
return new fields_1.
|
|
199
|
+
return new fields_1.TextField({
|
|
198
200
|
prediction: mrz,
|
|
199
201
|
pageId: pageNumber,
|
|
200
202
|
reconstructed: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { TaxField,
|
|
2
|
+
import { TaxField, TextField, Amount, Locale, DateField } from "../../fields";
|
|
3
3
|
export declare class ReceiptV3 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Total amount with the tax amount of the purchase. */
|
|
@@ -9,11 +9,11 @@ export declare class ReceiptV3 extends Document {
|
|
|
9
9
|
/** The purchase date. */
|
|
10
10
|
date: DateField;
|
|
11
11
|
/** The type of purchase. */
|
|
12
|
-
category:
|
|
12
|
+
category: TextField;
|
|
13
13
|
/** Merchant's name as seen on the receipt. */
|
|
14
|
-
merchantName:
|
|
14
|
+
merchantName: TextField;
|
|
15
15
|
/** Time as seen on the receipt in HH:MM format. */
|
|
16
|
-
time:
|
|
16
|
+
time: TextField;
|
|
17
17
|
/** Total tax amount of the purchase. */
|
|
18
18
|
totalTax: Amount;
|
|
19
19
|
/** Total amount without tax of the purchase. */
|
|
@@ -23,7 +23,6 @@ class ReceiptV3 extends document_1.Document {
|
|
|
23
23
|
this.taxes = [];
|
|
24
24
|
this.locale = new fields_1.Locale({
|
|
25
25
|
prediction: prediction.locale,
|
|
26
|
-
pageId: pageId,
|
|
27
26
|
});
|
|
28
27
|
this.totalTax = new fields_1.Amount({
|
|
29
28
|
prediction: { value: undefined, confidence: 0 },
|
|
@@ -68,15 +67,15 @@ _ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = functio
|
|
|
68
67
|
prediction: apiPrediction.date,
|
|
69
68
|
pageId: pageId,
|
|
70
69
|
});
|
|
71
|
-
this.category = new fields_1.
|
|
70
|
+
this.category = new fields_1.TextField({
|
|
72
71
|
prediction: apiPrediction.category,
|
|
73
72
|
pageId: pageId,
|
|
74
73
|
});
|
|
75
|
-
this.merchantName = new fields_1.
|
|
74
|
+
this.merchantName = new fields_1.TextField({
|
|
76
75
|
prediction: apiPrediction.supplier,
|
|
77
76
|
pageId: pageId,
|
|
78
77
|
});
|
|
79
|
-
this.time = new fields_1.
|
|
78
|
+
this.time = new fields_1.TextField({
|
|
80
79
|
prediction: apiPrediction.time,
|
|
81
80
|
pageId: pageId,
|
|
82
81
|
});
|
|
@@ -124,8 +123,8 @@ _ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = functio
|
|
|
124
123
|
}, _ReceiptV3_reconstructTotalExclFromTCCAndTaxes = function _ReceiptV3_reconstructTotalExclFromTCCAndTaxes() {
|
|
125
124
|
if (this.taxes.length && this.totalIncl.value !== undefined) {
|
|
126
125
|
const totalExcl = {
|
|
127
|
-
value: this.totalIncl.value - fields_1.
|
|
128
|
-
confidence: fields_1.
|
|
126
|
+
value: this.totalIncl.value - fields_1.TextField.arraySum(this.taxes),
|
|
127
|
+
confidence: fields_1.TextField.arrayConfidence(this.taxes) *
|
|
129
128
|
this.totalIncl.confidence,
|
|
130
129
|
};
|
|
131
130
|
this.totalExcl = new fields_1.Amount({
|
|
@@ -140,7 +139,7 @@ _ReceiptV3_instances = new WeakSet(), _ReceiptV3_initFromApiPrediction = functio
|
|
|
140
139
|
value: this.taxes
|
|
141
140
|
.map((tax) => tax.value || 0)
|
|
142
141
|
.reduce((a, b) => a + b, 0),
|
|
143
|
-
confidence: fields_1.
|
|
142
|
+
confidence: fields_1.TextField.arrayConfidence(this.taxes),
|
|
144
143
|
};
|
|
145
144
|
if (totalTax.value > 0)
|
|
146
145
|
this.totalTax = new fields_1.Amount({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { Amount, DateField,
|
|
2
|
+
import { Amount, DateField, TextField, Locale, TaxField } from "../../fields";
|
|
3
3
|
export declare class ReceiptV4 extends Document {
|
|
4
4
|
#private;
|
|
5
5
|
/** Where the purchase was made, the language, and the currency. */
|
|
@@ -7,11 +7,15 @@ export declare class ReceiptV4 extends Document {
|
|
|
7
7
|
/** The purchase date. */
|
|
8
8
|
date: DateField;
|
|
9
9
|
/** The type of purchase. */
|
|
10
|
-
category:
|
|
10
|
+
category: TextField;
|
|
11
|
+
/** The receipt sub category among predefined classes. */
|
|
12
|
+
subCategory: TextField;
|
|
13
|
+
/** The receipt document type provdes the information whether the document is an expense receipt or a credit card receipt. */
|
|
14
|
+
documentType: TextField;
|
|
11
15
|
/** Merchant's name as seen on the receipt. */
|
|
12
|
-
supplier:
|
|
16
|
+
supplier: TextField;
|
|
13
17
|
/** Time as seen on the receipt in HH:MM format. */
|
|
14
|
-
time:
|
|
18
|
+
time: TextField;
|
|
15
19
|
/** List of taxes detected on the receipt. */
|
|
16
20
|
taxes: TaxField[];
|
|
17
21
|
/** Total amount of tip and gratuity. */
|
|
@@ -33,6 +33,8 @@ Total net: ${this.totalNet}
|
|
|
33
33
|
Tip: ${this.tip}
|
|
34
34
|
Date: ${this.date}
|
|
35
35
|
Category: ${this.category}
|
|
36
|
+
Subcategory: ${this.subCategory}
|
|
37
|
+
Document type: ${this.documentType}
|
|
36
38
|
Time: ${this.time}
|
|
37
39
|
Supplier name: ${this.supplier}
|
|
38
40
|
Taxes: ${taxes}
|
|
@@ -47,7 +49,6 @@ exports.ReceiptV4 = ReceiptV4;
|
|
|
47
49
|
_ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = function _ReceiptV4_initFromApiPrediction(apiPrediction, pageId) {
|
|
48
50
|
this.locale = new fields_1.Locale({
|
|
49
51
|
prediction: apiPrediction.locale,
|
|
50
|
-
pageId: pageId,
|
|
51
52
|
});
|
|
52
53
|
this.totalTax = new fields_1.Amount({
|
|
53
54
|
prediction: apiPrediction.total_tax,
|
|
@@ -73,15 +74,23 @@ _ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = functio
|
|
|
73
74
|
prediction: apiPrediction.date,
|
|
74
75
|
pageId: pageId,
|
|
75
76
|
});
|
|
76
|
-
this.category = new fields_1.
|
|
77
|
+
this.category = new fields_1.TextField({
|
|
77
78
|
prediction: apiPrediction.category,
|
|
78
79
|
pageId: pageId,
|
|
79
80
|
});
|
|
80
|
-
this.
|
|
81
|
+
this.subCategory = new fields_1.TextField({
|
|
82
|
+
prediction: apiPrediction.subcategory,
|
|
83
|
+
pageId: pageId,
|
|
84
|
+
});
|
|
85
|
+
this.documentType = new fields_1.TextField({
|
|
86
|
+
prediction: apiPrediction.document_type,
|
|
87
|
+
pageId: pageId,
|
|
88
|
+
});
|
|
89
|
+
this.supplier = new fields_1.TextField({
|
|
81
90
|
prediction: apiPrediction.supplier,
|
|
82
91
|
pageId: pageId,
|
|
83
92
|
});
|
|
84
|
-
this.time = new fields_1.
|
|
93
|
+
this.time = new fields_1.TextField({
|
|
85
94
|
prediction: apiPrediction.time,
|
|
86
95
|
pageId: pageId,
|
|
87
96
|
});
|
|
@@ -91,6 +100,6 @@ _ReceiptV4_instances = new WeakSet(), _ReceiptV4_initFromApiPrediction = functio
|
|
|
91
100
|
valueKey: "value",
|
|
92
101
|
rateKey: "rate",
|
|
93
102
|
codeKey: "code",
|
|
94
|
-
|
|
103
|
+
baseKey: "base",
|
|
95
104
|
})));
|
|
96
105
|
};
|
|
@@ -4,13 +4,13 @@ interface ReceiptTaxConstructor {
|
|
|
4
4
|
valueKey?: string;
|
|
5
5
|
rateKey?: string;
|
|
6
6
|
codeKey?: string;
|
|
7
|
-
|
|
7
|
+
baseKey?: string;
|
|
8
8
|
reconstructed?: boolean;
|
|
9
9
|
pageId?: number;
|
|
10
10
|
}
|
|
11
11
|
export declare class ReceiptTaxField extends TaxField {
|
|
12
12
|
/** The tax base */
|
|
13
|
-
|
|
13
|
+
base?: number;
|
|
14
14
|
/**
|
|
15
15
|
* @param {Object} prediction - Prediction object from HTTP response
|
|
16
16
|
* @param {String} valueKey - Key to use in the prediction dict to get the tax value
|
|
@@ -19,7 +19,7 @@ export declare class ReceiptTaxField extends TaxField {
|
|
|
19
19
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
20
20
|
* @param {Integer} pageNumber - Page ID for multi-page document
|
|
21
21
|
*/
|
|
22
|
-
constructor({ prediction, valueKey, rateKey, codeKey,
|
|
22
|
+
constructor({ prediction, valueKey, rateKey, codeKey, baseKey, reconstructed, pageId, }: ReceiptTaxConstructor);
|
|
23
23
|
toString(): string;
|
|
24
24
|
}
|
|
25
25
|
export {};
|
|
@@ -12,13 +12,13 @@ class ReceiptTaxField extends fields_1.TaxField {
|
|
|
12
12
|
* @param {Boolean} reconstructed - Does the object is reconstructed (not extracted by the API)
|
|
13
13
|
* @param {Integer} pageNumber - Page ID for multi-page document
|
|
14
14
|
*/
|
|
15
|
-
constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code",
|
|
15
|
+
constructor({ prediction, valueKey = "value", rateKey = "rate", codeKey = "code", baseKey = "base", reconstructed = false, pageId = undefined, }) {
|
|
16
16
|
super({ prediction, valueKey, rateKey, codeKey, reconstructed, pageId });
|
|
17
17
|
/** The tax base */
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
if (isNaN(this.
|
|
21
|
-
this.
|
|
18
|
+
this.base = undefined;
|
|
19
|
+
this.base = parseFloat(prediction[baseKey]);
|
|
20
|
+
if (isNaN(this.base))
|
|
21
|
+
this.base = undefined;
|
|
22
22
|
}
|
|
23
23
|
toString() {
|
|
24
24
|
let outStr = "";
|
|
@@ -31,8 +31,8 @@ class ReceiptTaxField extends fields_1.TaxField {
|
|
|
31
31
|
if (this.code !== undefined) {
|
|
32
32
|
outStr += ` ${this.code}`;
|
|
33
33
|
}
|
|
34
|
-
if (this.
|
|
35
|
-
outStr += ` ${this.
|
|
34
|
+
if (this.base !== undefined) {
|
|
35
|
+
outStr += ` ${this.base}`;
|
|
36
36
|
}
|
|
37
37
|
return outStr.trim();
|
|
38
38
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import {
|
|
2
|
+
import { TextField } from "../../fields";
|
|
3
3
|
export declare class ShippingContainerV1 extends Document {
|
|
4
4
|
/** ISO 6346 code for container owner prefix + equipment identifier. */
|
|
5
|
-
owner:
|
|
5
|
+
owner: TextField;
|
|
6
6
|
/** ISO 6346 code for container serial number (6+1 digits). */
|
|
7
|
-
serialNumber:
|
|
7
|
+
serialNumber: TextField;
|
|
8
8
|
/** ISO 6346 code for container length, height and type. */
|
|
9
|
-
sizeType:
|
|
9
|
+
sizeType: TextField;
|
|
10
10
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
11
11
|
toString(): string;
|
|
12
12
|
}
|
|
@@ -11,21 +11,22 @@ class ShippingContainerV1 extends document_1.Document {
|
|
|
11
11
|
orientation: orientation,
|
|
12
12
|
extras: extras,
|
|
13
13
|
});
|
|
14
|
-
this.owner = new fields_1.
|
|
14
|
+
this.owner = new fields_1.TextField({
|
|
15
15
|
prediction: prediction.owner,
|
|
16
16
|
pageId: pageId,
|
|
17
17
|
});
|
|
18
|
-
this.serialNumber = new fields_1.
|
|
18
|
+
this.serialNumber = new fields_1.TextField({
|
|
19
19
|
prediction: prediction.serial_number,
|
|
20
20
|
pageId: pageId,
|
|
21
21
|
});
|
|
22
|
-
this.sizeType = new fields_1.
|
|
22
|
+
this.sizeType = new fields_1.TextField({
|
|
23
23
|
prediction: prediction.size_type,
|
|
24
24
|
pageId: pageId,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
toString() {
|
|
28
28
|
const outStr = `----- Shipping Container V1 -----
|
|
29
|
+
Filename: ${this.filename}
|
|
29
30
|
Owner: ${this.owner}
|
|
30
31
|
Serial number: ${this.serialNumber}
|
|
31
32
|
Size and type: ${this.sizeType}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Document, DocumentConstructorProps } from "../../document";
|
|
2
|
-
import {
|
|
2
|
+
import { TextField, DateField, PositionField, Amount } from "../../../fields";
|
|
3
3
|
export declare class BankCheckV1 extends Document {
|
|
4
4
|
/** Payer's bank account number. */
|
|
5
|
-
accountNumber:
|
|
5
|
+
accountNumber: TextField;
|
|
6
6
|
/** Total including taxes. */
|
|
7
7
|
amount: Amount;
|
|
8
8
|
/** Payer's bank account number. */
|
|
9
|
-
checkNumber:
|
|
9
|
+
checkNumber: TextField;
|
|
10
10
|
/** Check's position in the image. */
|
|
11
11
|
checkPosition: PositionField;
|
|
12
12
|
/** Date the check was issued. */
|
|
13
13
|
issuanceDate: DateField;
|
|
14
14
|
/** List of payees (full name or company name). */
|
|
15
|
-
payees:
|
|
15
|
+
payees: TextField[];
|
|
16
16
|
/** Payer's bank account routing number. */
|
|
17
|
-
routingNumber:
|
|
17
|
+
routingNumber: TextField;
|
|
18
18
|
/** Signatures' positions in the image. */
|
|
19
19
|
signaturesPositions: PositionField;
|
|
20
20
|
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|