mindee 3.10.2 → 4.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.
- package/CHANGELOG.md +19 -0
- package/README.md +103 -41
- package/package.json +6 -6
- package/src/cli.js +96 -70
- package/src/client.d.ts +34 -65
- package/src/client.js +108 -172
- package/src/geometry/boundingBox.d.ts +5 -0
- package/src/geometry/boundingBox.js +2 -0
- package/src/geometry/boundingBoxUtils.d.ts +22 -0
- package/src/geometry/boundingBoxUtils.js +66 -0
- package/src/geometry/index.d.ts +6 -0
- package/src/geometry/index.js +21 -0
- package/src/geometry/minMax.d.ts +4 -0
- package/src/geometry/minMax.js +2 -0
- package/src/geometry/point.d.ts +2 -0
- package/src/geometry/point.js +2 -0
- package/src/geometry/polygon.d.ts +4 -0
- package/src/geometry/polygon.js +7 -0
- package/src/{geometry.d.ts → geometry/polygonUtils.d.ts} +7 -32
- package/src/{geometry.js → geometry/polygonUtils.js} +41 -64
- package/src/http/endpoint.d.ts +44 -0
- package/src/http/endpoint.js +188 -0
- package/src/http/error.d.ts +2 -0
- package/src/http/error.js +9 -0
- package/src/http/index.d.ts +3 -0
- package/src/http/index.js +11 -0
- package/src/http/mindeeApi.d.ts +20 -0
- package/src/http/mindeeApi.js +73 -0
- package/src/index.d.ts +4 -4
- package/src/index.js +33 -26
- package/src/{inputs → input}/base.d.ts +4 -3
- package/src/{inputs → input}/base.js +9 -7
- package/src/{inputs → input}/index.d.ts +1 -1
- package/src/{inputs → input}/index.js +1 -2
- package/src/{inputs → input}/sources.d.ts +10 -11
- package/src/{inputs → input}/sources.js +9 -9
- package/src/parsing/common/apiRequest.d.ts +10 -0
- package/src/parsing/common/apiRequest.js +13 -0
- package/src/parsing/common/apiResponse.d.ts +6 -0
- package/src/parsing/common/apiResponse.js +10 -0
- package/src/parsing/common/asyncPredictResponse.d.ts +21 -0
- package/src/parsing/common/asyncPredictResponse.js +39 -0
- package/src/parsing/common/document.d.ts +13 -0
- package/src/parsing/common/document.js +34 -0
- package/src/parsing/common/extras/cropperExtra.d.ts +8 -0
- package/src/parsing/common/extras/cropperExtra.js +26 -0
- package/src/parsing/common/extras/extras.d.ts +11 -0
- package/src/parsing/common/extras/extras.js +18 -0
- package/src/parsing/common/index.d.ts +9 -0
- package/src/parsing/common/index.js +20 -0
- package/src/parsing/common/inference.d.ts +26 -0
- package/src/parsing/common/inference.js +56 -0
- package/src/parsing/common/mvisionV1.d.ts +8 -0
- package/src/parsing/common/mvisionV1.js +17 -0
- package/src/parsing/common/ocr.d.ts +8 -0
- package/src/parsing/common/ocr.js +13 -0
- package/src/parsing/common/ocrPage.d.ts +16 -0
- package/src/parsing/common/ocrPage.js +66 -0
- package/src/{fields → parsing/common}/orientation.d.ts +2 -2
- package/src/{fields → parsing/common}/orientation.js +4 -4
- package/src/parsing/common/page.d.ts +12 -0
- package/src/parsing/common/page.js +40 -0
- package/src/parsing/common/predictResponse.d.ts +6 -0
- package/src/parsing/common/predictResponse.js +12 -0
- package/src/parsing/common/prediction.d.ts +2 -0
- package/src/parsing/common/prediction.js +6 -0
- package/src/parsing/common/product.d.ts +4 -0
- package/src/parsing/common/product.js +2 -0
- package/src/parsing/common/stringDict.d.ts +3 -0
- package/src/parsing/common/stringDict.js +2 -0
- package/src/parsing/common/summaryHelper.d.ts +8 -0
- package/src/parsing/common/summaryHelper.js +22 -0
- package/src/parsing/custom/classificationField.d.ts +16 -0
- package/src/parsing/custom/classificationField.js +14 -0
- package/src/parsing/custom/index.d.ts +3 -0
- package/src/parsing/custom/index.js +12 -0
- package/src/{documents/custom/lineitems.d.ts → parsing/custom/lineItems.d.ts} +4 -4
- package/src/{documents/custom/lineitems.js → parsing/custom/lineItems.js} +11 -9
- package/src/{documents/custom/fields.d.ts → parsing/custom/listField.d.ts} +3 -16
- package/src/{documents/custom/fields.js → parsing/custom/listField.js} +4 -14
- package/src/parsing/index.d.ts +3 -0
- package/src/parsing/index.js +29 -0
- package/src/{fields → parsing/standard}/amount.d.ts +2 -2
- package/src/{fields → parsing/standard}/amount.js +5 -5
- package/src/{fields → parsing/standard}/base.d.ts +5 -5
- package/src/{fields → parsing/standard}/base.js +3 -2
- package/src/{fields → parsing/standard}/classification.d.ts +1 -1
- package/src/{fields → parsing/standard}/classification.js +3 -3
- package/src/{fields → parsing/standard}/companyRegistration.d.ts +1 -1
- package/src/parsing/standard/companyRegistration.js +14 -0
- package/src/{fields → parsing/standard}/date.d.ts +1 -1
- package/src/{fields → parsing/standard}/date.js +2 -2
- package/src/{fields → parsing/standard}/field.d.ts +3 -4
- package/src/{fields → parsing/standard}/field.js +6 -7
- package/src/parsing/standard/index.d.ts +12 -0
- package/src/parsing/standard/index.js +27 -0
- package/src/{fields → parsing/standard}/locale.d.ts +4 -4
- package/src/parsing/standard/locale.js +42 -0
- package/src/{fields → parsing/standard}/paymentDetails.d.ts +3 -3
- package/src/{fields → parsing/standard}/paymentDetails.js +11 -11
- package/src/{fields → parsing/standard}/position.d.ts +2 -2
- package/src/{fields → parsing/standard}/position.js +5 -5
- package/src/{fields → parsing/standard}/tax.d.ts +3 -3
- package/src/{fields → parsing/standard}/tax.js +3 -3
- package/src/{fields → parsing/standard}/text.d.ts +2 -2
- package/src/{fields → parsing/standard}/text.js +4 -4
- package/src/parsing/standard/word.d.ts +10 -0
- package/src/parsing/standard/word.js +2 -0
- package/src/pdf/pdfOperation.d.ts +1 -1
- package/src/pdf/pdfOperation.js +3 -3
- package/src/product/cropper/cropperV1.d.ts +9 -0
- package/src/product/cropper/cropperV1.js +16 -0
- package/src/product/cropper/cropperV1Document.d.ts +8 -0
- package/src/product/cropper/cropperV1Document.js +26 -0
- package/src/product/custom/customV1.d.ts +10 -0
- package/src/product/custom/customV1.js +17 -0
- package/src/product/custom/customV1Document.d.ts +9 -0
- package/src/product/custom/customV1Document.js +43 -0
- package/src/product/custom/customV1Page.d.ts +7 -0
- package/src/product/custom/customV1Page.js +24 -0
- package/src/product/eu/licensePlate/licensePlateV1.d.ts +9 -0
- package/src/product/eu/licensePlate/licensePlateV1.js +16 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.d.ts +11 -0
- package/src/product/eu/licensePlate/licensePlateV1Document.js +25 -0
- package/src/product/financialDocument/financialDocumentV1.d.ts +9 -0
- package/src/product/financialDocument/financialDocumentV1.js +16 -0
- package/src/{documents/financialDocument/financialDocumentV1.d.ts → product/financialDocument/financialDocumentV1Document.d.ts} +43 -44
- package/src/product/financialDocument/financialDocumentV1Document.js +158 -0
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.d.ts +8 -8
- package/src/{documents → product}/financialDocument/financialDocumentV1LineItem.js +35 -34
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1.js +16 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.d.ts +15 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV1Document.js +31 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.d.ts +9 -0
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2.js +16 -0
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.d.ts +5 -5
- package/src/{documents → product}/fr/bankAccountDetails/bankAccountDetailsV2Bban.js +1 -1
- package/src/{documents/fr/bankAccountDetails/bankAccountDetailsV2.d.ts → product/fr/bankAccountDetails/bankAccountDetailsV2Document.d.ts} +7 -7
- package/src/product/fr/bankAccountDetails/bankAccountDetailsV2Document.js +37 -0
- package/src/product/fr/carteVitale/carteVitaleV1.d.ts +9 -0
- package/src/product/fr/carteVitale/carteVitaleV1.js +16 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.d.ts +17 -0
- package/src/product/fr/carteVitale/carteVitaleV1Document.js +40 -0
- package/src/product/fr/idCard/idCardV1.d.ts +10 -0
- package/src/product/fr/idCard/idCardV1.js +17 -0
- package/src/product/fr/idCard/idCardV1Document.d.ts +29 -0
- package/src/product/fr/idCard/idCardV1Document.js +70 -0
- package/src/product/fr/idCard/idCardV1Page.d.ts +12 -0
- package/src/product/fr/idCard/idCardV1Page.js +23 -0
- package/src/{documents → product}/index.d.ts +2 -7
- package/src/{documents → product}/index.js +3 -14
- package/src/product/invoice/invoiceV4.d.ts +9 -0
- package/src/product/invoice/invoiceV4.js +16 -0
- package/src/product/invoice/invoiceV4Document.d.ts +44 -0
- package/src/product/invoice/invoiceV4Document.js +146 -0
- package/src/{documents/invoice/invoiceLineItem.d.ts → product/invoice/invoiceV4LineItem.d.ts} +10 -8
- package/src/product/invoice/invoiceV4LineItem.js +101 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.d.ts +9 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1.js +16 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.d.ts +8 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1Document.js +23 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.d.ts +7 -0
- package/src/product/invoiceSplitter/invoiceSplitterV1PageGroup.js +14 -0
- package/src/product/passport/passportV1.d.ts +9 -0
- package/src/product/passport/passportV1.js +16 -0
- package/src/product/passport/passportV1Document.d.ts +31 -0
- package/src/product/passport/passportV1Document.js +75 -0
- package/src/product/proofOfAddress/proofOfAddressV1.d.ts +9 -0
- package/src/product/proofOfAddress/proofOfAddressV1.js +16 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.d.ts +27 -0
- package/src/product/proofOfAddress/proofOfAddressV1Document.js +72 -0
- package/src/product/receipt/receiptV4.d.ts +9 -0
- package/src/product/receipt/receiptV4.js +15 -0
- package/src/{documents/receipt/receiptV4.d.ts → product/receipt/receiptV4Document.d.ts} +12 -12
- package/src/product/receipt/receiptV4Document.js +67 -0
- package/src/product/receipt/receiptV5.d.ts +9 -0
- package/src/product/receipt/receiptV5.js +16 -0
- package/src/{documents/receipt/receiptV5.d.ts → product/receipt/receiptV5Document.d.ts} +16 -17
- package/src/product/receipt/receiptV5Document.js +108 -0
- package/src/{documents → product}/receipt/receiptV5LineItem.d.ts +5 -5
- package/src/{documents → product}/receipt/receiptV5LineItem.js +20 -19
- package/src/product/us/bankCheck/bankCheckV1.d.ts +10 -0
- package/src/product/us/bankCheck/bankCheckV1.js +17 -0
- package/src/product/us/bankCheck/bankCheckV1Document.d.ts +21 -0
- package/src/product/us/bankCheck/bankCheckV1Document.js +50 -0
- package/src/product/us/bankCheck/bankCheckV1Page.d.ts +14 -0
- package/src/product/us/bankCheck/bankCheckV1Page.js +32 -0
- package/src/product/us/driverLicense/driverLicenseV1.d.ts +10 -0
- package/src/product/us/driverLicense/driverLicenseV1.js +17 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.d.ts +43 -0
- package/src/product/us/driverLicense/driverLicenseV1Document.js +101 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.d.ts +14 -0
- package/src/product/us/driverLicense/driverLicenseV1Page.js +29 -0
- package/src/product/us/index.d.ts +2 -0
- package/src/product/us/index.js +7 -0
- package/src/api/documentResponse.d.ts +0 -25
- package/src/api/documentResponse.js +0 -50
- package/src/api/endpoint.d.ts +0 -63
- package/src/api/endpoint.js +0 -216
- package/src/api/index.d.ts +0 -3
- package/src/api/index.js +0 -13
- package/src/api/predictResponse.d.ts +0 -33
- package/src/api/predictResponse.js +0 -52
- package/src/documents/cropper/cropperV1.d.ts +0 -7
- package/src/documents/cropper/cropperV1.js +0 -35
- package/src/documents/custom/customV1.d.ts +0 -10
- package/src/documents/custom/customV1.js +0 -53
- package/src/documents/document.d.ts +0 -47
- package/src/documents/document.js +0 -76
- package/src/documents/documentConfig.d.ts +0 -42
- package/src/documents/documentConfig.js +0 -118
- package/src/documents/eu/licensePlate/licensePlateV1.d.ts +0 -8
- package/src/documents/eu/licensePlate/licensePlateV1.js +0 -32
- package/src/documents/financialDocument/financialDocumentV0.d.ts +0 -28
- package/src/documents/financialDocument/financialDocumentV0.js +0 -140
- package/src/documents/financialDocument/financialDocumentV1.js +0 -197
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.d.ts +0 -13
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +0 -39
- package/src/documents/fr/bankAccountDetails/bankAccountDetailsV2.js +0 -48
- package/src/documents/fr/carteVitale/carteVitaleV1.d.ts +0 -14
- package/src/documents/fr/carteVitale/carteVitaleV1.js +0 -45
- package/src/documents/fr/idCard/idCardV1.d.ts +0 -28
- package/src/documents/fr/idCard/idCardV1.js +0 -79
- package/src/documents/invoice/checks.d.ts +0 -5
- package/src/documents/invoice/checks.js +0 -87
- package/src/documents/invoice/invoiceLineItem.js +0 -66
- package/src/documents/invoice/invoiceV3.d.ts +0 -49
- package/src/documents/invoice/invoiceV3.js +0 -156
- package/src/documents/invoice/invoiceV4.d.ts +0 -45
- package/src/documents/invoice/invoiceV4.js +0 -166
- package/src/documents/invoice/reconstruction.d.ts +0 -6
- package/src/documents/invoice/reconstruction.js +0 -78
- package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +0 -14
- package/src/documents/invoiceSplitter/invoiceSplitterV1.js +0 -47
- package/src/documents/mindeeVision/mindeeVisionV1.d.ts +0 -8
- package/src/documents/mindeeVision/mindeeVisionV1.js +0 -29
- package/src/documents/passport/passportV1.d.ts +0 -43
- package/src/documents/passport/passportV1.js +0 -220
- package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +0 -24
- package/src/documents/proofOfAddress/proofOfAddressV1.js +0 -77
- package/src/documents/receipt/receiptV3.d.ts +0 -25
- package/src/documents/receipt/receiptV3.js +0 -136
- package/src/documents/receipt/receiptV4.js +0 -78
- package/src/documents/receipt/receiptV5.js +0 -137
- package/src/documents/us/bankCheck/bankCheckV1.d.ts +0 -22
- package/src/documents/us/bankCheck/bankCheckV1.js +0 -63
- package/src/documents/us/index.d.ts +0 -1
- package/src/documents/us/index.js +0 -5
- package/src/fields/companyRegistration.js +0 -14
- package/src/fields/fullText.d.ts +0 -27
- package/src/fields/fullText.js +0 -92
- package/src/fields/index.d.ts +0 -12
- package/src/fields/index.js +0 -28
- package/src/fields/locale.js +0 -45
- package/src/math/index.d.ts +0 -1
- package/src/math/index.js +0 -5
- package/src/math/precision.d.ts +0 -1
- package/src/math/precision.js +0 -13
- /package/src/{inputs → input}/pageOptions.d.ts +0 -0
- /package/src/{inputs → input}/pageOptions.js +0 -0
- /package/src/{documents → product}/eu/index.d.ts +0 -0
- /package/src/{documents → product}/eu/index.js +0 -0
- /package/src/{documents → product}/fr/index.d.ts +0 -0
- /package/src/{documents → product}/fr/index.js +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var _InvoiceV4_instances, _InvoiceV4_checklist, _InvoiceV4_reconstruct;
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.InvoiceV4 = void 0;
|
|
10
|
-
const document_1 = require("../document");
|
|
11
|
-
const fields_1 = require("../../fields");
|
|
12
|
-
const invoiceLineItem_1 = require("./invoiceLineItem");
|
|
13
|
-
const checks_1 = require("./checks");
|
|
14
|
-
const reconstruction_1 = require("./reconstruction");
|
|
15
|
-
/** Invoice V4 */
|
|
16
|
-
class InvoiceV4 extends document_1.Document {
|
|
17
|
-
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
18
|
-
super({
|
|
19
|
-
inputSource: inputSource,
|
|
20
|
-
pageId: pageId,
|
|
21
|
-
orientation: orientation,
|
|
22
|
-
fullText: fullText,
|
|
23
|
-
extras: extras,
|
|
24
|
-
});
|
|
25
|
-
_InvoiceV4_instances.add(this);
|
|
26
|
-
/** List of Reference numbers including PO number. */
|
|
27
|
-
this.referenceNumbers = [];
|
|
28
|
-
/** The payment information. */
|
|
29
|
-
this.supplierPaymentDetails = [];
|
|
30
|
-
/** The supplier company regitration information. */
|
|
31
|
-
this.supplierCompanyRegistrations = [];
|
|
32
|
-
/** The company registration information for the customer. */
|
|
33
|
-
this.customerCompanyRegistrations = [];
|
|
34
|
-
/** Line items details. */
|
|
35
|
-
this.lineItems = [];
|
|
36
|
-
this.locale = new fields_1.Locale({
|
|
37
|
-
prediction: prediction.locale,
|
|
38
|
-
valueKey: "language",
|
|
39
|
-
});
|
|
40
|
-
this.documentType = new fields_1.ClassificationField({
|
|
41
|
-
prediction: prediction.document_type,
|
|
42
|
-
});
|
|
43
|
-
this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
|
|
44
|
-
return new fields_1.TextField({
|
|
45
|
-
prediction: prediction,
|
|
46
|
-
pageId: pageId,
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
this.totalAmount = new fields_1.Amount({
|
|
50
|
-
prediction: prediction.total_amount,
|
|
51
|
-
pageId: pageId,
|
|
52
|
-
});
|
|
53
|
-
this.totalTax = new fields_1.Amount({
|
|
54
|
-
prediction: { value: undefined, confidence: 0.0 },
|
|
55
|
-
pageId: pageId,
|
|
56
|
-
});
|
|
57
|
-
this.totalNet = new fields_1.Amount({
|
|
58
|
-
prediction: prediction.total_net,
|
|
59
|
-
pageId: pageId,
|
|
60
|
-
});
|
|
61
|
-
this.date = new fields_1.DateField({
|
|
62
|
-
prediction: prediction.date,
|
|
63
|
-
pageId,
|
|
64
|
-
});
|
|
65
|
-
this.taxes = new fields_1.Taxes().init(prediction["taxes"], pageId);
|
|
66
|
-
this.supplierCompanyRegistrations =
|
|
67
|
-
prediction.supplier_company_registrations.map(function (prediction) {
|
|
68
|
-
return new fields_1.CompanyRegistration({
|
|
69
|
-
prediction: prediction,
|
|
70
|
-
pageId: pageId,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
this.dueDate = new fields_1.DateField({
|
|
74
|
-
prediction: prediction.due_date,
|
|
75
|
-
pageId: pageId,
|
|
76
|
-
});
|
|
77
|
-
this.invoiceNumber = new fields_1.TextField({
|
|
78
|
-
prediction: prediction.invoice_number,
|
|
79
|
-
pageId: pageId,
|
|
80
|
-
});
|
|
81
|
-
this.supplierName = new fields_1.TextField({
|
|
82
|
-
prediction: prediction.supplier_name,
|
|
83
|
-
pageId: pageId,
|
|
84
|
-
});
|
|
85
|
-
this.supplierAddress = new fields_1.TextField({
|
|
86
|
-
prediction: prediction.supplier_address,
|
|
87
|
-
pageId: pageId,
|
|
88
|
-
});
|
|
89
|
-
this.customerName = new fields_1.TextField({
|
|
90
|
-
prediction: prediction.customer_name,
|
|
91
|
-
pageId: pageId,
|
|
92
|
-
});
|
|
93
|
-
this.customerAddress = new fields_1.TextField({
|
|
94
|
-
prediction: prediction.customer_address,
|
|
95
|
-
pageId: pageId,
|
|
96
|
-
});
|
|
97
|
-
prediction.customer_company_registrations.map((prediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
|
|
98
|
-
prediction: prediction,
|
|
99
|
-
pageId: pageId,
|
|
100
|
-
})));
|
|
101
|
-
prediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
|
|
102
|
-
prediction: prediction,
|
|
103
|
-
pageId: pageId,
|
|
104
|
-
})));
|
|
105
|
-
prediction.line_items.map((prediction) => this.lineItems.push(new invoiceLineItem_1.InvoiceLineItem({
|
|
106
|
-
prediction: prediction,
|
|
107
|
-
})));
|
|
108
|
-
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_checklist).call(this);
|
|
109
|
-
__classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_reconstruct).call(this);
|
|
110
|
-
}
|
|
111
|
-
toString() {
|
|
112
|
-
const referenceNumbers = this.referenceNumbers
|
|
113
|
-
.map((item) => item.toString())
|
|
114
|
-
.join(", ");
|
|
115
|
-
const paymentDetails = this.supplierPaymentDetails
|
|
116
|
-
.map((item) => item.toString())
|
|
117
|
-
.join("\n ");
|
|
118
|
-
const customerCompanyRegistration = this.customerCompanyRegistrations
|
|
119
|
-
.map((item) => item.toString())
|
|
120
|
-
.join("; ");
|
|
121
|
-
const companyRegistration = this.supplierCompanyRegistrations
|
|
122
|
-
.map((item) => item.toString())
|
|
123
|
-
.join("; ");
|
|
124
|
-
let lineItems = "\n";
|
|
125
|
-
if (this.lineItems.length > 0) {
|
|
126
|
-
lineItems =
|
|
127
|
-
"\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
|
|
128
|
-
lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
|
|
129
|
-
}
|
|
130
|
-
const outStr = `Invoice V4 Prediction
|
|
131
|
-
=====================
|
|
132
|
-
:Filename: ${this.filename}
|
|
133
|
-
:Locale: ${this.locale}
|
|
134
|
-
:Invoice number: ${this.invoiceNumber}
|
|
135
|
-
:Reference numbers: ${referenceNumbers}
|
|
136
|
-
:Invoice date: ${this.date}
|
|
137
|
-
:Invoice due date: ${this.dueDate}
|
|
138
|
-
:Supplier name: ${this.supplierName}
|
|
139
|
-
:Supplier address: ${this.supplierAddress}
|
|
140
|
-
:Supplier company registrations: ${companyRegistration}
|
|
141
|
-
:Supplier payment details: ${paymentDetails}
|
|
142
|
-
:Customer name: ${this.customerName}
|
|
143
|
-
:Customer company registrations: ${customerCompanyRegistration}
|
|
144
|
-
:Customer address: ${this.customerAddress}
|
|
145
|
-
:Line Items: ${lineItems}
|
|
146
|
-
:Taxes: ${this.taxes}
|
|
147
|
-
:Total tax: ${this.totalTax}
|
|
148
|
-
:Total net: ${this.totalNet}
|
|
149
|
-
:Total amount: ${this.totalAmount}
|
|
150
|
-
`;
|
|
151
|
-
return InvoiceV4.cleanOutString(outStr);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.InvoiceV4 = InvoiceV4;
|
|
155
|
-
_InvoiceV4_instances = new WeakSet(), _InvoiceV4_checklist = function _InvoiceV4_checklist() {
|
|
156
|
-
this.checklist = {
|
|
157
|
-
taxesMatchTotalIncl: (0, checks_1.taxesMatchTotalIncl)(this),
|
|
158
|
-
taxesMatchTotalExcl: (0, checks_1.taxesMatchTotalExcl)(this),
|
|
159
|
-
taxesAndTotalExclMatchTotalIncl: (0, checks_1.taxesAndTotalExclMatchTotalIncl)(this),
|
|
160
|
-
};
|
|
161
|
-
}, _InvoiceV4_reconstruct = function _InvoiceV4_reconstruct() {
|
|
162
|
-
(0, reconstruction_1.reconstructTotalTax)(this);
|
|
163
|
-
(0, reconstruction_1.reconstructTotalExcl)(this);
|
|
164
|
-
(0, reconstruction_1.reconstructTotalIncl)(this);
|
|
165
|
-
(0, reconstruction_1.reconstructTotalTaxFromTotals)(this);
|
|
166
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { InvoiceV3 } from "./invoiceV3";
|
|
2
|
-
import { InvoiceV4 } from "./invoiceV4";
|
|
3
|
-
export declare function reconstructTotalTax(document: InvoiceV3 | InvoiceV4): void;
|
|
4
|
-
export declare function reconstructTotalTaxFromTotals(document: InvoiceV3 | InvoiceV4): void;
|
|
5
|
-
export declare function reconstructTotalExcl(document: InvoiceV3 | InvoiceV4): void;
|
|
6
|
-
export declare function reconstructTotalIncl(document: InvoiceV3 | InvoiceV4): void;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reconstructTotalIncl = exports.reconstructTotalExcl = exports.reconstructTotalTaxFromTotals = exports.reconstructTotalTax = void 0;
|
|
4
|
-
const fields_1 = require("../../fields");
|
|
5
|
-
function reconstructTotalTax(document) {
|
|
6
|
-
if (document.taxes.length > 0) {
|
|
7
|
-
const totalTax = {
|
|
8
|
-
value: document.taxes.reduce((acc, tax) => {
|
|
9
|
-
return tax.value !== undefined ? acc + tax.value : acc;
|
|
10
|
-
}, 0),
|
|
11
|
-
confidence: fields_1.TextField.arrayConfidence(document.taxes),
|
|
12
|
-
};
|
|
13
|
-
if (totalTax.value > 0)
|
|
14
|
-
document.totalTax = new fields_1.Amount({
|
|
15
|
-
prediction: totalTax,
|
|
16
|
-
valueKey: "value",
|
|
17
|
-
reconstructed: true,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.reconstructTotalTax = reconstructTotalTax;
|
|
22
|
-
function reconstructTotalTaxFromTotals(document) {
|
|
23
|
-
if (document.totalTax.value !== undefined ||
|
|
24
|
-
document.totalNet.value === undefined ||
|
|
25
|
-
document.totalAmount.value === undefined) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const totalTax = {
|
|
29
|
-
value: document.totalAmount.value - document.totalNet.value,
|
|
30
|
-
confidence: document.totalAmount.confidence * document.totalNet.confidence,
|
|
31
|
-
};
|
|
32
|
-
if (totalTax.value >= 0) {
|
|
33
|
-
document.totalTax = new fields_1.Amount({
|
|
34
|
-
prediction: totalTax,
|
|
35
|
-
valueKey: "value",
|
|
36
|
-
reconstructed: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.reconstructTotalTaxFromTotals = reconstructTotalTaxFromTotals;
|
|
41
|
-
function reconstructTotalExcl(document) {
|
|
42
|
-
if (document.totalAmount.value === undefined ||
|
|
43
|
-
document.taxes.length === 0 ||
|
|
44
|
-
document.totalNet.value !== undefined) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const totalExcl = {
|
|
48
|
-
value: document.totalAmount.value - fields_1.TextField.arraySum(document.taxes),
|
|
49
|
-
confidence: fields_1.TextField.arrayConfidence(document.taxes) *
|
|
50
|
-
document.totalAmount.confidence,
|
|
51
|
-
};
|
|
52
|
-
document.totalNet = new fields_1.Amount({
|
|
53
|
-
prediction: totalExcl,
|
|
54
|
-
valueKey: "value",
|
|
55
|
-
reconstructed: true,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
exports.reconstructTotalExcl = reconstructTotalExcl;
|
|
59
|
-
function reconstructTotalIncl(document) {
|
|
60
|
-
if (!(document.totalNet.value === undefined ||
|
|
61
|
-
document.taxes.length === 0 ||
|
|
62
|
-
document.totalAmount.value !== undefined)) {
|
|
63
|
-
const totalIncl = {
|
|
64
|
-
value: document.totalNet.value +
|
|
65
|
-
document.taxes.reduce((acc, tax) => {
|
|
66
|
-
return tax.value ? acc + tax.value : acc;
|
|
67
|
-
}, 0.0),
|
|
68
|
-
confidence: fields_1.TextField.arrayConfidence(document.taxes) *
|
|
69
|
-
document.totalNet.confidence,
|
|
70
|
-
};
|
|
71
|
-
document.totalAmount = new fields_1.Amount({
|
|
72
|
-
prediction: totalIncl,
|
|
73
|
-
valueKey: "value",
|
|
74
|
-
reconstructed: true,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.reconstructTotalIncl = reconstructTotalIncl;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { StringDict } from "../../fields";
|
|
3
|
-
export declare class PageGroup {
|
|
4
|
-
pageIndexes: number[];
|
|
5
|
-
confidence: number;
|
|
6
|
-
constructor(prediction: StringDict);
|
|
7
|
-
toString(): string;
|
|
8
|
-
}
|
|
9
|
-
export declare class InvoiceSplitterV1 extends Document {
|
|
10
|
-
/** List of page indexes that belong to the same invoice in the PDF. */
|
|
11
|
-
invoicePageGroups: PageGroup[];
|
|
12
|
-
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
13
|
-
toString(): string;
|
|
14
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvoiceSplitterV1 = exports.PageGroup = void 0;
|
|
4
|
-
const document_1 = require("../document");
|
|
5
|
-
class PageGroup {
|
|
6
|
-
constructor(prediction) {
|
|
7
|
-
this.pageIndexes = [];
|
|
8
|
-
this.pageIndexes = prediction.page_indexes;
|
|
9
|
-
this.confidence = prediction.confidence;
|
|
10
|
-
}
|
|
11
|
-
toString() {
|
|
12
|
-
return `page indexes: ${this.pageIndexes.join(", ")}`;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.PageGroup = PageGroup;
|
|
16
|
-
class InvoiceSplitterV1 extends document_1.Document {
|
|
17
|
-
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
18
|
-
super({
|
|
19
|
-
inputSource: inputSource,
|
|
20
|
-
pageId: pageId,
|
|
21
|
-
orientation: orientation,
|
|
22
|
-
fullText: fullText,
|
|
23
|
-
extras: extras,
|
|
24
|
-
});
|
|
25
|
-
/** List of page indexes that belong to the same invoice in the PDF. */
|
|
26
|
-
this.invoicePageGroups = [];
|
|
27
|
-
if (prediction.invoice_page_groups !== undefined) {
|
|
28
|
-
prediction.invoice_page_groups.map((prediction) => this.invoicePageGroups.push(new PageGroup(prediction)));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
toString() {
|
|
32
|
-
let invoicePageGroups = "\n";
|
|
33
|
-
if (this.invoicePageGroups.length > 0) {
|
|
34
|
-
invoicePageGroups = "\n ";
|
|
35
|
-
invoicePageGroups += this.invoicePageGroups
|
|
36
|
-
.map((item) => item.toString())
|
|
37
|
-
.join("\n ");
|
|
38
|
-
}
|
|
39
|
-
const outStr = `----- Invoice Splitter V1 -----
|
|
40
|
-
Filename: ${this.filename}
|
|
41
|
-
Invoice Page Groups: ${invoicePageGroups}
|
|
42
|
-
----------------------
|
|
43
|
-
`;
|
|
44
|
-
return InvoiceSplitterV1.cleanOutString(outStr);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.InvoiceSplitterV1 = InvoiceSplitterV1;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { Word } from "../../fields";
|
|
3
|
-
export declare class MindeeVisionV1 extends Document {
|
|
4
|
-
/** List of words found on the page. */
|
|
5
|
-
allWords: Word[];
|
|
6
|
-
constructor({ prediction, orientation, extras, inputSource, fullText, pageId, }: DocumentConstructorProps);
|
|
7
|
-
toString(): string;
|
|
8
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MindeeVisionV1 = void 0;
|
|
4
|
-
const document_1 = require("../document");
|
|
5
|
-
const fields_1 = require("../../fields");
|
|
6
|
-
class MindeeVisionV1 extends document_1.Document {
|
|
7
|
-
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
|
|
8
|
-
super({
|
|
9
|
-
inputSource: inputSource,
|
|
10
|
-
pageId: pageId,
|
|
11
|
-
orientation: orientation,
|
|
12
|
-
fullText: fullText,
|
|
13
|
-
extras: extras,
|
|
14
|
-
});
|
|
15
|
-
/** List of words found on the page. */
|
|
16
|
-
this.allWords = [];
|
|
17
|
-
if (prediction.all_words !== undefined) {
|
|
18
|
-
prediction.all_words.map((prediction) => {
|
|
19
|
-
this.allWords.push(prediction);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
toString() {
|
|
24
|
-
const fullText = new fields_1.FullText();
|
|
25
|
-
fullText.words = this.allWords;
|
|
26
|
-
return fullText.toString();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.MindeeVisionV1 = MindeeVisionV1;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { DateField, TextField } from "../../fields";
|
|
3
|
-
export declare class PassportV1 extends Document {
|
|
4
|
-
#private;
|
|
5
|
-
/** The country of issue. */
|
|
6
|
-
country: TextField;
|
|
7
|
-
/** The passport number. */
|
|
8
|
-
idNumber: TextField;
|
|
9
|
-
/** The date of birth of the passport holder. */
|
|
10
|
-
birthDate: DateField;
|
|
11
|
-
/** The expiration date of the passport. */
|
|
12
|
-
expiryDate: DateField;
|
|
13
|
-
/** The issuance date of the passport. */
|
|
14
|
-
issuanceDate: DateField;
|
|
15
|
-
/** The place of birth of the passport holder. */
|
|
16
|
-
birthPlace: TextField;
|
|
17
|
-
/** The sex or gender of the passport holder. */
|
|
18
|
-
gender: TextField;
|
|
19
|
-
/** The surname (last name) of the passport holder. */
|
|
20
|
-
surname: TextField;
|
|
21
|
-
/** The value of the first MRZ line. */
|
|
22
|
-
mrz1: TextField;
|
|
23
|
-
/** The value of the second MRZ line. */
|
|
24
|
-
mrz2: TextField;
|
|
25
|
-
/** List of first (given) names of the passport holder. */
|
|
26
|
-
givenNames: TextField[];
|
|
27
|
-
/** The full name of the passport holder. */
|
|
28
|
-
fullName: TextField;
|
|
29
|
-
/** All the MRZ values combined. */
|
|
30
|
-
mrz: TextField;
|
|
31
|
-
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
32
|
-
static convertMRZDateToDatetime(dateString: string): Date;
|
|
33
|
-
toString(): string;
|
|
34
|
-
isExpired(): boolean;
|
|
35
|
-
private isMRZValid;
|
|
36
|
-
private isBirthDateValid;
|
|
37
|
-
private isExpiryDateValid;
|
|
38
|
-
private isIdNumberValid;
|
|
39
|
-
private isSurnameValid;
|
|
40
|
-
private isCountryValid;
|
|
41
|
-
private constructFullName;
|
|
42
|
-
private constructMRZ;
|
|
43
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
27
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
|
-
};
|
|
30
|
-
var _PassportV1_instances, _PassportV1_checklist;
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.PassportV1 = void 0;
|
|
33
|
-
const document_1 = require("../document");
|
|
34
|
-
const fields_1 = require("../../fields");
|
|
35
|
-
const MRZ = __importStar(require("mrz"));
|
|
36
|
-
class PassportV1 extends document_1.Document {
|
|
37
|
-
constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, pageId = undefined, }) {
|
|
38
|
-
super({
|
|
39
|
-
inputSource: inputSource,
|
|
40
|
-
pageId: pageId,
|
|
41
|
-
orientation: orientation,
|
|
42
|
-
extras: extras,
|
|
43
|
-
});
|
|
44
|
-
_PassportV1_instances.add(this);
|
|
45
|
-
/** List of first (given) names of the passport holder. */
|
|
46
|
-
this.givenNames = [];
|
|
47
|
-
this.country = new fields_1.TextField({
|
|
48
|
-
prediction: prediction.country,
|
|
49
|
-
pageId: pageId,
|
|
50
|
-
});
|
|
51
|
-
this.idNumber = new fields_1.TextField({
|
|
52
|
-
prediction: prediction.id_number,
|
|
53
|
-
pageId: pageId,
|
|
54
|
-
});
|
|
55
|
-
this.birthDate = new fields_1.DateField({
|
|
56
|
-
prediction: prediction.birth_date,
|
|
57
|
-
pageId: pageId,
|
|
58
|
-
});
|
|
59
|
-
this.expiryDate = new fields_1.DateField({
|
|
60
|
-
prediction: prediction.expiry_date,
|
|
61
|
-
pageId: pageId,
|
|
62
|
-
});
|
|
63
|
-
this.issuanceDate = new fields_1.DateField({
|
|
64
|
-
prediction: prediction.issuance_date,
|
|
65
|
-
pageId: pageId,
|
|
66
|
-
});
|
|
67
|
-
this.birthPlace = new fields_1.TextField({
|
|
68
|
-
prediction: prediction.birth_place,
|
|
69
|
-
pageId: pageId,
|
|
70
|
-
});
|
|
71
|
-
this.gender = new fields_1.TextField({
|
|
72
|
-
prediction: prediction.gender,
|
|
73
|
-
pageId: pageId,
|
|
74
|
-
});
|
|
75
|
-
this.surname = new fields_1.TextField({
|
|
76
|
-
prediction: prediction.surname,
|
|
77
|
-
pageId: pageId,
|
|
78
|
-
});
|
|
79
|
-
this.mrz1 = new fields_1.TextField({
|
|
80
|
-
prediction: prediction.mrz1,
|
|
81
|
-
pageId: pageId,
|
|
82
|
-
});
|
|
83
|
-
this.mrz2 = new fields_1.TextField({
|
|
84
|
-
prediction: prediction.mrz2,
|
|
85
|
-
pageId: pageId,
|
|
86
|
-
});
|
|
87
|
-
prediction.given_names.map((prediction) => this.givenNames.push(new fields_1.TextField({
|
|
88
|
-
prediction: prediction,
|
|
89
|
-
pageId: pageId,
|
|
90
|
-
})));
|
|
91
|
-
this.fullName = this.constructFullName(pageId);
|
|
92
|
-
this.mrz = this.constructMRZ(pageId);
|
|
93
|
-
__classPrivateFieldGet(this, _PassportV1_instances, "m", _PassportV1_checklist).call(this);
|
|
94
|
-
}
|
|
95
|
-
static convertMRZDateToDatetime(dateString) {
|
|
96
|
-
const year = parseInt(dateString.substring(0, 2));
|
|
97
|
-
const month = parseInt(dateString.substring(2, 4));
|
|
98
|
-
const day = parseInt(dateString.substring(4, 6));
|
|
99
|
-
// month is 0 indexed, day is 1 indexed... because JavaScript ...
|
|
100
|
-
return new Date(year, month - 1, day, 0, 0, 0, 0);
|
|
101
|
-
}
|
|
102
|
-
toString() {
|
|
103
|
-
const outStr = `----- Passport V1 -----
|
|
104
|
-
Filename: ${this.filename}
|
|
105
|
-
Full name: ${this.fullName}
|
|
106
|
-
Given names: ${this.givenNames.map((name) => name.value).join(" ")}
|
|
107
|
-
Surname: ${this.surname}
|
|
108
|
-
Country: ${this.country}
|
|
109
|
-
ID Number: ${this.idNumber}
|
|
110
|
-
Issuance date: ${this.issuanceDate}
|
|
111
|
-
Birth date: ${this.birthDate}
|
|
112
|
-
Expiry date: ${this.expiryDate}
|
|
113
|
-
MRZ 1: ${this.mrz1}
|
|
114
|
-
MRZ 2: ${this.mrz2}
|
|
115
|
-
MRZ: ${this.mrz}
|
|
116
|
-
----------------------
|
|
117
|
-
`;
|
|
118
|
-
return PassportV1.cleanOutString(outStr);
|
|
119
|
-
}
|
|
120
|
-
isExpired() {
|
|
121
|
-
const dateTime = new Date();
|
|
122
|
-
if (this.expiryDate.dateObject) {
|
|
123
|
-
return this.expiryDate.dateObject < dateTime;
|
|
124
|
-
}
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
isMRZValid(mrz) {
|
|
128
|
-
const check = mrz.valid;
|
|
129
|
-
if (check)
|
|
130
|
-
this.mrz.confidence = 1.0;
|
|
131
|
-
return check;
|
|
132
|
-
}
|
|
133
|
-
isBirthDateValid(mrz) {
|
|
134
|
-
if (this.birthDate.dateObject === undefined || !mrz.fields.birthDate) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
const mrzDate = PassportV1.convertMRZDateToDatetime(mrz.fields.birthDate);
|
|
138
|
-
const check = fields_1.DateField.compareDates(this.birthDate.dateObject, mrzDate);
|
|
139
|
-
if (check) {
|
|
140
|
-
this.birthDate.confidence = 1.0;
|
|
141
|
-
}
|
|
142
|
-
return check;
|
|
143
|
-
}
|
|
144
|
-
isExpiryDateValid(mrz) {
|
|
145
|
-
if (this.expiryDate.dateObject === undefined ||
|
|
146
|
-
!mrz.fields.expirationDate) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
const mrzDate = PassportV1.convertMRZDateToDatetime(mrz.fields.expirationDate);
|
|
150
|
-
const check = fields_1.DateField.compareDates(this.expiryDate.dateObject, mrzDate);
|
|
151
|
-
if (check) {
|
|
152
|
-
this.expiryDate.confidence = 1.0;
|
|
153
|
-
}
|
|
154
|
-
return check;
|
|
155
|
-
}
|
|
156
|
-
isIdNumberValid(mrz) {
|
|
157
|
-
const check = mrz.fields.documentNumber &&
|
|
158
|
-
mrz.fields.documentNumber === this.idNumber.value;
|
|
159
|
-
if (check)
|
|
160
|
-
this.idNumber.confidence = 1.0;
|
|
161
|
-
return check;
|
|
162
|
-
}
|
|
163
|
-
isSurnameValid(mrz) {
|
|
164
|
-
const check = mrz.fields.lastName === this.surname.value;
|
|
165
|
-
if (check)
|
|
166
|
-
this.surname.confidence = 1.0;
|
|
167
|
-
return check;
|
|
168
|
-
}
|
|
169
|
-
isCountryValid(mrz) {
|
|
170
|
-
const check = mrz.fields.nationality === this.country.value;
|
|
171
|
-
if (check)
|
|
172
|
-
this.country.confidence = 1.0;
|
|
173
|
-
return check;
|
|
174
|
-
}
|
|
175
|
-
constructFullName(pageNumber) {
|
|
176
|
-
if (this.surname &&
|
|
177
|
-
this.givenNames.length > 0 &&
|
|
178
|
-
this.givenNames[0].value) {
|
|
179
|
-
const fullName = {
|
|
180
|
-
value: `${this.givenNames[0].value} ${this.surname.value}`,
|
|
181
|
-
confidence: fields_1.TextField.arrayConfidence([
|
|
182
|
-
this.surname,
|
|
183
|
-
this.givenNames[0],
|
|
184
|
-
]),
|
|
185
|
-
};
|
|
186
|
-
return new fields_1.TextField({
|
|
187
|
-
prediction: fullName,
|
|
188
|
-
pageId: pageNumber,
|
|
189
|
-
reconstructed: true,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
constructMRZ(pageNumber) {
|
|
194
|
-
if (this.mrz1.value && this.mrz2.value) {
|
|
195
|
-
const mrz = {
|
|
196
|
-
value: `${this.mrz1.value}${this.mrz2.value}`,
|
|
197
|
-
confidence: fields_1.TextField.arrayConfidence([this.mrz1, this.mrz2]),
|
|
198
|
-
};
|
|
199
|
-
return new fields_1.TextField({
|
|
200
|
-
prediction: mrz,
|
|
201
|
-
pageId: pageNumber,
|
|
202
|
-
reconstructed: true,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
exports.PassportV1 = PassportV1;
|
|
208
|
-
_PassportV1_instances = new WeakSet(), _PassportV1_checklist = function _PassportV1_checklist() {
|
|
209
|
-
if (this.mrz1.value && this.mrz2.value) {
|
|
210
|
-
const mrz = MRZ.parse([this.mrz1.value, this.mrz2.value]);
|
|
211
|
-
this.checklist = {
|
|
212
|
-
mrzValid: this.isMRZValid(mrz),
|
|
213
|
-
mrzValidBirthDate: this.isBirthDateValid(mrz),
|
|
214
|
-
mrzValidExpiryDate: this.isExpiryDateValid(mrz),
|
|
215
|
-
mrzValidIdNumber: this.isIdNumberValid(mrz),
|
|
216
|
-
mrzValidSurname: this.isSurnameValid(mrz),
|
|
217
|
-
mrzValidCountry: this.isCountryValid(mrz),
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Document, DocumentConstructorProps } from "../document";
|
|
2
|
-
import { CompanyRegistration, DateField, Locale, TextField } from "../../fields";
|
|
3
|
-
export declare class ProofOfAddressV1 extends Document {
|
|
4
|
-
/** ISO date yyyy-mm-dd. Works both for European and US dates. */
|
|
5
|
-
date: DateField;
|
|
6
|
-
/** All extrated ISO date yyyy-mm-dd. Works both for European and US dates. */
|
|
7
|
-
dates: DateField[];
|
|
8
|
-
/** Address of the document's issuer. */
|
|
9
|
-
issuerAddress: TextField;
|
|
10
|
-
/** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
|
|
11
|
-
issuerCompanyRegistration: CompanyRegistration[];
|
|
12
|
-
/** Name of the person or company issuing the document. */
|
|
13
|
-
issuerName: TextField;
|
|
14
|
-
/** ISO 639-1 code, works best with ca, de, en, es, fr, it, nl and pt. */
|
|
15
|
-
locale: Locale;
|
|
16
|
-
/** Address of supplier. */
|
|
17
|
-
recipientAddress: TextField;
|
|
18
|
-
/** Generic: VAT NUMBER, TAX ID, COMPANY REGISTRATION NUMBER or country specific. */
|
|
19
|
-
recipientCompanyRegistration: CompanyRegistration[];
|
|
20
|
-
/** Name of the document's recipient. */
|
|
21
|
-
recipientName: TextField;
|
|
22
|
-
constructor({ prediction, orientation, extras, inputSource, pageId, }: DocumentConstructorProps);
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|