mindee 3.5.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +63 -39
  2. package/package.json +3 -3
  3. package/src/api/{response.d.ts → documentResponse.d.ts} +2 -2
  4. package/src/api/endpoint.d.ts +32 -5
  5. package/src/api/endpoint.js +104 -34
  6. package/src/api/index.d.ts +3 -2
  7. package/src/api/index.js +5 -3
  8. package/src/api/predictResponse.d.ts +33 -0
  9. package/src/api/predictResponse.js +52 -0
  10. package/src/cli.js +210 -50
  11. package/src/client.d.ts +20 -4
  12. package/src/client.js +75 -23
  13. package/src/documents/custom/fields.js +1 -1
  14. package/src/documents/custom/lineitems.d.ts +41 -0
  15. package/src/documents/custom/lineitems.js +127 -0
  16. package/src/documents/document.d.ts +1 -1
  17. package/src/documents/documentConfig.d.ts +14 -6
  18. package/src/documents/documentConfig.js +59 -28
  19. package/src/documents/eu/licensePlate/licensePlateV1.js +4 -2
  20. package/src/documents/financialDocument/financialDocumentV0.d.ts +28 -0
  21. package/src/documents/financialDocument/financialDocumentV0.js +140 -0
  22. package/src/documents/financialDocument/financialDocumentV1.d.ts +44 -15
  23. package/src/documents/financialDocument/financialDocumentV1.js +154 -110
  24. package/src/documents/fr/bankAccountDetails/bankAccountDetailsV1.js +3 -2
  25. package/src/documents/fr/carteVitale/carteVitaleV1.js +2 -2
  26. package/src/documents/fr/idCard/idCardV1.js +10 -10
  27. package/src/documents/index.d.ts +5 -1
  28. package/src/documents/index.js +10 -2
  29. package/src/documents/invoice/invoiceV4.d.ts +3 -2
  30. package/src/documents/invoice/invoiceV4.js +85 -86
  31. package/src/documents/invoiceSplitter/invoiceSplitterV1.d.ts +3 -3
  32. package/src/documents/invoiceSplitter/invoiceSplitterV1.js +1 -0
  33. package/src/documents/mindeeVision/mindeeVisionV1.d.ts +8 -0
  34. package/src/documents/mindeeVision/mindeeVisionV1.js +29 -0
  35. package/src/documents/proofOfAddress/proofOfAddressV1.d.ts +24 -0
  36. package/src/documents/proofOfAddress/proofOfAddressV1.js +77 -0
  37. package/src/documents/receipt/receiptV3.d.ts +2 -2
  38. package/src/documents/receipt/receiptV3.js +1 -2
  39. package/src/documents/receipt/receiptV4.d.ts +3 -4
  40. package/src/documents/receipt/receiptV4.js +53 -65
  41. package/src/documents/{shipping_container → shippingContainer}/shippingContainerV1.js +2 -2
  42. package/src/fields/classification.d.ts +8 -0
  43. package/src/fields/classification.js +11 -0
  44. package/src/fields/field.d.ts +2 -2
  45. package/src/fields/field.js +1 -6
  46. package/src/fields/index.d.ts +1 -0
  47. package/src/fields/index.js +3 -1
  48. package/src/geometry.d.ts +18 -4
  49. package/src/geometry.js +40 -3
  50. package/src/index.d.ts +2 -2
  51. package/src/index.js +3 -1
  52. package/src/math/index.d.ts +1 -0
  53. package/src/math/index.js +5 -0
  54. package/src/math/precision.d.ts +1 -0
  55. package/src/math/precision.js +13 -0
  56. /package/src/api/{response.js → documentResponse.js} +0 -0
  57. /package/src/documents/{shipping_container → shippingContainer}/shippingContainerV1.d.ts +0 -0
@@ -1,16 +1,12 @@
1
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 _FinancialDocumentV1_instances, _FinancialDocumentV1_initFromApiPrediction, _FinancialDocumentV1_checklist, _FinancialDocumentV1_taxesMatchTotalIncl;
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.FinancialDocumentV1 = void 0;
10
4
  const document_1 = require("../document");
11
- const invoiceV3_1 = require("../invoice/invoiceV3");
12
- const receiptV3_1 = require("../receipt/receiptV3");
13
5
  const fields_1 = require("../../fields");
6
+ const invoiceLineItem_1 = require("../invoice/invoiceLineItem");
7
+ /**
8
+ * Financial Document.
9
+ */
14
10
  class FinancialDocumentV1 extends document_1.Document {
15
11
  constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
16
12
  super({
@@ -20,118 +16,166 @@ class FinancialDocumentV1 extends document_1.Document {
20
16
  fullText: fullText,
21
17
  extras: extras,
22
18
  });
23
- _FinancialDocumentV1_instances.add(this);
19
+ /** List of Reference numbers including PO number. */
20
+ this.referenceNumbers = [];
21
+ /** The payment information. */
22
+ this.supplierPaymentDetails = [];
23
+ /** The supplier company registration information. */
24
+ this.supplierCompanyRegistrations = [];
25
+ /** The company registration information for the customer. */
26
+ this.customerCompanyRegistrations = [];
27
+ /** The list of the taxes. */
24
28
  this.taxes = [];
25
- this.companyRegistration = [];
26
- this.paymentDetails = [];
27
- this.customerCompanyRegistration = [];
28
- __classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_initFromApiPrediction).call(this, prediction, inputSource, pageId, orientation, extras);
29
- __classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_checklist).call(this);
30
- }
31
- toString() {
32
- const outStr = `-----Financial document-----
33
- Filename: ${this.filename}
34
- Total amount: ${this.totalIncl.value}
35
- Date: ${this.date.value}
36
- Supplier: ${this.supplier.value}
37
- Total taxes: ${this.totalTax.value}
38
- ----------------------
39
- `;
40
- return FinancialDocumentV1.cleanOutString(outStr);
41
- }
42
- }
43
- exports.FinancialDocumentV1 = FinancialDocumentV1;
44
- _FinancialDocumentV1_instances = new WeakSet(), _FinancialDocumentV1_initFromApiPrediction = function _FinancialDocumentV1_initFromApiPrediction(prediction, inputFile, pageNumber, orientation, extras) {
45
- if (Object.keys(prediction).includes("invoice_number")) {
46
- const invoice = new invoiceV3_1.InvoiceV3({
47
- prediction: prediction,
48
- inputSource: inputFile,
49
- pageId: pageNumber,
50
- orientation: orientation,
51
- extras: extras,
29
+ /** Line items details. */
30
+ this.lineItems = [];
31
+ this.locale = new fields_1.Locale({
32
+ prediction: prediction.locale,
33
+ valueKey: "language",
52
34
  });
53
- this.locale = invoice.locale;
54
- this.totalIncl = invoice.totalIncl;
55
- this.totalExcl = invoice.totalExcl;
56
- this.date = invoice.date;
57
- this.invoiceNumber = invoice.invoiceNumber;
58
- this.dueDate = invoice.dueDate;
59
- this.taxes = invoice.taxes;
60
- this.supplier = invoice.supplier;
61
- this.supplierAddress = invoice.supplierAddress;
62
- this.paymentDetails = invoice.paymentDetails;
63
- this.companyRegistration = invoice.customerCompanyRegistration;
64
- this.orientation = invoice.orientation;
65
- this.totalTax = invoice.totalTax;
66
- this.time = new fields_1.TextField({
67
- prediction: { value: undefined, confidence: 0.0 },
35
+ this.documentType = new fields_1.BaseField({
36
+ prediction: prediction.document_type,
37
+ valueKey: "value",
68
38
  });
69
- this.customerName = invoice.customerName;
70
- this.customerAddress = invoice.customerAddress;
71
- this.customerCompanyRegistration = invoice.customerCompanyRegistration;
72
- }
73
- else {
74
- const receipt = new receiptV3_1.ReceiptV3({
75
- prediction: prediction,
76
- inputSource: inputFile,
77
- pageId: pageNumber,
78
- orientation: orientation,
79
- extras: extras,
39
+ this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
40
+ return new fields_1.TextField({
41
+ prediction: prediction,
42
+ pageId: pageId,
43
+ });
80
44
  });
81
- this.orientation = receipt.orientation;
82
- this.date = receipt.date;
83
- this.dueDate = receipt.date;
84
- this.taxes = receipt.taxes;
85
- this.locale = receipt.locale;
86
- this.totalIncl = receipt.totalIncl;
87
- this.totalExcl = receipt.totalExcl;
88
- this.supplier = receipt.merchantName;
89
- this.supplierAddress = new fields_1.TextField({
90
- prediction: { value: undefined, confidence: 0.0 },
45
+ this.totalAmount = new fields_1.Amount({
46
+ prediction: prediction.total_amount,
47
+ valueKey: "value",
48
+ pageId: pageId,
49
+ });
50
+ this.totalTax = new fields_1.Amount({
51
+ prediction: prediction.total_tax,
52
+ valueKey: "value",
53
+ pageId: pageId,
54
+ });
55
+ this.totalNet = new fields_1.Amount({
56
+ prediction: prediction.total_net,
57
+ valueKey: "value",
58
+ pageId: pageId,
59
+ });
60
+ this.date = new fields_1.DateField({
61
+ prediction: prediction.date,
62
+ pageId,
63
+ });
64
+ this.dueDate = new fields_1.DateField({
65
+ prediction: prediction.due_date,
66
+ pageId: pageId,
91
67
  });
92
- this.time = receipt.time;
93
- this.totalTax = receipt.totalTax;
94
68
  this.invoiceNumber = new fields_1.TextField({
95
- prediction: { value: undefined, confidence: 0.0 },
69
+ prediction: prediction.invoice_number,
70
+ pageId: pageId,
71
+ });
72
+ this.supplierName = new fields_1.TextField({
73
+ prediction: prediction.supplier_name,
74
+ pageId: pageId,
75
+ });
76
+ this.supplierAddress = new fields_1.TextField({
77
+ prediction: prediction.supplier_address,
78
+ pageId: pageId,
96
79
  });
80
+ this.supplierCompanyRegistrations =
81
+ prediction.supplier_company_registrations.map(function (prediction) {
82
+ return new fields_1.CompanyRegistration({
83
+ prediction: prediction,
84
+ pageId: pageId,
85
+ });
86
+ });
97
87
  this.customerName = new fields_1.TextField({
98
- prediction: { value: undefined, confidence: 0.0 },
88
+ prediction: prediction.customer_name,
89
+ pageId: pageId,
99
90
  });
100
91
  this.customerAddress = new fields_1.TextField({
101
- prediction: { value: undefined, confidence: 0.0 },
92
+ prediction: prediction.customer_address,
93
+ pageId: pageId,
94
+ });
95
+ prediction.customer_company_registrations.map((prediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
96
+ prediction: prediction,
97
+ pageId: pageId,
98
+ })));
99
+ prediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
100
+ prediction: prediction,
101
+ pageId: pageId,
102
+ })));
103
+ prediction.line_items.map((prediction) => this.lineItems.push(new invoiceLineItem_1.InvoiceLineItem({
104
+ prediction: prediction,
105
+ })));
106
+ this.tip = new fields_1.Amount({
107
+ prediction: prediction.tip,
108
+ valueKey: "value",
109
+ pageId: pageId,
110
+ });
111
+ this.category = new fields_1.TextField({
112
+ prediction: prediction.category,
113
+ pageId: pageId,
114
+ });
115
+ this.subCategory = new fields_1.TextField({
116
+ prediction: prediction.subcategory,
117
+ pageId: pageId,
102
118
  });
119
+ this.time = new fields_1.TextField({
120
+ prediction: prediction.time,
121
+ pageId: pageId,
122
+ });
123
+ prediction.taxes.map((taxPrediction) => this.taxes.push(new fields_1.TaxField({
124
+ prediction: taxPrediction,
125
+ pageId: pageId,
126
+ valueKey: "value",
127
+ rateKey: "rate",
128
+ codeKey: "code",
129
+ baseKey: "base",
130
+ })));
103
131
  }
104
- }, _FinancialDocumentV1_checklist = function _FinancialDocumentV1_checklist() {
105
- this.checklist = {
106
- taxesMatchTotalIncl: __classPrivateFieldGet(this, _FinancialDocumentV1_instances, "m", _FinancialDocumentV1_taxesMatchTotalIncl).call(this),
107
- };
108
- }, _FinancialDocumentV1_taxesMatchTotalIncl = function _FinancialDocumentV1_taxesMatchTotalIncl() {
109
- // Check taxes and total include exist
110
- if (this.taxes.length === 0 || this.totalIncl.value === undefined)
111
- return false;
112
- // Reconstruct totalIncl from taxes
113
- let totalVat = 0;
114
- let reconstructedTotal = 0;
115
- this.taxes.forEach((tax) => {
116
- if (tax.value === undefined || !tax.rate)
117
- return false;
118
- totalVat += tax.value;
119
- reconstructedTotal += tax.value + (100 * tax.value) / tax.rate;
120
- });
121
- // Sanity check
122
- if (totalVat <= 0)
123
- return false;
124
- // Crate epsilon
125
- const eps = 1 / (100 * totalVat);
126
- if (this.totalIncl.value * (1 - eps) - 0.02 <= reconstructedTotal &&
127
- reconstructedTotal <= this.totalIncl.value * (1 + eps) + 0.02) {
128
- this.taxes = this.taxes.map((tax) => ({
129
- ...tax,
130
- confidence: 1.0,
131
- }));
132
- this.totalTax.confidence = 1.0;
133
- this.totalIncl.confidence = 1.0;
134
- return true;
132
+ toString() {
133
+ const taxes = this.taxes.map((item) => item.toString()).join("\n ");
134
+ const referenceNumbers = this.referenceNumbers
135
+ .map((item) => item.toString())
136
+ .join(", ");
137
+ const paymentDetails = this.supplierPaymentDetails
138
+ .map((item) => item.toString())
139
+ .join("\n ");
140
+ const customerCompanyRegistration = this.customerCompanyRegistrations
141
+ .map((item) => item.toString())
142
+ .join("; ");
143
+ const supplierCompanyRegistration = this.supplierCompanyRegistrations
144
+ .map((item) => item.toString())
145
+ .join("; ");
146
+ let lineItems = "";
147
+ if (this.lineItems.length > 0) {
148
+ lineItems =
149
+ "\n Code | QTY | Price | Amount | Tax (Rate) | Description\n ";
150
+ lineItems += this.lineItems.map((item) => item.toString()).join("\n ");
151
+ }
152
+ const outStr = `----- Financial Document V1 -----
153
+ Filename: ${this.filename}
154
+ Document type: ${this.documentType}
155
+ Category: ${this.category}
156
+ Subcategory: ${this.subCategory}
157
+ Locale: ${this.locale}
158
+ Invoice number: ${this.invoiceNumber}
159
+ Reference numbers: ${referenceNumbers}
160
+ Date: ${this.date}
161
+ Due date: ${this.dueDate}
162
+ Time: ${this.time}
163
+ Supplier name: ${this.supplierName}
164
+ Supplier address: ${this.supplierAddress}
165
+ Supplier company registrations: ${supplierCompanyRegistration}
166
+ Supplier payment details: ${paymentDetails}
167
+ Customer name: ${this.customerName}
168
+ Customer address: ${this.customerAddress}
169
+ Customer company registrations: ${customerCompanyRegistration}
170
+ Tip: ${this.tip}
171
+ Taxes: ${taxes}
172
+ Total tax: ${this.totalTax}
173
+ Total net: ${this.totalNet}
174
+ Total amount: ${this.totalAmount}
175
+ Line Items: ${lineItems}
176
+ ----------------------
177
+ `;
178
+ return FinancialDocumentV1.cleanOutString(outStr);
135
179
  }
136
- return false;
137
- };
180
+ }
181
+ exports.FinancialDocumentV1 = FinancialDocumentV1;
@@ -27,9 +27,10 @@ class BankAccountDetailsV1 extends document_1.Document {
27
27
  }
28
28
  toString() {
29
29
  const outStr = `----- FR Bank Account Details V1 -----
30
+ Filename: ${this.filename}
30
31
  IBAN: ${this.iban}
31
- Account holder name: ${this.accountHolderName}
32
- SWIFT: ${this.swift}
32
+ Account Holder's Name: ${this.accountHolderName}
33
+ SWIFT Code: ${this.swift}
33
34
  ----------------------
34
35
  `;
35
36
  return BankAccountDetailsV1.cleanOutString(outStr);
@@ -33,10 +33,10 @@ class CarteVitaleV1 extends document_1.Document {
33
33
  toString() {
34
34
  const outStr = `----- FR Carte Vitale V1 -----
35
35
  Filename: ${this.filename}
36
- Given names: ${this.givenNames.map((name) => name.value).join(" ")}
36
+ Given Name(s): ${this.givenNames.map((name) => name.value).join(" ")}
37
37
  Surname: ${this.surname}
38
38
  Social Security Number: ${this.socialSecurity}
39
- Issuance date: ${this.issuanceDate}
39
+ Issuance Date: ${this.issuanceDate}
40
40
  ----------------------
41
41
  `;
42
42
  return CarteVitaleV1.cleanOutString(outStr);
@@ -58,19 +58,19 @@ class IdCardV1 extends document_1.Document {
58
58
  })));
59
59
  }
60
60
  toString() {
61
- const outStr = `----- FR ID Card V1 -----
61
+ const outStr = `----- FR Carte Nationale d'Identité V1 -----
62
62
  Filename: ${this.filename}
63
- Document side: ${this.documentSide}
64
- Authority: ${this.authority}
65
- Given names: ${this.givenNames.map((name) => name.value).join(" ")}
63
+ Document Side: ${this.documentSide}
64
+ Identity Number: ${this.idNumber}
65
+ Given Name(s): ${this.givenNames.map((name) => name.value).join(" ")}
66
66
  Surname: ${this.surname}
67
+ Date of Birth: ${this.birthDate}
68
+ Place of Birth: ${this.birthPlace}
69
+ Expiry Date: ${this.expiryDate}
70
+ Issuing Authority: ${this.authority}
67
71
  Gender: ${this.gender}
68
- ID Number: ${this.idNumber}
69
- Birth date: ${this.birthDate}
70
- Birth place: ${this.birthPlace}
71
- Expiry date: ${this.expiryDate}
72
- MRZ 1: ${this.mrz1}
73
- MRZ 2: ${this.mrz2}
72
+ MRZ Line 1: ${this.mrz1}
73
+ MRZ Line 2: ${this.mrz2}
74
74
  ----------------------
75
75
  `;
76
76
  return IdCardV1.cleanOutString(outStr);
@@ -4,10 +4,14 @@ export { InvoiceSplitterV1, PageGroup, } from "./invoiceSplitter/invoiceSplitter
4
4
  export { ReceiptV3 } from "./receipt/receiptV3";
5
5
  export { ReceiptV4 } from "./receipt/receiptV4";
6
6
  export { PassportV1 } from "./passport/passportV1";
7
+ export { FinancialDocumentV0 } from "./financialDocument/financialDocumentV0";
7
8
  export { FinancialDocumentV1 } from "./financialDocument/financialDocumentV1";
8
9
  export { CustomV1 } from "./custom/customV1";
10
+ export { getLineItems } from "./custom/lineitems";
9
11
  export { CropperV1 } from "./cropper/cropperV1";
10
- export { ShippingContainerV1 } from "./shipping_container/shippingContainerV1";
12
+ export { MindeeVisionV1 } from "./mindeeVision/mindeeVisionV1";
13
+ export { ProofOfAddressV1 } from "./proofOfAddress/proofOfAddressV1";
14
+ export { ShippingContainerV1 } from "./shippingContainer/shippingContainerV1";
11
15
  export { Document, DocumentConstructorProps, DocumentSig } from "./document";
12
16
  export * as fr from "./fr";
13
17
  export * as us from "./us";
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.CropperV1 = exports.CustomV1 = exports.FinancialDocumentV1 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
26
+ exports.eu = exports.us = exports.fr = exports.Document = exports.ShippingContainerV1 = exports.ProofOfAddressV1 = exports.MindeeVisionV1 = exports.CropperV1 = exports.getLineItems = exports.CustomV1 = exports.FinancialDocumentV1 = exports.FinancialDocumentV0 = exports.PassportV1 = exports.ReceiptV4 = exports.ReceiptV3 = exports.PageGroup = exports.InvoiceSplitterV1 = exports.InvoiceV4 = exports.InvoiceV3 = void 0;
27
27
  var invoiceV3_1 = require("./invoice/invoiceV3");
28
28
  Object.defineProperty(exports, "InvoiceV3", { enumerable: true, get: function () { return invoiceV3_1.InvoiceV3; } });
29
29
  var invoiceV4_1 = require("./invoice/invoiceV4");
@@ -37,13 +37,21 @@ var receiptV4_1 = require("./receipt/receiptV4");
37
37
  Object.defineProperty(exports, "ReceiptV4", { enumerable: true, get: function () { return receiptV4_1.ReceiptV4; } });
38
38
  var passportV1_1 = require("./passport/passportV1");
39
39
  Object.defineProperty(exports, "PassportV1", { enumerable: true, get: function () { return passportV1_1.PassportV1; } });
40
+ var financialDocumentV0_1 = require("./financialDocument/financialDocumentV0");
41
+ Object.defineProperty(exports, "FinancialDocumentV0", { enumerable: true, get: function () { return financialDocumentV0_1.FinancialDocumentV0; } });
40
42
  var financialDocumentV1_1 = require("./financialDocument/financialDocumentV1");
41
43
  Object.defineProperty(exports, "FinancialDocumentV1", { enumerable: true, get: function () { return financialDocumentV1_1.FinancialDocumentV1; } });
42
44
  var customV1_1 = require("./custom/customV1");
43
45
  Object.defineProperty(exports, "CustomV1", { enumerable: true, get: function () { return customV1_1.CustomV1; } });
46
+ var lineitems_1 = require("./custom/lineitems");
47
+ Object.defineProperty(exports, "getLineItems", { enumerable: true, get: function () { return lineitems_1.getLineItems; } });
44
48
  var cropperV1_1 = require("./cropper/cropperV1");
45
49
  Object.defineProperty(exports, "CropperV1", { enumerable: true, get: function () { return cropperV1_1.CropperV1; } });
46
- var shippingContainerV1_1 = require("./shipping_container/shippingContainerV1");
50
+ var mindeeVisionV1_1 = require("./mindeeVision/mindeeVisionV1");
51
+ Object.defineProperty(exports, "MindeeVisionV1", { enumerable: true, get: function () { return mindeeVisionV1_1.MindeeVisionV1; } });
52
+ var proofOfAddressV1_1 = require("./proofOfAddress/proofOfAddressV1");
53
+ Object.defineProperty(exports, "ProofOfAddressV1", { enumerable: true, get: function () { return proofOfAddressV1_1.ProofOfAddressV1; } });
54
+ var shippingContainerV1_1 = require("./shippingContainer/shippingContainerV1");
47
55
  Object.defineProperty(exports, "ShippingContainerV1", { enumerable: true, get: function () { return shippingContainerV1_1.ShippingContainerV1; } });
48
56
  var document_1 = require("./document");
49
57
  Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return document_1.Document; } });
@@ -1,12 +1,13 @@
1
1
  import { Document, DocumentConstructorProps } from "../document";
2
- import { TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration, BaseField } from "../../fields";
2
+ import { ClassificationField, TaxField, PaymentDetails, Locale, Amount, TextField, DateField, CompanyRegistration } from "../../fields";
3
3
  import { InvoiceLineItem } from "./invoiceLineItem";
4
+ /** Invoice V4 */
4
5
  export declare class InvoiceV4 extends Document {
5
6
  #private;
6
7
  /** Locale information. */
7
8
  locale: Locale;
8
9
  /** The nature of the invoice. */
9
- documentType: BaseField;
10
+ documentType: ClassificationField;
10
11
  /** List of Reference numbers including PO number. */
11
12
  referenceNumbers: TextField[];
12
13
  /** The total amount with tax included. */
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
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
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _InvoiceV4_instances, _InvoiceV4_initFromApiPrediction, _InvoiceV4_checklist, _InvoiceV4_reconstruct;
7
+ var _InvoiceV4_instances, _InvoiceV4_checklist, _InvoiceV4_reconstruct;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.InvoiceV4 = void 0;
10
10
  const document_1 = require("../document");
@@ -12,6 +12,7 @@ const fields_1 = require("../../fields");
12
12
  const invoiceLineItem_1 = require("./invoiceLineItem");
13
13
  const checks_1 = require("./checks");
14
14
  const reconstruction_1 = require("./reconstruction");
15
+ /** Invoice V4 */
15
16
  class InvoiceV4 extends document_1.Document {
16
17
  constructor({ prediction, orientation = undefined, extras = undefined, inputSource = undefined, fullText = undefined, pageId = undefined, }) {
17
18
  super({
@@ -34,7 +35,88 @@ class InvoiceV4 extends document_1.Document {
34
35
  this.taxes = [];
35
36
  /** Line items details. */
36
37
  this.lineItems = [];
37
- __classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_initFromApiPrediction).call(this, prediction, pageId);
38
+ this.locale = new fields_1.Locale({
39
+ prediction: prediction.locale,
40
+ valueKey: "language",
41
+ });
42
+ this.documentType = new fields_1.ClassificationField({
43
+ prediction: prediction.document_type,
44
+ valueKey: "value",
45
+ });
46
+ this.referenceNumbers = prediction.reference_numbers.map(function (prediction) {
47
+ return new fields_1.TextField({
48
+ prediction: prediction,
49
+ pageId: pageId,
50
+ });
51
+ });
52
+ this.totalAmount = new fields_1.Amount({
53
+ prediction: prediction.total_amount,
54
+ valueKey: "value",
55
+ pageId: pageId,
56
+ });
57
+ this.totalTax = new fields_1.Amount({
58
+ prediction: { value: undefined, confidence: 0.0 },
59
+ valueKey: "value",
60
+ pageId: pageId,
61
+ });
62
+ this.totalNet = new fields_1.Amount({
63
+ prediction: prediction.total_net,
64
+ valueKey: "value",
65
+ pageId: pageId,
66
+ });
67
+ this.date = new fields_1.DateField({
68
+ prediction: prediction.date,
69
+ pageId,
70
+ });
71
+ prediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({
72
+ prediction: prediction,
73
+ pageId: pageId,
74
+ valueKey: "value",
75
+ rateKey: "rate",
76
+ codeKey: "code",
77
+ })));
78
+ this.supplierCompanyRegistrations =
79
+ prediction.supplier_company_registrations.map(function (prediction) {
80
+ return new fields_1.CompanyRegistration({
81
+ prediction: prediction,
82
+ pageId: pageId,
83
+ });
84
+ });
85
+ this.dueDate = new fields_1.DateField({
86
+ prediction: prediction.due_date,
87
+ pageId: pageId,
88
+ });
89
+ this.invoiceNumber = new fields_1.TextField({
90
+ prediction: prediction.invoice_number,
91
+ pageId: pageId,
92
+ });
93
+ this.supplierName = new fields_1.TextField({
94
+ prediction: prediction.supplier_name,
95
+ pageId: pageId,
96
+ });
97
+ this.supplierAddress = new fields_1.TextField({
98
+ prediction: prediction.supplier_address,
99
+ pageId: pageId,
100
+ });
101
+ this.customerName = new fields_1.TextField({
102
+ prediction: prediction.customer_name,
103
+ pageId: pageId,
104
+ });
105
+ this.customerAddress = new fields_1.TextField({
106
+ prediction: prediction.customer_address,
107
+ pageId: pageId,
108
+ });
109
+ prediction.customer_company_registrations.map((prediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
110
+ prediction: prediction,
111
+ pageId: pageId,
112
+ })));
113
+ prediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
114
+ prediction: prediction,
115
+ pageId: pageId,
116
+ })));
117
+ prediction.line_items.map((prediction) => this.lineItems.push(new invoiceLineItem_1.InvoiceLineItem({
118
+ prediction: prediction,
119
+ })));
38
120
  __classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_checklist).call(this);
39
121
  __classPrivateFieldGet(this, _InvoiceV4_instances, "m", _InvoiceV4_reconstruct).call(this);
40
122
  }
@@ -83,90 +165,7 @@ Total amount including taxes: ${this.totalAmount}
83
165
  }
84
166
  }
85
167
  exports.InvoiceV4 = InvoiceV4;
86
- _InvoiceV4_instances = new WeakSet(), _InvoiceV4_initFromApiPrediction = function _InvoiceV4_initFromApiPrediction(apiPrediction, pageId) {
87
- this.locale = new fields_1.Locale({
88
- prediction: apiPrediction.locale,
89
- valueKey: "language",
90
- });
91
- this.documentType = new fields_1.BaseField({
92
- prediction: apiPrediction.document_type,
93
- valueKey: "value",
94
- });
95
- this.referenceNumbers = apiPrediction.reference_numbers.map(function (prediction) {
96
- return new fields_1.TextField({
97
- prediction: prediction,
98
- pageId: pageId,
99
- });
100
- });
101
- this.totalAmount = new fields_1.Amount({
102
- prediction: apiPrediction.total_amount,
103
- valueKey: "value",
104
- pageId: pageId,
105
- });
106
- this.totalTax = new fields_1.Amount({
107
- prediction: { value: undefined, confidence: 0.0 },
108
- valueKey: "value",
109
- pageId: pageId,
110
- });
111
- this.totalNet = new fields_1.Amount({
112
- prediction: apiPrediction.total_net,
113
- valueKey: "value",
114
- pageId: pageId,
115
- });
116
- this.date = new fields_1.DateField({
117
- prediction: apiPrediction.date,
118
- pageId,
119
- });
120
- apiPrediction.taxes.map((prediction) => this.taxes.push(new fields_1.TaxField({
121
- prediction: prediction,
122
- pageId: pageId,
123
- valueKey: "value",
124
- rateKey: "rate",
125
- codeKey: "code",
126
- })));
127
- this.supplierCompanyRegistrations =
128
- apiPrediction.supplier_company_registrations.map(function (prediction) {
129
- return new fields_1.CompanyRegistration({
130
- prediction: prediction,
131
- pageId: pageId,
132
- });
133
- });
134
- this.dueDate = new fields_1.DateField({
135
- prediction: apiPrediction.due_date,
136
- pageId: pageId,
137
- });
138
- this.invoiceNumber = new fields_1.TextField({
139
- prediction: apiPrediction.invoice_number,
140
- pageId: pageId,
141
- });
142
- this.supplierName = new fields_1.TextField({
143
- prediction: apiPrediction.supplier_name,
144
- pageId: pageId,
145
- });
146
- this.supplierAddress = new fields_1.TextField({
147
- prediction: apiPrediction.supplier_address,
148
- pageId: pageId,
149
- });
150
- this.customerName = new fields_1.TextField({
151
- prediction: apiPrediction.customer_name,
152
- pageId: pageId,
153
- });
154
- this.customerAddress = new fields_1.TextField({
155
- prediction: apiPrediction.customer_address,
156
- pageId: pageId,
157
- });
158
- apiPrediction.customer_company_registrations.map((prediction) => this.customerCompanyRegistrations.push(new fields_1.CompanyRegistration({
159
- prediction: prediction,
160
- pageId: pageId,
161
- })));
162
- apiPrediction.supplier_payment_details.map((prediction) => this.supplierPaymentDetails.push(new fields_1.PaymentDetails({
163
- prediction: prediction,
164
- pageId: pageId,
165
- })));
166
- apiPrediction.line_items.map((prediction) => this.lineItems.push(new invoiceLineItem_1.InvoiceLineItem({
167
- prediction: prediction,
168
- })));
169
- }, _InvoiceV4_checklist = function _InvoiceV4_checklist() {
168
+ _InvoiceV4_instances = new WeakSet(), _InvoiceV4_checklist = function _InvoiceV4_checklist() {
170
169
  this.checklist = {
171
170
  taxesMatchTotalIncl: (0, checks_1.taxesMatchTotalIncl)(this),
172
171
  taxesMatchTotalExcl: (0, checks_1.taxesMatchTotalExcl)(this),
@@ -1,9 +1,9 @@
1
1
  import { Document, DocumentConstructorProps } from "../document";
2
+ import { StringDict } from "../../fields";
2
3
  export declare class PageGroup {
3
4
  pageIndexes: number[];
4
- constructor(prediction: {
5
- [index: string]: number[];
6
- });
5
+ confidence: number;
6
+ constructor(prediction: StringDict);
7
7
  toString(): string;
8
8
  }
9
9
  export declare class InvoiceSplitterV1 extends Document {
@@ -6,6 +6,7 @@ class PageGroup {
6
6
  constructor(prediction) {
7
7
  this.pageIndexes = [];
8
8
  this.pageIndexes = prediction.page_indexes;
9
+ this.confidence = prediction.confidence;
9
10
  }
10
11
  toString() {
11
12
  return `page indexes: ${this.pageIndexes.join(", ")}`;
@@ -0,0 +1,8 @@
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
+ }